Re: [PATCH v3 4/4] iio: light: ltr501: Add support for the LTR-659PS-01 proximity sensor
From: Jonathan Cameron
Date: Sat Nov 14 2026 - 18:02:33 EST
On Sun, 8 Nov 2026 11:42:53 +0200
Svyatoslav Ryhel <clamor95@xxxxxxxxx> wrote:
> Add support for the Lite-On LTR-659PS-01 proximity sensor. This device is
> nearly identical to the LTR-559ALS-01, but omits all elements related to
> ambient light sensing.
>
> Add a no_als_support flag, similar to how no_irq_support is used, to
> isolate ALS register access for the LTR-659PS-01, since ALS registers are
> marked as reserved and interactions with them are discouraged.
>
> The ltr501_trigger_handler relied on the scan index to identify channels.
> This approach is fragile regarding channel status flags and can break if
> the index is not strictly set. Switch to checking the channel type
> instead.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@xxxxxxxxx>
Just trivial stuff inline.
Thanks,
Jonathan
> @@ -1260,16 +1295,21 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p)
> aligned_s64 ts;
> } scan = { };
> __le16 als_buf[2];
> + unsigned int i;
> u8 mask = 0;
> int j = 0;
> int ret, psdata;
>
> /* figure out which data needs to be ready */
> - 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;
> + for_each_set_bit(i, indio_dev->active_scan_mask, indio_dev->num_channels) {
iio_for_each_active_channel() should work here. The longer term plan is
to make some of this stuff opaque so I have a series that I haven't posted
yet converting most users over to this macro.
> + const struct iio_chan_spec *chan = iio_find_channel_from_si(indio_dev, i);
Fine exporting that helper.
Thanks,
Jonathan
> +
> + if (chan->type == IIO_INTENSITY)
> + mask |= LTR501_STATUS_ALS_RDY;
> +
> + if (chan->type == IIO_PROXIMITY)
> + mask |= LTR501_STATUS_PS_RDY;
> + }