From: Jonathan Cameron <jic23@kernel.org>
To: raoxu <raoxu@uniontech.com>
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
luiz.von.dentz@intel.com, pengpeng@iscas.ac.cn,
pmenzel@molgen.mpg.de, brgl@kernel.org,
u.kleine-koenig@baylibre.com, lars@metafoo.de,
mike.looijmans@topic.nl, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Joshua Crofts <crofts@kernel.org>
Subject: Re: [PATCH v3] iio: adc: ltc2471: Fix LTC2473 differential offset
Date: Fri, 13 Nov 2026 02:21:53 +0000 [thread overview]
Message-ID: <20261113022153.445fdcb7@jic23-hlaptop> (raw)
In-Reply-To: <B29B7229F9C3B748+20261110122414.373459-1-raoxu@uniontech.com>
On Tue, 10 Nov 2026 20:24:14 +0800
raoxu <raoxu@uniontech.com> wrote:
> From: Xu Rao <raoxu@uniontech.com>
>
> The LTC2473 reports its differential conversion result as an unsigned
> 16-bit value spanning -VREF to +VREF. The IIO scale is consequently
> reported as 2 * VREF divided by 2^16.
>
> IIO offsets are expressed in raw codes, but the driver currently returns
> -LTC2471_VREF, which is a millivolt value. This makes the processed
> reading incorrect: with a 1.25 V reference, the midpoint raw code is
> shifted by 1250 instead of 32768 codes.
>
> Return the raw-code offset so that the midpoint maps to 0 mV and the
> endpoints map to -VREF and +VREF as intended. The single-ended LTC2471
> does not expose the offset attribute and is unaffected.
>
> Fixes: 1d3eacbfa644 ("iio: Add LTC2471/LTC2473 driver")
> Cc: stable@vger.kernel.org
> Reviewed-by: Joshua Crofts <crofts@kernel.org>
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> Signed-off-by: Xu Rao <raoxu@uniontech.com>
Applied to the fixes-togreg branch of iio.git
Thanks
Jonathan
> ---
> Changes in v3:
> - Add Reviewed-by tags from Nuno Sá and Joshua Crofts.
> - Move the AI assistance disclosure out of the commit message.
> - No code changes from v2.
>
> Changes in v2:
> - Replace the raw -32768 literal with the named LTC2473_DIFF_OFFSET
> macro.
>
> The supplied fix was reviewed and this commit message prepared with
> OpenCode AI assistance.
>
> drivers/iio/adc/ltc2471.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ltc2471.c b/drivers/iio/adc/ltc2471.c
> index 369af700969f..eb418c0fa732 100644
> --- a/drivers/iio/adc/ltc2471.c
> +++ b/drivers/iio/adc/ltc2471.c
> @@ -25,6 +25,7 @@ struct ltc2471_data {
>
> /* Reference voltage is 1.25V */
> #define LTC2471_VREF 1250
> +#define LTC2473_DIFF_OFFSET (-32768)
>
> /* Read two bytes from the I2C bus to obtain the ADC result */
> static int ltc2471_get_value(struct i2c_client *client)
> @@ -69,7 +70,7 @@ static int ltc2471_read_raw(struct iio_dev *indio_dev,
>
> case IIO_CHAN_INFO_OFFSET:
> /* Only differential chip has this property */
> - *val = -LTC2471_VREF;
> + *val = LTC2473_DIFF_OFFSET;
> return IIO_VAL_INT;
>
> default:
> --
> 2.50.1
prev parent reply other threads:[~2026-11-13 2:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 12:24 raoxu
2026-11-13 2:21 ` Jonathan Cameron [this message]
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=20261113022153.445fdcb7@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=brgl@kernel.org \
--cc=crofts@kernel.org \
--cc=dlechner@baylibre.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.von.dentz@intel.com \
--cc=mike.looijmans@topic.nl \
--cc=nuno.sa@analog.com \
--cc=pengpeng@iscas.ac.cn \
--cc=pmenzel@molgen.mpg.de \
--cc=raoxu@uniontech.com \
--cc=stable@vger.kernel.org \
--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
all inboxes | Powered by JetHome®