From: Jonathan Cameron <jic23@kernel.org>
To: <alexandru.tachici@analog.com>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/5] iio: adc: ad7192: Add update_scan_mode
Date: Fri, 12 Nov 2021 16:57:55 +0000 [thread overview]
Message-ID: <20211112165755.0504e06a@jic23-huawei> (raw)
In-Reply-To: <20211110111750.27263-3-alexandru.tachici@analog.com>
On Wed, 10 Nov 2021 13:17:47 +0200
<alexandru.tachici@analog.com> wrote:
> From: Alexandru Tachici <alexandru.tachici@analog.com>
>
> In continuous mode neither sigma_delta.c nor ad7192.c
> will disable previously enabled channels.
>
> Before this patch a channel stayed enabled indefinetly,
> even when one another one was supposed to be sampled.
> This causes mixed samples in continuous mode to be delivered
> to the host.
Can you expand a bit on the path that leads to this. As far as I can tell
in both continuous mode enable and single channel reading set_channel()
callback is called and will overwrite the channels enabled previously.
Perhaps I'm missing a path in which that call isn't made?
>
> By adding an update_scan_mode callback, every time the
> continuous mode is activated, channels will be enabled/disabled
> accordingly.
>
> Fixes: 3f7c3306cf38 ("staging:iio:ad7192: Use common Sigma Delta library")
> Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
> ---
> drivers/iio/adc/ad7192.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c
> index 2121a812b0c3..1fc0f4eb858e 100644
> --- a/drivers/iio/adc/ad7192.c
> +++ b/drivers/iio/adc/ad7192.c
> @@ -782,6 +782,20 @@ static int ad7192_read_avail(struct iio_dev *indio_dev,
> return -EINVAL;
> }
>
> +static int ad7192_update_scan_mode(struct iio_dev *indio_dev, const unsigned long *scan_mask)
> +{
> + struct ad7192_state *st = iio_priv(indio_dev);
> + int i;
> +
> + st->conf &= ~AD7192_CONF_CHAN_MASK;
> + for (i = 0; i < 8; i++) {
> + if (test_bit(i, scan_mask))
for_each_set_bit()
> + st->conf |= AD7192_CONF_CHAN(i);
> + }
> +
> + return ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, st->conf);
> +}
> +
> static const struct iio_info ad7192_info = {
> .read_raw = ad7192_read_raw,
> .write_raw = ad7192_write_raw,
> @@ -789,6 +803,7 @@ static const struct iio_info ad7192_info = {
> .read_avail = ad7192_read_avail,
> .attrs = &ad7192_attribute_group,
> .validate_trigger = ad_sd_validate_trigger,
> + .update_scan_mode = ad7192_update_scan_mode,
> };
>
> static const struct iio_info ad7195_info = {
> @@ -798,6 +813,7 @@ static const struct iio_info ad7195_info = {
> .read_avail = ad7192_read_avail,
> .attrs = &ad7195_attribute_group,
> .validate_trigger = ad_sd_validate_trigger,
> + .update_scan_mode = ad7192_update_scan_mode,
> };
>
> #define __AD719x_CHANNEL(_si, _channel1, _channel2, _address, _extend_name, \
next prev parent reply other threads:[~2021-11-12 16:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-10 11:17 [PATCH 0/5] iio: adc: ad_sigma_delta: Add sequencer support alexandru.tachici
2021-11-10 11:17 ` [PATCH 1/5] iio: adc: ad7124: Add update_scan_mode alexandru.tachici
2021-11-12 16:54 ` Jonathan Cameron
2021-11-10 11:17 ` [PATCH 2/5] iio: adc: ad7192: " alexandru.tachici
2021-11-12 16:57 ` Jonathan Cameron [this message]
2021-11-10 11:17 ` [PATCH 3/5] iio: adc: ad_sigma_delta: Add sequencer support alexandru.tachici
2021-11-12 17:14 ` Jonathan Cameron
2021-11-13 17:00 ` Andy Shevchenko
2021-11-13 18:23 ` Jonathan Cameron
2021-11-10 11:17 ` [PATCH 4/5] iio: adc: ad7124: add " alexandru.tachici
2021-11-10 11:17 ` [PATCH 5/5] iio: adc: ad7192: " alexandru.tachici
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=20211112165755.0504e06a@jic23-huawei \
--to=jic23@kernel.org \
--cc=alexandru.tachici@analog.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.