Re: [PATCH] iio: ad_sigma_delta: Introduce prepare_channel callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 19 Mar 2019 11:53:06 +0200
Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx> wrote:

> From: Lars-Peter Clausen <lars@xxxxxxxxxx>
> 
> The prepare channel callback will be called before starting a conversion and
> can be used by the driver to configure the chip according to the selected
> channel.
> 
> Signed-off-by: Lars-Peter Clausen <lars@xxxxxxxxxx>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx>

Hi Alexandru,

Not without a user....  I.e. I want to see a driver using this before
I apply it. In of itself, it is fine but right now I can't answer the
'why?' question!

Jonathan

> ---
>  drivers/iio/adc/ad_sigma_delta.c       |  5 +++++
>  include/linux/iio/adc/ad_sigma_delta.h | 13 +++++++++++++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
> index ff5f2da2e1b1..00808838edd8 100644
> --- a/drivers/iio/adc/ad_sigma_delta.c
> +++ b/drivers/iio/adc/ad_sigma_delta.c
> @@ -285,6 +285,7 @@ int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev,
>  		return -EBUSY;
>  
>  	mutex_lock(&indio_dev->mlock);
> +	ad_sigma_delta_prepare_channel(sigma_delta, chan);
>  	ad_sigma_delta_set_channel(sigma_delta, chan->address);
>  
>  	spi_bus_lock(sigma_delta->spi->master);
> @@ -351,6 +352,10 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev)
>  
>  	channel = find_first_bit(indio_dev->active_scan_mask,
>  				 indio_dev->masklength);
> +	ret = ad_sigma_delta_prepare_channel(sigma_delta,
> +		&indio_dev->channels[channel]);
> +	if (ret)
> +		goto err_predisable;
>  	ret = ad_sigma_delta_set_channel(sigma_delta,
>  		indio_dev->channels[channel].address);
>  	if (ret)
> diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc/ad_sigma_delta.h
> index 7e84351fa2c0..21ee12543bdd 100644
> --- a/include/linux/iio/adc/ad_sigma_delta.h
> +++ b/include/linux/iio/adc/ad_sigma_delta.h
> @@ -31,6 +31,8 @@ struct iio_dev;
>  
>  /**
>   * struct ad_sigma_delta_info - Sigma Delta driver specific callbacks and options
> + * @prepare_channel: Will be called to prepare and configure a channel, may be
> + *                   NULL.
>   * @set_channel: Will be called to select the current channel, may be NULL.
>   * @set_mode: Will be called to select the current mode, may be NULL.
>   * @postprocess_sample: Is called for each sampled data word, can be used to
> @@ -43,6 +45,8 @@ struct iio_dev;
>   *   be used.
>   */
>  struct ad_sigma_delta_info {
> +	int (*prepare_channel)(struct ad_sigma_delta *,
> +		const struct iio_chan_spec *);
>  	int (*set_channel)(struct ad_sigma_delta *, unsigned int channel);
>  	int (*set_mode)(struct ad_sigma_delta *, enum ad_sigma_delta_mode mode);
>  	int (*postprocess_sample)(struct ad_sigma_delta *, unsigned int raw_sample);
> @@ -81,6 +85,15 @@ struct ad_sigma_delta {
>  	uint8_t				data[4] ____cacheline_aligned;
>  };
>  
> +static inline int ad_sigma_delta_prepare_channel(struct ad_sigma_delta *sd,
> +	const struct iio_chan_spec *chan)
> +{
> +	if (sd->info->prepare_channel)
> +		return sd->info->prepare_channel(sd, chan);
> +
> +	return 0;
> +}
> +
>  static inline int ad_sigma_delta_set_channel(struct ad_sigma_delta *sd,
>  	unsigned int channel)
>  {




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux