From: Jonathan Cameron <jic23@kernel.org>
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: "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 v2 4/4] iio: light: ltr501: Add support for the LTR-659PS-01 proximity sensor
Date: Sat, 7 Nov 2026 19:43:19 +0000 [thread overview]
Message-ID: <20261107194319.0645b31f@jic23-hlaptop> (raw)
In-Reply-To: <CAPVz0n10N6PvBC5AL=nT+fUGsONtuzTZvzSYqAXP_eWWb86nuQ@mail.gmail.com>
On Sat, 7 Nov 2026 12:15:07 +0200
Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> сб, 7 лист. 2026 р. о 05:33 Jonathan Cameron <jic23@kernel.org> пише:
> >
> > On Fri, 6 Nov 2026 11:19:43 +0200
> > Svyatoslav Ryhel <clamor95@gmail.com> 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@gmail.com>
> > > ---
> > > drivers/iio/light/ltr501.c | 73 +++++++++++++++++++++++++++++++-------
> > > 1 file changed, 61 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
> > > index d5ce6468a229b..e7762115df913 100644
> > > --- a/drivers/iio/light/ltr501.c
> > > +++ b/drivers/iio/light/ltr501.c
> > > @@ -151,6 +151,7 @@ struct ltr501_chip_info {
> > > u8 als_gain_mask;
> > > u8 als_gain_shift;
> > > bool no_irq_support;
> > > + bool no_als_support;
> > > struct iio_chan_spec const *channels;
> > > const int no_channels;
> > > };
> > > @@ -192,6 +193,11 @@ static bool ltr501_has_irq_support(const struct ltr501_chip_info *info)
> > > return !info->no_irq_support;
> > > }
> > >
> > > +static bool ltr501_has_als_support(const struct ltr501_chip_info *info)
> >
> > Is the helper bring enough value? The !info->no_als_support
> > where this is used seems clear enough to me.
> >
>
> Noted, if you are fine with !info->no_als_support I have no objections.
>
> > > +{
> > > + return !info->no_als_support;
> > > +}
> > > +
> > > static int ltr501_match_samp_freq(const struct ltr501_samp_table *tab,
> > > int len, int val, int val2)
> > > {
> > > @@ -656,6 +662,29 @@ static const struct iio_chan_spec ltr301_channels[] = {
> > > IIO_CHAN_SOFT_TIMESTAMP(2),
> > > };
> > >
> > > +static const struct iio_chan_spec ltr659_channels[] = {
> > > + {
> > > + .type = IIO_PROXIMITY,
> > > + .address = LTR501_PS_DATA,
> > > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > > + BIT(IIO_CHAN_INFO_SCALE) |
> > > + BIT(IIO_CHAN_INFO_SAMP_FREQ),
> > > + .info_mask_separate_available = BIT(IIO_CHAN_INFO_SCALE) |
> > > + BIT(IIO_CHAN_INFO_SAMP_FREQ),
> >
> > The sampling frequency applies to both channels here. I'd just make that
> > info_mask_shared_by_all
> >
>
> so IIO_CHAN_INFO_SCALE is separate
> and IIO_CHAN_INFO_SAMP_FREQ is shared_by_all
>
> Noted.
>
Roughly speaking look at what is being described and consider what it applies to.
Here the timestamp is grabbed for each single channel read, so sampling_frequency
it applies to the timestamp as well as the channel. There are messier corners
with sampling for devices with more channels where it would be per channel in
the case that they are sampled one by one.
That usually indicates the sampling frequency of a scan is 1/(1/sampA + 1/sampB ...)
If the sampling of a scan is independent of channels enabled (because we read
them all anyway, parallel read out in the hardware or the sampling is clocked at
a rate such that they all get sampled in less time than the inter sample frequency
then sampling_frequency may still be shared_by_all.
The scale doesn't apply to the timestamp. Now you only have one channel
so you could use shared_by_type, but for this I'd just go with most common
pattern for related drivers and separate is also a valid ABI choice.
Userspace should always cope with figuring out whether the broader scoped
parameters apply to a specific channel - so separate and shared_by_type
are equivalent when there is only one channel of the type.
Jonathan
>
> > > + .scan_index = 0,
> > > + .scan_type = {
> > > + .sign = 'u',
> > > + .realbits = 11,
> > > + .storagebits = 16,
> > > + .endianness = IIO_CPU,
> > > + },
> > > + .event_spec = ltr501_pxs_event_spec,
> > > + .num_event_specs = ARRAY_SIZE(ltr501_pxs_event_spec),
> > > + .ext_info = ltr501_ext_info,
> > > + },
> > > + IIO_CHAN_SOFT_TIMESTAMP(1),
> > > +};
> >
prev parent reply other threads:[~2026-11-07 19:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 9:19 [PATCH v2 0/4] iio: light: ltr501: Add LTR-659PS-01 prox sensor support Svyatoslav Ryhel
2026-11-06 9:19 ` [PATCH v2 1/4] iio: light: ltr501: Switch to read_avail() op from manual attribute registration Svyatoslav Ryhel
2026-11-07 3:20 ` Jonathan Cameron
2026-11-07 10:10 ` Svyatoslav Ryhel
2026-11-07 10:59 ` Joshua Crofts
2026-11-06 9:19 ` [PATCH v2 2/4] iio: light: ltr501: Switch to modern match mechanism Svyatoslav Ryhel
2026-11-07 3:30 ` Jonathan Cameron
2026-11-07 10:13 ` Svyatoslav Ryhel
2026-11-07 19:51 ` Jonathan Cameron
2026-11-06 9:19 ` [PATCH v2 3/4] dt-bindings: iio: light: ltr501: Document LTR659 proximity sensor Svyatoslav Ryhel
2026-11-06 17:31 ` Conor Dooley
2026-11-06 9:19 ` [PATCH v2 4/4] iio: light: ltr501: Add support for the LTR-659PS-01 " Svyatoslav Ryhel
2026-11-07 3:33 ` Jonathan Cameron
2026-11-07 10:15 ` Svyatoslav Ryhel
2026-11-07 19:43 ` 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=20261107194319.0645b31f@jic23-hlaptop \
--to=jic23@kernel.org \
--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=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®