[PATCH 1/6] iio: light: isl29125: Report the scale list via read_avail()
From: Arka Mondal
Date: Mon Nov 02 2026 - 02:48:35 EST
The intensity channels set IIO_CHAN_INFO_SCALE in
info_mask_shared_by_type, so userspace reads the scale from
in_intensity_scale. The values that attribute accepts are listed by a
custom attribute named scale_available. That name carries no channel
prefix, so it is registered at the device level and is never paired
with the channel. The core would have called it
in_intensity_scale_available, which is also the name
Documentation/ABI/testing/sysfs-bus-iio gives, so userspace does not
find the list where the ABI says it is.
Report the two values through read_avail() and drop the custom
attribute group. The values and the text they print do not change.
Fixes: 208335138001 ("iio: light: isl29125: Add scale_available information")
Signed-off-by: Arka Mondal <arka@xxxxxxxxxxxxxx>
---
Notes:
Compile tested only; no relevant hardware available.
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..0efe0d72f9d6 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_type_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