From: Arka Mondal <arka@arkamondal.net>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Robert Eshleman" <bobbyeshleman@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
"Arka Mondal" <arka@arkamondal.net>
Subject: [PATCH v2 1/2] iio: light: isl29125: Report the scale list via read_avail()
Date: Mon, 9 Nov 2026 14:07:37 +0900 [thread overview]
Message-ID: <20261109050738.93424-2-arka@arkamondal.net> (raw)
In-Reply-To: <20261109050738.93424-1-arka@arkamondal.net>
The scales the intensity channels accept are listed by a custom
attribute built with IIO_CONST_ATTR and named scale_available.
Report the two values through read_avail() and drop the attribute
group. The available bit goes in info_mask_shared_by_all_available,
the sharing level the core names scale_available, so the file keeps
the name it has. The scale itself stays in info_mask_shared_by_type
and is still in_intensity_scale. veml6030 and ti-ads1015 hold
IIO_CHAN_INFO_SCALE in info_mask_separate and list it under
info_mask_shared_by_all_available, so the pairing is already in use.
The two values and the text they print do not change.
Signed-off-by: Arka Mondal <arka@arkamondal.net>
---
Notes:
No hardware available. Loaded against CONFIG_I2C_STUB under qemu:
in_intensity_scale and scale_available are both present,
in_intensity_scale_available is not, and scale_available reads
0.005722 0.152590.
drivers/iio/light/isl29125.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c
index 9e0b7e6a3ecf..35a378cc3990 100644
--- a/drivers/iio/light/isl29125.c
+++ b/drivers/iio/light/isl29125.c
@@ -58,6 +58,7 @@ struct isl29125_data {
.modified = 1, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
+ .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_SCALE), \
.channel2 = IIO_MOD_LIGHT_##_color, \
.scan_index = _si, \
.scan_type = { \
@@ -198,21 +199,31 @@ static irqreturn_t isl29125_trigger_handler(int irq, void *p)
return IRQ_HANDLED;
}
-static IIO_CONST_ATTR(scale_available, "0.005722 0.152590");
-
-static struct attribute *isl29125_attributes[] = {
- &iio_const_attr_scale_available.dev_attr.attr,
- NULL
+static const int isl29125_scale_avail[] = {
+ 0, ISL29125_SENSING_RANGE_0,
+ 0, ISL29125_SENSING_RANGE_1,
};
-static const struct attribute_group isl29125_attribute_group = {
- .attrs = isl29125_attributes,
-};
+static int isl29125_read_avail(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ const int **vals, int *type, int *length,
+ long mask)
+{
+ switch (mask) {
+ case IIO_CHAN_INFO_SCALE:
+ *vals = isl29125_scale_avail;
+ *type = IIO_VAL_INT_PLUS_MICRO;
+ *length = ARRAY_SIZE(isl29125_scale_avail);
+ return IIO_AVAIL_LIST;
+ default:
+ return -EINVAL;
+ }
+}
static const struct iio_info isl29125_info = {
.read_raw = isl29125_read_raw,
.write_raw = isl29125_write_raw,
- .attrs = &isl29125_attribute_group,
+ .read_avail = isl29125_read_avail,
};
static int isl29125_buffer_postenable(struct iio_dev *indio_dev)
--
2.56.0
next prev parent reply other threads:[~2026-11-09 5:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 5:07 [PATCH v2 0/2] iio: light: Report the available lists " Arka Mondal
2026-11-09 5:07 ` Arka Mondal [this message]
2026-11-09 5:07 ` [PATCH v2 2/2] iio: light: max44009: Report the integration time " Arka Mondal
2026-11-09 23:19 ` Andy Shevchenko
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=20261109050738.93424-2-arka@arkamondal.net \
--to=arka@arkamondal.net \
--cc=andy@kernel.org \
--cc=bobbyeshleman@gmail.com \
--cc=dlechner@baylibre.com \
--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®