From: Jonathan Cameron <jic23@jic23.retrosnub.co.uk>
To: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <linux-iio@vger.kernel.org>, Lars-Peter Clausen <lars@metafoo.de>
Subject: Re: [PATCH] iio: ad_sigma_delta: Introduce prepare_channel callback
Date: Sun, 24 Mar 2019 17:49:03 +0000 [thread overview]
Message-ID: <20190324174903.77158070@archlinux> (raw)
In-Reply-To: <20190319095306.16010-1-alexandru.ardelean@analog.com>
On Tue, 19 Mar 2019 11:53:06 +0200
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:
> From: Lars-Peter Clausen <lars@metafoo.de>
>
> 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@metafoo.de>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
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)
> {
next prev parent reply other threads:[~2019-03-24 17:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 9:53 [PATCH] iio: ad_sigma_delta: Introduce prepare_channel callback Alexandru Ardelean
2019-03-24 17:49 ` Jonathan Cameron [this message]
2019-03-26 6:53 ` Ardelean, Alexandru
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190324174903.77158070@archlinux \
--to=jic23@jic23.retrosnub.co.uk \
--cc=alexandru.ardelean@analog.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox