From: David Lechner <dlechner@baylibre.com>
To: "Yuanshen Cao" <alex.caoys@gmail.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: light: tsl2772: fix ALS calibscale readback
Date: Sat, 25 Jul 2026 16:27:39 -0500 [thread overview]
Message-ID: <99422b78-20e7-4222-a2d8-ca778a3a618b@baylibre.com> (raw)
In-Reply-To: <20260724-tsl2772-calibscale-fix-v1-1-00a7789f4deb@gmail.com>
On 7/24/26 6:46 PM, Yuanshen Cao wrote:
> The read_raw() implementation uses IIO_LIGHT to distinguish between the
> ambient light and proximity channels when handling
> IIO_CHAN_INFO_CALIBSCALE.
>
> However, the ALS channel is registered as IIO_INTENSITY, while
> write_raw() correctly writes to IIO_INTENSITY. As a result, reading
> in_intensity0_calibscale incorrectly returns the proximity gain instead
> of the ALS gain.
>
> This causes the following user-visible behavior:
> - Writing in_intensity0_calibscale appears to have no effect because the
> readback reports the proximity gain.
> - Writing in_proximity0_calibscale causes both in_proximity0_calibscale
> and in_intensity0_calibscale to report the same value.
>
> Fix this by checking for IIO_INTENSITY in read_raw(), matching the
> channel definition and the existing write_raw() implementation.
>
> Signed-off-by: Yuanshen Cao <alex.caoys@gmail.com>
> ---
> drivers/iio/light/tsl2772.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c
> index 244f44379c36..2287585711c6 100644
> --- a/drivers/iio/light/tsl2772.c
> +++ b/drivers/iio/light/tsl2772.c
> @@ -1274,7 +1274,7 @@ static int tsl2772_read_raw(struct iio_dev *indio_dev,
> }
> break;
> case IIO_CHAN_INFO_CALIBSCALE:
> - if (chan->type == IIO_LIGHT)
> + if (chan->type == IIO_INTENSITY)
> *val = tsl2772_als_gain[chip->settings.als_gain];
> else
> *val = tsl2772_prox_gain[chip->settings.prox_gain];
>
> ---
> base-commit: 1590cf0329716306e948a8fc29f1d3ee87d3989f
> change-id: 20260724-tsl2772-calibscale-fix-0cc42518d5fc
>
> Best regards,
> --
> Yuanshen Cao <alex.caoys@gmail.com>
>
Reviewed-by: David Lechner <dlechner@baylibre.com>
next prev parent reply other threads:[~2026-07-25 21:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 23:46 Yuanshen Cao
2026-07-25 21:27 ` David Lechner [this message]
2026-07-27 2:14 ` Jonathan Cameron
2026-07-27 4:40 ` Yuanshen Cao
2026-07-27 21:25 ` Jonathan Cameron
2026-08-03 21:35 ` 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=99422b78-20e7-4222-a2d8-ca778a3a618b@baylibre.com \
--to=dlechner@baylibre.com \
--cc=alex.caoys@gmail.com \
--cc=andy@kernel.org \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.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®