* [PATCH v2 0/2] iio: light: Report the available lists via read_avail()
@ 2026-11-09 5:07 Arka Mondal
2026-11-09 5:07 ` [PATCH v2 1/2] iio: light: isl29125: Report the scale list " Arka Mondal
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Arka Mondal @ 2026-11-09 5:07 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Robert Eshleman, linux-iio, linux-kernel,
Arka Mondal
These are patches 1 and 3 of the v1 series. Patches 2, 4, 5 and 6 are
applied and are not resent.
Changes since v1:
- isl29125: the available bit goes in info_mask_shared_by_all_available
instead of info_mask_shared_by_type_available, which is the sharing
level that names the file scale_available, so the attribute keeps the
name it has and no ABI changes. The Fixes: tag is gone with it, and
the patch is a cleanup rather than a fix.
- max44009: the list is IIO_VAL_INT_PLUS_MICRO instead of
IIO_VAL_INT_PLUS_NANO. All eight values are a whole number of
microseconds, so three zeros go and nothing is rounded.
I loaded both drivers against CONFIG_I2C_STUB under qemu and read the
attributes. isl29125 shows in_intensity_scale and scale_available, no
in_intensity_scale_available, and scale_available still reads
0.005722 0.152590. max44009 shows in_illuminance_integration_time_available
reading 0.800000 0.400000 0.200000 0.100000 0.050000 0.025000 0.012500 0.006250,
and no unprefixed name.
Link: https://lore.kernel.org/r/20261102074700.63075-1-arka@arkamondal.net
Arka Mondal (2):
iio: light: isl29125: Report the scale list via read_avail()
iio: light: max44009: Report the integration time via read_avail()
drivers/iio/light/isl29125.c | 29 +++++++++++++++-------
drivers/iio/light/max44009.c | 48 ++++++++++++++++++++----------------
2 files changed, 47 insertions(+), 30 deletions(-)
base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
--
2.56.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] iio: light: isl29125: Report the scale list via read_avail()
2026-11-09 5:07 [PATCH v2 0/2] iio: light: Report the available lists via read_avail() Arka Mondal
@ 2026-11-09 5:07 ` Arka Mondal
2026-11-09 5:07 ` [PATCH v2 2/2] iio: light: max44009: Report the integration time " Arka Mondal
2026-11-14 23:44 ` [PATCH v2 0/2] iio: light: Report the available lists " Jonathan Cameron
2 siblings, 0 replies; 6+ messages in thread
From: Arka Mondal @ 2026-11-09 5:07 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Robert Eshleman, linux-iio, linux-kernel,
Arka Mondal
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] iio: light: max44009: Report the integration time via read_avail()
2026-11-09 5:07 [PATCH v2 0/2] iio: light: Report the available lists via read_avail() Arka Mondal
2026-11-09 5:07 ` [PATCH v2 1/2] iio: light: isl29125: Report the scale list " Arka Mondal
@ 2026-11-09 5:07 ` Arka Mondal
2026-11-09 23:19 ` Andy Shevchenko
2026-11-14 23:44 ` [PATCH v2 0/2] iio: light: Report the available lists " Jonathan Cameron
2 siblings, 1 reply; 6+ messages in thread
From: Arka Mondal @ 2026-11-09 5:07 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Robert Eshleman, linux-iio, linux-kernel,
Arka Mondal
The integration times the light channel accepts are listed by a custom
attribute named illuminance_integration_time_available. That name has
no in_ prefix, so it is registered at the device level instead of
beside in_illuminance_integration_time, and userspace looking for
in_illuminance_integration_time_available finds nothing.
Report the list through read_avail() and drop the custom attribute.
All eight values are a whole number of microseconds, so they go in as
IIO_VAL_INT_PLUS_MICRO pairs with nothing rounded. The values do not
change; the core prints them with six decimals, so the attribute reads
0.800000 down to 0.006250 instead of 0.8 down to 0.00625. read_raw()
still reports the time itself as IIO_VAL_INT_PLUS_NANO.
Fixes: 6aef699a7d7e ("iio: light: add driver for MAX44009")
Signed-off-by: Arka Mondal <arka@arkamondal.net>
---
Notes:
No hardware available. Loaded against CONFIG_I2C_STUB under qemu:
in_illuminance_integration_time_available reads 0.800000 0.400000
0.200000 0.100000 0.050000 0.025000 0.012500 0.006250, and the
unprefixed name is gone.
drivers/iio/light/max44009.c | 48 ++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 21 deletions(-)
diff --git a/drivers/iio/light/max44009.c b/drivers/iio/light/max44009.c
index 82b8a806c5fa..8a57b9812f7f 100644
--- a/drivers/iio/light/max44009.c
+++ b/drivers/iio/light/max44009.c
@@ -66,15 +66,16 @@ static const u32 max44009_int_time_ns_array[] = {
6250000, /* Manual mode only */
};
-static const char max44009_int_time_str[] =
- "0.8 "
- "0.4 "
- "0.2 "
- "0.1 "
- "0.05 "
- "0.025 "
- "0.0125 "
- "0.00625";
+static const int max44009_int_time_avail[] = {
+ 0, 800000,
+ 0, 400000,
+ 0, 200000,
+ 0, 100000,
+ 0, 50000,
+ 0, 25000,
+ 0, 12500,
+ 0, 6250,
+};
struct max44009_data {
struct i2c_client *client;
@@ -101,6 +102,7 @@ static const struct iio_chan_spec max44009_channels[] = {
.type = IIO_LIGHT,
.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
BIT(IIO_CHAN_INFO_INT_TIME),
+ .info_mask_separate_available = BIT(IIO_CHAN_INFO_INT_TIME),
.event_spec = max44009_event_spec,
.num_event_specs = ARRAY_SIZE(max44009_event_spec),
},
@@ -284,17 +286,21 @@ static int max44009_read_raw(struct iio_dev *indio_dev,
}
}
-static IIO_CONST_ATTR(illuminance_integration_time_available,
- max44009_int_time_str);
-
-static struct attribute *max44009_attributes[] = {
- &iio_const_attr_illuminance_integration_time_available.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group max44009_attribute_group = {
- .attrs = max44009_attributes,
-};
+static int max44009_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_INT_TIME:
+ *vals = max44009_int_time_avail;
+ *type = IIO_VAL_INT_PLUS_MICRO;
+ *length = ARRAY_SIZE(max44009_int_time_avail);
+ return IIO_AVAIL_LIST;
+ default:
+ return -EINVAL;
+ }
+}
static int max44009_threshold_byte_from_fraction(int integral, int fractional)
{
@@ -464,7 +470,7 @@ static const struct iio_info max44009_info = {
.read_event_config = max44009_read_event_config,
.write_event_value = max44009_write_event_value,
.write_event_config = max44009_write_event_config,
- .attrs = &max44009_attribute_group,
+ .read_avail = max44009_read_avail,
};
static irqreturn_t max44009_threaded_irq_handler(int irq, void *p)
--
2.56.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] iio: light: max44009: Report the integration time via read_avail()
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
2026-11-14 23:41 ` Jonathan Cameron
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2026-11-09 23:19 UTC (permalink / raw)
To: Arka Mondal
Cc: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Robert Eshleman, linux-iio, linux-kernel
On Mon, Nov 09, 2026 at 02:07:38PM +0900, Arka Mondal wrote:
> The integration times the light channel accepts are listed by a custom
> attribute named illuminance_integration_time_available. That name has
> no in_ prefix, so it is registered at the device level instead of
> beside in_illuminance_integration_time, and userspace looking for
> in_illuminance_integration_time_available finds nothing.
>
> Report the list through read_avail() and drop the custom attribute.
Will break it user space?
> All eight values are a whole number of microseconds, so they go in as
> IIO_VAL_INT_PLUS_MICRO pairs with nothing rounded. The values do not
> change; the core prints them with six decimals, so the attribute reads
> 0.800000 down to 0.006250 instead of 0.8 down to 0.00625. read_raw()
> still reports the time itself as IIO_VAL_INT_PLUS_NANO.
...
> +static const int max44009_int_time_avail[] = {
> + 0, 800000,
> + 0, 400000,
> + 0, 200000,
> + 0, 100000,
> + 0, 50000,
> + 0, 25000,
> + 0, 12500,
> + 0, 6250,
> +};
Make it 2d array.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] iio: light: max44009: Report the integration time via read_avail()
2026-11-09 23:19 ` Andy Shevchenko
@ 2026-11-14 23:41 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2026-11-14 23:41 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Arka Mondal, David Lechner, Nuno Sá,
Andy Shevchenko, Robert Eshleman, linux-iio, linux-kernel
On Tue, 10 Nov 2026 01:19:57 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Mon, Nov 09, 2026 at 02:07:38PM +0900, Arka Mondal wrote:
> > The integration times the light channel accepts are listed by a custom
> > attribute named illuminance_integration_time_available. That name has
> > no in_ prefix, so it is registered at the device level instead of
> > beside in_illuminance_integration_time, and userspace looking for
> > in_illuminance_integration_time_available finds nothing.
> >
> > Report the list through read_avail() and drop the custom attribute.
>
> Will break it user space?
Yes, but given no standard tools would have looked for that naming
we should be able to get away with it without anyone noticing.
Given it's an optional attribute I'm guessing everything just assumed
it wasn't provided.
Always the risk of a custom board script of course that might cause
us to have to carry the old broken ABI.
Arka, you should clearly state thee concerns in the patch description
to answer questions like the one Andy raised.
Thanks
Jonathan
>
> > All eight values are a whole number of microseconds, so they go in as
> > IIO_VAL_INT_PLUS_MICRO pairs with nothing rounded. The values do not
> > change; the core prints them with six decimals, so the attribute reads
> > 0.800000 down to 0.006250 instead of 0.8 down to 0.00625. read_raw()
> > still reports the time itself as IIO_VAL_INT_PLUS_NANO.
>
> ...
>
> > +static const int max44009_int_time_avail[] = {
> > + 0, 800000,
> > + 0, 400000,
> > + 0, 200000,
> > + 0, 100000,
> > + 0, 50000,
> > + 0, 25000,
> > + 0, 12500,
> > + 0, 6250,
> > +};
>
> Make it 2d array.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] iio: light: Report the available lists via read_avail()
2026-11-09 5:07 [PATCH v2 0/2] iio: light: Report the available lists via read_avail() Arka Mondal
2026-11-09 5:07 ` [PATCH v2 1/2] iio: light: isl29125: Report the scale list " Arka Mondal
2026-11-09 5:07 ` [PATCH v2 2/2] iio: light: max44009: Report the integration time " Arka Mondal
@ 2026-11-14 23:44 ` Jonathan Cameron
2 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2026-11-14 23:44 UTC (permalink / raw)
To: Arka Mondal
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Robert Eshleman, linux-iio, linux-kernel
On Mon, 9 Nov 2026 14:07:36 +0900
Arka Mondal <arka@arkamondal.net> wrote:
> These are patches 1 and 3 of the v1 series. Patches 2, 4, 5 and 6 are
> applied and are not resent.
>
> Changes since v1:
>
> - isl29125: the available bit goes in info_mask_shared_by_all_available
> instead of info_mask_shared_by_type_available, which is the sharing
> level that names the file scale_available, so the attribute keeps the
> name it has and no ABI changes. The Fixes: tag is gone with it, and
> the patch is a cleanup rather than a fix.
>
> - max44009: the list is IIO_VAL_INT_PLUS_MICRO instead of
> IIO_VAL_INT_PLUS_NANO. All eight values are a whole number of
> microseconds, so three zeros go and nothing is rounded.
>
> I loaded both drivers against CONFIG_I2C_STUB under qemu and read the
> attributes. isl29125 shows in_intensity_scale and scale_available, no
> in_intensity_scale_available, and scale_available still reads
> 0.005722 0.152590. max44009 shows in_illuminance_integration_time_available
> reading 0.800000 0.400000 0.200000 0.100000 0.050000 0.025000 0.012500 0.006250,
> and no unprefixed name.
>
> Link: https://lore.kernel.org/r/20261102074700.63075-1-arka@arkamondal.net
Applied both to the testing branch of iio.git.
I added a note on the ABI break in patch 2 being a fix of buggy ABI and
cross our fingers case
Thanks
Jonathan
>
> Arka Mondal (2):
> iio: light: isl29125: Report the scale list via read_avail()
> iio: light: max44009: Report the integration time via read_avail()
>
> drivers/iio/light/isl29125.c | 29 +++++++++++++++-------
> drivers/iio/light/max44009.c | 48 ++++++++++++++++++++----------------
> 2 files changed, 47 insertions(+), 30 deletions(-)
>
>
> base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-14 23:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 5:07 [PATCH v2 0/2] iio: light: Report the available lists via read_avail() Arka Mondal
2026-11-09 5:07 ` [PATCH v2 1/2] iio: light: isl29125: Report the scale list " Arka Mondal
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
2026-11-14 23:41 ` Jonathan Cameron
2026-11-14 23:44 ` [PATCH v2 0/2] iio: light: Report the available lists " Jonathan Cameron
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®