From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 1/4] iio: light: ltr501: Switch to read_avail() op from manual attribute registration
Date: Fri, 06 Nov 2026 09:29:35 +0000 [thread overview]
Message-ID: <sashiko-outbox-201110@kernel.org> (raw)
In-Reply-To: <20261106091943.35783-2-clamor95@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] iio: light: ltr501: wrong available masks break scale_available
sysfs ABI
- [Medium] iio: light: ltr501: ltr501_read_avail() exposes reserved gain
entries
--
commit 62f3eb145ee7bea38108b1176e688878b094c714
Author: Svyatoslav Ryhel <clamor95@gmail.com>
iio: light: ltr501: Switch to read_avail() op from manual attribute registration
This commit replaces manual *_available sysfs attribute registration with
the IIO read_avail() callback and consolidates the per-chip iio_info
structures.
> diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
> index 302be2fc314c5..cc5d7af44d77c 100644
> --- a/drivers/iio/light/ltr501.c
> +++ b/drivers/iio/light/ltr501.c
[ ... ]
> @@ -590,6 +604,7 @@ static const struct iio_event_spec ltr501_pxs_event_spec[] = {
> .channel2 = (_mod), \
> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
> .info_mask_shared_by_type = (_shared), \
> + .info_mask_shared_by_all_available = (_shared), \
> .scan_index = (_idx), \
> .scan_type = { \
> .sign = 'u', \
[Severity: High]
Does setting .info_mask_shared_by_all_available = (_shared) break the
sysfs ABI for scale availability?
_shared includes BIT(IIO_CHAN_INFO_SCALE), so placing it in
info_mask_shared_by_all_available registers scale_available instead of
in_intensity_scale_available (which requires
info_mask_shared_by_type_available).
In addition, the IIO_PROXIMITY channel in ltr501_channels sets
BIT(IIO_CHAN_INFO_SCALE) in .info_mask_separate without a matching
.info_mask_separate_available mask, so in_proximity_scale_available is
no longer registered on ltr501 or ltr559 and the proximity scale branch in
ltr501_read_avail() is unreachable.
> @@ -1111,111 +1126,56 @@ static int ltr501_write_event_config(struct iio_dev *indio_dev,
> return -EINVAL;
> }
>
> -static ssize_t ltr501_show_proximity_scale_avail(struct device *dev,
> - struct device_attribute *attr,
> - char *buf)
> +static int ltr501_read_avail(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + const int **vals, int *type, int *length, long mask)
> {
> - struct ltr501_data *data = iio_priv(dev_to_iio_dev(dev));
> + struct ltr501_data *data = iio_priv(indio_dev);
> const struct ltr501_chip_info *info = data->chip_info;
[ ... ]
> + switch (mask) {
> + case IIO_CHAN_INFO_SCALE:
> + if (chan->type == IIO_INTENSITY) {
> + *length = info->als_gain_tbl_size * 2;
> + *vals = (const int *)info->als_gain;
> + } else {
> + *length = info->ps_gain_tbl_size * 2;
> + *vals = (const int *)info->ps_gain;
> + }
> + *type = IIO_VAL_INT_PLUS_MICRO;
> + return IIO_AVAIL_LIST;
[Severity: Medium]
Does returning info->als_gain directly as IIO_AVAIL_LIST expose
LTR501_RESERVED_GAIN sentinel entries to userspace?
ltr559_als_gain_tbl (used by ltr303, ltr329, and ltr559) is indexed by
hardware register value and has two reserved entries:
drivers/iio/light/ltr501.c:
static const struct ltr501_gain ltr559_als_gain_tbl[] = {
...
{LTR501_RESERVED_GAIN, LTR501_RESERVED_GAIN},
{LTR501_RESERVED_GAIN, LTR501_RESERVED_GAIN},
{0, 20000},
{0, 10000},
};
ltr501_show_intensity_scale_avail() previously skipped entries equal to
LTR501_RESERVED_GAIN (-1), whereas iio_format_avail_list() formats each
{-1, -1} pair as "-1.000001" in sysfs.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106091943.35783-1-clamor95@gmail.com?part=1
next prev parent reply other threads:[~2026-11-06 9:29 UTC|newest]
Thread overview: 18+ 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-06 9:29 ` sashiko-bot [this message]
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-06 9:37 ` sashiko-bot
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-06 9:31 ` sashiko-bot
2026-11-07 3:33 ` Jonathan Cameron
2026-11-07 10:15 ` Svyatoslav Ryhel
2026-11-07 19:43 ` 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=sashiko-outbox-201110@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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