From: Arnav Kapoor <kapoorarnav43@gmail.com>
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Esben Haabendal" <esben@geanix.com>,
"Kuppuswamy Sathyanarayanan"
<sathyanarayanan.kuppuswamy@linux.intel.com>,
"Uwe Kleine-König (The Capable Hub)"
<u.kleine-koenig@baylibre.com>, "Pan Chuang" <panchuang@vivo.com>,
"Hemanth Selam" <hemanth.selam@gmail.com>,
"Antoniu Miclaus" <antoniu.miclaus@analog.com>,
"Nikita Travkin" <nikita@trvn.ru>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 4/4] iio: light: ltr501: Add support for the LTR-659PS-01 proximity sensor
Date: Tue, 17 Nov 2026 00:51:56 +0530 [thread overview]
Message-ID: <20261116192156.33333-1-kapoorarnav43@gmail.com> (raw)
In-Reply-To: <20261115083741.62140-5-clamor95@gmail.com>
On Sun, Nov 15, 2026 at 10:37:41AM +0200, Svyatoslav Ryhel wrote:
> - if (test_bit(0, indio_dev->active_scan_mask) ||
> - test_bit(1, indio_dev->active_scan_mask))
> - mask |= LTR501_STATUS_ALS_RDY;
> - if (test_bit(2, indio_dev->active_scan_mask))
> - mask |= LTR501_STATUS_PS_RDY;
> + iio_for_each_active_channel(indio_dev, chan_idx) {
> + const struct iio_chan_spec *chan = &indio_dev->channels[chan_idx];
iio_for_each_active_channel() walks the bits of active_scan_mask, so
chan_idx is a scan index, not an index into indio_dev->channels[].
The two only match when every channel before it has scan_index ==
array position. That holds for ltr659_channels[], but not for
ltr501_channels[] (also used by ltr559) or ltr301_channels[]: entry 0
there is LTR501_LIGHT_CHANNEL() with .scan_index = -1, so scan bit N
maps to channels[N + 1].
On ltr501/ltr559 that gives:
scan bit 0 (intensity_both) -> channels[0], IIO_LIGHT: no RDY bit set
scan bit 1 (intensity_ir) -> channels[1], IIO_INTENSITY: ALS_RDY (ok)
scan bit 2 (proximity) -> channels[2], IIO_INTENSITY: ALS_RDY
scan bit 3 (timestamp) -> channels[3], IIO_PROXIMITY: PS_RDY
So a proximity-only buffer waits for ALS_RDY and never reads PS (the
"if (mask & LTR501_STATUS_PS_RDY)" block is skipped), and pushes
zeros; intensity_both alone gives mask == 0 and also pushes zeros;
and enabling the timestamp makes an ALS-only capture wait for PS_RDY
as well. On ltr301 bit 0 is likewise lost.
> + if (chan->type == IIO_INTENSITY)
> + mask |= LTR501_STATUS_ALS_RDY;
> +
> + if (chan->type == IIO_PROXIMITY)
> + mask |= LTR501_STATUS_PS_RDY;
> + }
This is what iio_find_channel_from_si() is for, as Jonathan suggested
on v3. With the export patch you sent separately, something like
iio_for_each_active_channel(indio_dev, scan_idx) {
const struct iio_chan_spec *chan =
iio_find_channel_from_si(indio_dev, scan_idx);
...
}
(it also returns the timestamp channel, which matches neither type)
would keep the type-based check working for all four chips. Since
this patch is the export's only user, it is probably best to fold the
export into this series.
Thanks,
Arnav
prev parent reply other threads:[~2026-11-16 19:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 8:37 [PATCH v4 0/4] iio: light: ltr501: Add LTR-659PS-01 prox sensor support Svyatoslav Ryhel
2026-11-15 8:37 ` [PATCH v4 1/4] iio: light: ltr501: Switch to read_avail() op from manual attribute registration Svyatoslav Ryhel
2026-11-15 8:37 ` [PATCH v4 2/4] iio: light: ltr501: Switch to modern match mechanism Svyatoslav Ryhel
2026-11-15 8:37 ` [PATCH v4 3/4] dt-bindings: iio: light: ltr501: Document LTR659 proximity sensor Svyatoslav Ryhel
2026-11-15 8:37 ` [PATCH v4 4/4] iio: light: ltr501: Add support for the LTR-659PS-01 " Svyatoslav Ryhel
2026-11-16 19:21 ` Arnav Kapoor [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=20261116192156.33333-1-kapoorarnav43@gmail.com \
--to=kapoorarnav43@gmail.com \
--cc=andy@kernel.org \
--cc=antoniu.miclaus@analog.com \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=esben@geanix.com \
--cc=hemanth.selam@gmail.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nikita@trvn.ru \
--cc=nuno.sa@analog.com \
--cc=panchuang@vivo.com \
--cc=robh@kernel.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.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
all inboxes | Powered by JetHome®