From: Jonathan Cameron <jic23@kernel.org>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Dumitru Ceclan <dumitru.ceclan@analog.com>,
Nuno Sa <nuno.sa@analog.com>,
Guillaume Ranquet <granquet@baylibre.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: ad7124: Disable all channels at probe time
Date: Sat, 9 Nov 2024 15:24:38 +0000 [thread overview]
Message-ID: <20241109152438.0135f0c2@jic23-huawei> (raw)
In-Reply-To: <20241104101905.845737-2-u.kleine-koenig@baylibre.com>
On Mon, 4 Nov 2024 11:19:04 +0100
Uwe Kleine-König <u.kleine-koenig@baylibre.com> wrote:
> When during a measurement two channels are enabled, two measurements are
> done that are reported sequencially in the DATA register. As the code
> triggered by reading one of the sysfs properties expects that only one
> channel is enabled it only reads the first data set which might or might
> not belong to the intended channel.
>
> To prevent this situation disable all channels during probe. This fixes
> a problem in practise because the reset default for channel 0 is
> enabled. So all measurements before the first measurement on channel 0
> (which disables channel 0 at the end) might report wrong values.
>
> Fixes: 7b8d045e497a ("iio: adc: ad7124: allow more than 8 channels")
> Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---
> Hello,
>
> this patch was part of a series before. The remaining patches are still
> under discussion. As this is a fix orthogonal to the other patches of
> the series (apart from the other relevant change there also being
> necessary to make the ad7124 work for me) it IMHO makes sense to apply
> this one already now. There are machines that don't suffer from the
> other issue (i.e. the device irq becoming pending by spi traffic), so
> this fix is also valuable stand alone. It's IMHO good enough to go in
> before v6.12.
>
> The previous submission is available at
> https://lore.kernel.org/linux-iio/20241028160748.489596-10-u.kleine-koenig@baylibre.com/
>
> b4 ignored Nuno's Reviewed-by tag with
>
> NOTE: some trailers ignored due to from/email mismatches:
> ! Trailer: Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> Msg From: Nuno Sá <noname.nuno@gmail.com>
>
> I wonder if other maintainers use b4 apply's -S by default, because I
> often run into this issue but don't see others mentioning that.
I only use -S when Nuno has given a tag. It tends to be a bit too generous
on applying tags in general.
Thanks for picking it up here.
Sadly this has probably missed 6.12, but I have queued it up as a fix
for early next cycle and marked it for stable.
Thanks,
Jonathan
> I added the tag here anyhow.
>
> drivers/iio/adc/ad7124.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
> index a5d91933f505..749304d38415 100644
> --- a/drivers/iio/adc/ad7124.c
> +++ b/drivers/iio/adc/ad7124.c
> @@ -917,6 +917,9 @@ static int ad7124_setup(struct ad7124_state *st)
> * set all channels to this default value.
> */
> ad7124_set_channel_odr(st, i, 10);
> +
> + /* Disable all channels to prevent unintended conversions. */
> + ad_sd_write_reg(&st->sd, AD7124_CHANNEL(i), 2, 0);
> }
>
> ret = ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL, 2, st->adc_control);
>
> base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc
next prev parent reply other threads:[~2024-11-09 15:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 10:19 [PATCH] iio: adc: ad7124: Disable all channels at probe time Uwe Kleine-König
2024-11-09 15:24 ` Jonathan Cameron [this message]
2024-12-06 11:04 ` Uwe Kleine-König
2024-12-06 15:35 ` David Lechner
2024-12-06 16:11 ` Uwe Kleine-König
2024-12-07 17:15 ` Jonathan Cameron
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=20241109152438.0135f0c2@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=dumitru.ceclan@analog.com \
--cc=granquet@baylibre.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=u.kleine-koenig@baylibre.com \
/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