* [PATCH 0/6] iio: Give the *_available attributes the names the core generates
@ 2026-11-02 7:46 Arka Mondal
2026-11-02 7:46 ` [PATCH 1/6] iio: light: isl29125: Report the scale list via read_avail() Arka Mondal
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Arka Mondal @ 2026-11-02 7:46 UTC (permalink / raw)
To: Jonathan Cameron, Linus Walleij
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Peter Meerwald, Matt Ranostay, Robert Eshleman,
Leonard Crestez, linux-iio, linux-kernel, Arka Mondal
An <attr>_available file takes its name from the attribute whose values
it lists. The core builds both names with __iio_chan_prefix_emit(),
called for the available attribute with the same shared_by
argument, so the prefix follows from where the value sits:
in_<type> plus any index or modifier for info_mask_separate,
in_<type> for info_mask_shared_by_type, and nothing at all for
info_mask_shared_by_all. The iio-channel-prefix KUnit suite covers each
of those cases.
Six drivers build their lists by hand with IIO_CONST_ATTR instead,
and ten of the eleven names they use have no prefix even though
none of those values is shared across all channels. Each of
the ten is a device level attribute paired with no channel, so
its list is reachable only under a name that does not describe
it. Documentation/ABI/testing/sysfs-bus-iio keeps bare names
for the shared-across-all case, sampling_frequency_available and
oversampling_ratio_available, and gives the prefixed form everywhere
else: in_accel_scale_available, in_illuminance_scale_available,
in_intensity_hardwaregain_available. Anything that looks for a list
beside the attribute it belongs to finds no such file.
These patches hand all eleven lists to read_avail() and delete the
custom attribute groups. The same was done for hts221 in
commit 003e99cf33e3 ("iio: humidity: hts221: report available values via read_avail()")
where "the incorrectly named in_humidity_oversampling_ratio_available
attribute is replaced by the standard
in_humidityrelative_oversampling_ratio_available name", so the shape is
not new. The names change as follows.
isl29125 scale_available
-> in_intensity_scale_available
apds9960 proximity_scale_available
-> in_proximity_scale_available
apds9960 intensity_scale_available
-> in_intensity_scale_available
apds9960 integration_time_available
-> in_intensity_integration_time_available
max44009 illuminance_integration_time_available
-> in_illuminance_integration_time_available
max44000 illuminance_scale_available
-> in_illuminance_scale_available
max44000 illuminance_integration_time_available
-> in_illuminance_integration_time_available
hdc100x temp_integration_time_available
-> in_temp_integration_time_available
hdc100x humidityrelative_integration_time_available
-> in_humidityrelative_integration_time_available
hdc100x out_current_heater_raw_available
-> unchanged, this one was already right
mpu3050 anglevel_scale_available
-> in_anglvel_scale_available
Of the eleven lists, four print exactly the text they printed before and
six gain trailing decimals, because the core prints each value to the
full precision of its IIO_VAL_* type where the old strings were written
out by hand. apds9960's integration time, for one, becomes 0.028000
0.100000 0.200000 0.700000. The numbers are the same.
The eleventh is mpu3050, whose four values really do change. They were
computed against 2^16 while mpu3050_read_raw() divides by U16_MAX,
so the list never agreed with the channel: it offered 0.000122070
where in_anglvel_scale reports 0.000122072, and likewise for the other
three. Patch 6 builds the list from the same IIO_DEGREE_TO_RAD() terms
the read path uses, so the two cannot diverge again.
On who runs these parts: mpu3050 appears in eight in-tree device tree
files, covering Tegra 2 and 3 tablets, the APQ8060 Dragonboard and two
Ux500 phones, and hdc1080 in two, one of them an IBM BMC. apds9960,
max44000 and hdc100x also carry ACPI ids, so they turn up on x86
machines with no device tree at all. isl29125 and max44009 have no
in-tree user that I could find.
Compile tested only; I have none of this hardware. Patch 2 draws one
checkpatch spelling warning on a word inside its Fixes: subject. That
typo is in the 2015 commit being cited and has to stay, or the tag stops
matching the subject it names. I am happy to rebase on togreg or testing
if that is easier for you.
Arka Mondal (6):
iio: light: isl29125: Report the scale list via read_avail()
iio: light: apds9960: Report the available lists via read_avail()
iio: light: max44009: Report the integration time via read_avail()
iio: light: max44000: Report the available lists via read_avail()
iio: humidity: hdc100x: Report the available lists via read_avail()
iio: gyro: mpu3050: Fix the scale list and report it via read_avail()
drivers/iio/gyro/mpu3050-core.c | 40 ++++++++++++---------
drivers/iio/humidity/hdc100x.c | 61 ++++++++++++++++++++++++---------
drivers/iio/light/apds9960.c | 56 ++++++++++++++++++++++--------
drivers/iio/light/isl29125.c | 29 +++++++++++-----
drivers/iio/light/max44000.c | 60 +++++++++++++++++++-------------
drivers/iio/light/max44009.c | 48 ++++++++++++++------------
6 files changed, 193 insertions(+), 101 deletions(-)
base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
--
2.56.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/6] iio: light: isl29125: Report the scale list via read_avail()
2026-11-02 7:46 [PATCH 0/6] iio: Give the *_available attributes the names the core generates Arka Mondal
@ 2026-11-02 7:46 ` Arka Mondal
2026-11-02 22:26 ` Jonathan Cameron
2026-11-02 7:46 ` [PATCH 2/6] iio: light: apds9960: Report the available lists " Arka Mondal
` (4 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Arka Mondal @ 2026-11-02 7:46 UTC (permalink / raw)
To: Jonathan Cameron, Linus Walleij
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Peter Meerwald, Matt Ranostay, Robert Eshleman,
Leonard Crestez, linux-iio, linux-kernel, Arka Mondal
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@arkamondal.net>
---
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/6] iio: light: apds9960: Report the available lists via read_avail()
2026-11-02 7:46 [PATCH 0/6] iio: Give the *_available attributes the names the core generates Arka Mondal
2026-11-02 7:46 ` [PATCH 1/6] iio: light: isl29125: Report the scale list via read_avail() Arka Mondal
@ 2026-11-02 7:46 ` Arka Mondal
2026-11-02 7:46 ` [PATCH 3/6] iio: light: max44009: Report the integration time " Arka Mondal
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Arka Mondal @ 2026-11-02 7:46 UTC (permalink / raw)
To: Jonathan Cameron, Linus Walleij
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Peter Meerwald, Matt Ranostay, Robert Eshleman,
Leonard Crestez, linux-iio, linux-kernel, Arka Mondal
The proximity and intensity channels put IIO_CHAN_INFO_SCALE in
info_mask_shared_by_type, and the intensity channels put
IIO_CHAN_INFO_INT_TIME there too. The values those attributes accept
are listed by three custom attributes: proximity_scale_available,
intensity_scale_available and integration_time_available. None of the
three carries the in_ prefix that the core gives the attribute it
describes, so all three are registered at the device level, and
userspace looking for in_proximity_scale_available,
in_intensity_scale_available or in_intensity_integration_time_available
finds nothing.
Report all three through read_avail() and drop the custom attribute
group. The two gain lists keep their exact text. The integration time
list becomes 0.028000 0.100000 0.200000 0.700000 instead of 0.028 0.1
0.2 0.7, because the core prints IIO_VAL_INT_PLUS_MICRO with six
decimals. The values are unchanged.
Fixes: aff268cd532e ("iio: light: add APDS9960 ALS + promixity driver")
Signed-off-by: Arka Mondal <arka@arkamondal.net>
---
Notes:
Compile tested only; no relevant hardware available.
drivers/iio/light/apds9960.c | 56 +++++++++++++++++++++++++++---------
1 file changed, 42 insertions(+), 14 deletions(-)
diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c
index afe520de60e2..496678c4d338 100644
--- a/drivers/iio/light/apds9960.c
+++ b/drivers/iio/light/apds9960.c
@@ -289,6 +289,8 @@ static const struct iio_event_spec apds9960_als_event_spec[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
BIT(IIO_CHAN_INFO_INT_TIME), \
+ .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE) | \
+ BIT(IIO_CHAN_INFO_INT_TIME), \
.channel2 = IIO_MOD_LIGHT_##_colour, \
.address = APDS9960_REG_ALS_CHANNEL(_colour), \
.modified = 1, \
@@ -304,6 +306,7 @@ static const struct iio_chan_spec apds9960_channels[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_CALIBBIAS),
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
+ .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE),
.channel = 0,
.indexed = 0,
.scan_index = -1,
@@ -322,6 +325,8 @@ static const struct iio_chan_spec apds9960_channels[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_INT_TIME),
+ .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE) |
+ BIT(IIO_CHAN_INFO_INT_TIME),
.channel2 = IIO_MOD_LIGHT_CLEAR,
.address = APDS9960_REG_ALS_CHANNEL(CLEAR),
.modified = 1,
@@ -370,19 +375,11 @@ static const int apds9960_int_time[][2] = {
static const int apds9960_pxs_gain_map[] = {1, 2, 4, 8};
static const int apds9960_als_gain_map[] = {1, 4, 16, 64};
-static IIO_CONST_ATTR(proximity_scale_available, "1 2 4 8");
-static IIO_CONST_ATTR(intensity_scale_available, "1 4 16 64");
-static IIO_CONST_ATTR_INT_TIME_AVAIL("0.028 0.1 0.2 0.7");
-
-static struct attribute *apds9960_attributes[] = {
- &iio_const_attr_proximity_scale_available.dev_attr.attr,
- &iio_const_attr_intensity_scale_available.dev_attr.attr,
- &iio_const_attr_integration_time_available.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group apds9960_attribute_group = {
- .attrs = apds9960_attributes,
+static const int apds9960_int_time_avail[] = {
+ 0, 28000,
+ 0, 100000,
+ 0, 200000,
+ 0, 700000,
};
static const struct reg_field apds9960_reg_field_int_als =
@@ -786,8 +783,39 @@ static int apds9960_write_event_config(struct iio_dev *indio_dev,
return 0;
}
+static int apds9960_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:
+ switch (chan->type) {
+ case IIO_PROXIMITY:
+ *vals = apds9960_pxs_gain_map;
+ *length = ARRAY_SIZE(apds9960_pxs_gain_map);
+ break;
+ case IIO_INTENSITY:
+ *vals = apds9960_als_gain_map;
+ *length = ARRAY_SIZE(apds9960_als_gain_map);
+ break;
+ default:
+ return -EINVAL;
+ }
+ *type = IIO_VAL_INT;
+ return IIO_AVAIL_LIST;
+ case IIO_CHAN_INFO_INT_TIME:
+ *vals = apds9960_int_time_avail;
+ *type = IIO_VAL_INT_PLUS_MICRO;
+ *length = ARRAY_SIZE(apds9960_int_time_avail);
+ return IIO_AVAIL_LIST;
+ default:
+ return -EINVAL;
+ }
+}
+
static const struct iio_info apds9960_info = {
- .attrs = &apds9960_attribute_group,
+ .read_avail = apds9960_read_avail,
.read_raw = apds9960_read_raw,
.write_raw = apds9960_write_raw,
.read_event_value = apds9960_read_event,
--
2.56.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/6] iio: light: max44009: Report the integration time via read_avail()
2026-11-02 7:46 [PATCH 0/6] iio: Give the *_available attributes the names the core generates Arka Mondal
2026-11-02 7:46 ` [PATCH 1/6] iio: light: isl29125: Report the scale list via read_avail() Arka Mondal
2026-11-02 7:46 ` [PATCH 2/6] iio: light: apds9960: Report the available lists " Arka Mondal
@ 2026-11-02 7:46 ` Arka Mondal
2026-11-02 7:46 ` [PATCH 4/6] iio: light: max44000: Report the available lists " Arka Mondal
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Arka Mondal @ 2026-11-02 7:46 UTC (permalink / raw)
To: Jonathan Cameron, Linus Walleij
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Peter Meerwald, Matt Ranostay, Robert Eshleman,
Leonard Crestez, linux-iio, linux-kernel, Arka Mondal
The light channel has IIO_CHAN_INFO_INT_TIME in info_mask_separate,
so userspace reads the integration time from
in_illuminance_integration_time. The values it accepts are listed by
a custom attribute called illuminance_integration_time_available.
That name lacks the in_ prefix the core puts on the attribute it
describes, so it is registered at the device level, and userspace
looking for in_illuminance_integration_time_available finds nothing.
Report the list through read_avail() and drop the custom attribute
along with the string it printed. read_avail() wants the values as
IIO_VAL_INT_PLUS_NANO pairs, while max44009_write_int_time() rounds a
request to the nearest supported value with find_closest_descending()
over a flat table, so the two forms stay as separate tables.
The eight values do not change. The core prints them with nine
decimals, so the attribute now reads 0.800000000 down to 0.006250000
instead of 0.8 down to 0.00625.
Fixes: 6aef699a7d7e ("iio: light: add driver for MAX44009")
Signed-off-by: Arka Mondal <arka@arkamondal.net>
---
Notes:
Compile tested only; no relevant hardware available.
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..c27f0f9ecc44 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, 800000000,
+ 0, 400000000,
+ 0, 200000000,
+ 0, 100000000,
+ 0, 50000000,
+ 0, 25000000,
+ 0, 12500000,
+ 0, 6250000,
+};
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_NANO;
+ *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] 8+ messages in thread
* [PATCH 4/6] iio: light: max44000: Report the available lists via read_avail()
2026-11-02 7:46 [PATCH 0/6] iio: Give the *_available attributes the names the core generates Arka Mondal
` (2 preceding siblings ...)
2026-11-02 7:46 ` [PATCH 3/6] iio: light: max44009: Report the integration time " Arka Mondal
@ 2026-11-02 7:46 ` Arka Mondal
2026-11-02 7:46 ` [PATCH 5/6] iio: humidity: hdc100x: " Arka Mondal
2026-11-02 7:47 ` [PATCH 6/6] iio: gyro: mpu3050: Fix the scale list and report it " Arka Mondal
5 siblings, 0 replies; 8+ messages in thread
From: Arka Mondal @ 2026-11-02 7:46 UTC (permalink / raw)
To: Jonathan Cameron, Linus Walleij
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Peter Meerwald, Matt Ranostay, Robert Eshleman,
Leonard Crestez, linux-iio, linux-kernel, Arka Mondal
The light channel keeps IIO_CHAN_INFO_SCALE and IIO_CHAN_INFO_INT_TIME
in info_mask_shared_by_type, so userspace sees in_illuminance_scale
and in_illuminance_integration_time. Two custom attributes list the
values those accept, but they are named illuminance_scale_available and
illuminance_integration_time_available, without the in_ prefix the core
gives the attribute a list belongs to. Both land at the device level,
paired with nothing, so userspace that asks for either prefixed name
finds no such file.
Report both lists through read_avail() and delete the two attributes
along with the strings they printed.
Each list uses the format the write path accepts, which
max44000_write_raw_get_fmt() gives as IIO_VAL_INT_PLUS_MICRO for
scale and IIO_VAL_INT_PLUS_NANO for integration time. The scale
is read back as IIO_VAL_FRACTIONAL_LOG2, the same number written
another way. max44000_write_raw() still rounds a request against
the ulux table with find_closest() and against the ns table with
find_closest_descending(), so both tables stay and the lists are
separate arrays of value pairs.
No value changes, but the core prints each one to the full precision
of its format. The scale now reads 0.031250 0.125000 0.500000 4.000000
where it read 0.03125 0.125 0.5 4, and the integration time reads
0.100000000 0.025000000 0.006250000 0.001562500 where it read 0.100
0.025 0.00625 0.0015625.
Fixes: d5d8f49b6345 ("max44000: Expose ambient sensor scaling")
Signed-off-by: Arka Mondal <arka@arkamondal.net>
---
Notes:
Compile tested only; no relevant hardware available.
drivers/iio/light/max44000.c | 60 ++++++++++++++++++++++--------------
1 file changed, 37 insertions(+), 23 deletions(-)
diff --git a/drivers/iio/light/max44000.c b/drivers/iio/light/max44000.c
index 8c344f1b3fe2..9f9046e127c0 100644
--- a/drivers/iio/light/max44000.c
+++ b/drivers/iio/light/max44000.c
@@ -104,11 +104,20 @@ static const int max44000_int_time_avail_ns_array[] = {
6250000,
1562500,
};
-static const char max44000_int_time_avail_str[] =
- "0.100 "
- "0.025 "
- "0.00625 "
- "0.0015625";
+
+static const int max44000_int_time_avail[] = {
+ 0, 100000000,
+ 0, 25000000,
+ 0, 6250000,
+ 0, 1562500,
+};
+
+static const int max44000_scale_avail[] = {
+ 0, 31250,
+ 0, 125000,
+ 0, 500000,
+ 4, 0,
+};
/* Available scales (internal to ulux) with pretty manual alignment: */
static const int max44000_scale_avail_ulux_array[] = {
@@ -117,11 +126,6 @@ static const int max44000_scale_avail_ulux_array[] = {
500000,
4000000,
};
-static const char max44000_scale_avail_str[] =
- "0.03125 "
- "0.125 "
- "0.5 "
- "4";
#define MAX44000_SCAN_INDEX_ALS 0
#define MAX44000_SCAN_INDEX_PRX 1
@@ -132,6 +136,8 @@ static const struct iio_chan_spec max44000_channels[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_INT_TIME),
+ .info_mask_shared_by_type_available =
+ BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_INT_TIME),
.scan_index = MAX44000_SCAN_INDEX_ALS,
.scan_type = {
.sign = 'u',
@@ -383,24 +389,32 @@ static int max44000_write_raw_get_fmt(struct iio_dev *indio_dev,
return IIO_VAL_INT;
}
-static IIO_CONST_ATTR(illuminance_integration_time_available, max44000_int_time_avail_str);
-static IIO_CONST_ATTR(illuminance_scale_available, max44000_scale_avail_str);
-
-static struct attribute *max44000_attributes[] = {
- &iio_const_attr_illuminance_integration_time_available.dev_attr.attr,
- &iio_const_attr_illuminance_scale_available.dev_attr.attr,
- NULL
-};
-
-static const struct attribute_group max44000_attribute_group = {
- .attrs = max44000_attributes,
-};
+static int max44000_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 = max44000_scale_avail;
+ *type = IIO_VAL_INT_PLUS_MICRO;
+ *length = ARRAY_SIZE(max44000_scale_avail);
+ return IIO_AVAIL_LIST;
+ case IIO_CHAN_INFO_INT_TIME:
+ *vals = max44000_int_time_avail;
+ *type = IIO_VAL_INT_PLUS_NANO;
+ *length = ARRAY_SIZE(max44000_int_time_avail);
+ return IIO_AVAIL_LIST;
+ default:
+ return -EINVAL;
+ }
+}
static const struct iio_info max44000_info = {
.read_raw = max44000_read_raw,
.write_raw = max44000_write_raw,
.write_raw_get_fmt = max44000_write_raw_get_fmt,
- .attrs = &max44000_attribute_group,
+ .read_avail = max44000_read_avail,
};
static bool max44000_readable_reg(struct device *dev, unsigned int reg)
--
2.56.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 5/6] iio: humidity: hdc100x: Report the available lists via read_avail()
2026-11-02 7:46 [PATCH 0/6] iio: Give the *_available attributes the names the core generates Arka Mondal
` (3 preceding siblings ...)
2026-11-02 7:46 ` [PATCH 4/6] iio: light: max44000: Report the available lists " Arka Mondal
@ 2026-11-02 7:46 ` Arka Mondal
2026-11-02 7:47 ` [PATCH 6/6] iio: gyro: mpu3050: Fix the scale list and report it " Arka Mondal
5 siblings, 0 replies; 8+ messages in thread
From: Arka Mondal @ 2026-11-02 7:46 UTC (permalink / raw)
To: Jonathan Cameron, Linus Walleij
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Peter Meerwald, Matt Ranostay, Robert Eshleman,
Leonard Crestez, linux-iio, linux-kernel, Arka Mondal
The temperature and humidity channels have IIO_CHAN_INFO_INT_TIME in
info_mask_separate, so userspace sees in_temp_integration_time and
in_humidityrelative_integration_time. Two custom attributes list
the values they accept, named temp_integration_time_available and
humidityrelative_integration_time_available. Neither carries the in_
prefix of the attribute it describes, so both sit at the device level,
and userspace that opens either prefixed name finds no such file. A
third attribute, out_current_heater_raw_available, already has the right
name and keeps it.
Report all three through read_avail() and delete the attributes and the
group that held them.
The two time lists hold what hdc100x_set_it_time() accepts. Its loop
ignores a zero request, so the padding entry in the temperature row of
hdc100x_int_time cannot be selected, which is why the temperature list
has two entries and the humidity list three.
No value changes. The heater list still prints 0 1, and the core prints
the times to the six decimals of IIO_VAL_INT_PLUS_MICRO: temperature
reads 0.003650 0.006350 where it read 0.00365 0.00635, humidity 0.002500
0.003850 0.006500 where it read 0.0025 0.00385 0.0065.
Fixes: 4839367d99e3 ("iio: humidity: add HDC100x support")
Signed-off-by: Arka Mondal <arka@arkamondal.net>
---
Notes:
Compile tested only; no relevant hardware available.
drivers/iio/humidity/hdc100x.c | 61 ++++++++++++++++++++++++----------
1 file changed, 44 insertions(+), 17 deletions(-)
diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
index bc452cc8fbcf..e2780e436655 100644
--- a/drivers/iio/humidity/hdc100x.c
+++ b/drivers/iio/humidity/hdc100x.c
@@ -69,26 +69,19 @@ static const struct {
},
};
-static IIO_CONST_ATTR(temp_integration_time_available,
- "0.00365 0.00635");
-
-static IIO_CONST_ATTR(humidityrelative_integration_time_available,
- "0.0025 0.00385 0.0065");
-
-static IIO_CONST_ATTR(out_current_heater_raw_available,
- "0 1");
-
-static struct attribute *hdc100x_attributes[] = {
- &iio_const_attr_temp_integration_time_available.dev_attr.attr,
- &iio_const_attr_humidityrelative_integration_time_available.dev_attr.attr,
- &iio_const_attr_out_current_heater_raw_available.dev_attr.attr,
- NULL
+static const int hdc100x_temp_int_time_avail[] = {
+ 0, 3650,
+ 0, 6350,
};
-static const struct attribute_group hdc100x_attribute_group = {
- .attrs = hdc100x_attributes,
+static const int hdc100x_humidity_int_time_avail[] = {
+ 0, 2500,
+ 0, 3850,
+ 0, 6500,
};
+static const int hdc100x_heater_avail[] = { 0, 1 };
+
static const struct iio_chan_spec hdc100x_channels[] = {
{
.type = IIO_TEMP,
@@ -97,6 +90,7 @@ static const struct iio_chan_spec hdc100x_channels[] = {
BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_INT_TIME) |
BIT(IIO_CHAN_INFO_OFFSET),
+ .info_mask_separate_available = BIT(IIO_CHAN_INFO_INT_TIME),
.scan_index = 0,
.scan_type = {
.sign = 's',
@@ -111,6 +105,7 @@ static const struct iio_chan_spec hdc100x_channels[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_INT_TIME),
+ .info_mask_separate_available = BIT(IIO_CHAN_INFO_INT_TIME),
.scan_index = 1,
.scan_type = {
.sign = 'u',
@@ -122,6 +117,7 @@ static const struct iio_chan_spec hdc100x_channels[] = {
{
.type = IIO_CURRENT,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .info_mask_separate_available = BIT(IIO_CHAN_INFO_RAW),
.extend_name = "heater",
.output = 1,
.scan_index = -1,
@@ -328,10 +324,41 @@ static irqreturn_t hdc100x_trigger_handler(int irq, void *p)
return IRQ_HANDLED;
}
+static int hdc100x_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:
+ switch (chan->type) {
+ case IIO_TEMP:
+ *vals = hdc100x_temp_int_time_avail;
+ *length = ARRAY_SIZE(hdc100x_temp_int_time_avail);
+ break;
+ case IIO_HUMIDITYRELATIVE:
+ *vals = hdc100x_humidity_int_time_avail;
+ *length = ARRAY_SIZE(hdc100x_humidity_int_time_avail);
+ break;
+ default:
+ return -EINVAL;
+ }
+ *type = IIO_VAL_INT_PLUS_MICRO;
+ return IIO_AVAIL_LIST;
+ case IIO_CHAN_INFO_RAW:
+ *vals = hdc100x_heater_avail;
+ *type = IIO_VAL_INT;
+ *length = ARRAY_SIZE(hdc100x_heater_avail);
+ return IIO_AVAIL_LIST;
+ default:
+ return -EINVAL;
+ }
+}
+
static const struct iio_info hdc100x_info = {
.read_raw = hdc100x_read_raw,
.write_raw = hdc100x_write_raw,
- .attrs = &hdc100x_attribute_group,
+ .read_avail = hdc100x_read_avail,
};
static int hdc100x_probe(struct i2c_client *client)
--
2.56.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 6/6] iio: gyro: mpu3050: Fix the scale list and report it via read_avail()
2026-11-02 7:46 [PATCH 0/6] iio: Give the *_available attributes the names the core generates Arka Mondal
` (4 preceding siblings ...)
2026-11-02 7:46 ` [PATCH 5/6] iio: humidity: hdc100x: " Arka Mondal
@ 2026-11-02 7:47 ` Arka Mondal
5 siblings, 0 replies; 8+ messages in thread
From: Arka Mondal @ 2026-11-02 7:47 UTC (permalink / raw)
To: Jonathan Cameron, Linus Walleij
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Peter Meerwald, Matt Ranostay, Robert Eshleman,
Leonard Crestez, linux-iio, linux-kernel, Arka Mondal
The angular velocity channels keep IIO_CHAN_INFO_SCALE in
info_mask_shared_by_type, so userspace reads the scale from
in_anglvel_scale. One custom attribute lists the values it can take,
and that list is wrong in both its numbers and its name.
The four numbers were computed against 2^16 while mpu3050_read_raw()
divides by U16_MAX, so not one of them is a value the channel ever
reports. The list gives 0.000122070, 0.000274658, 0.000518798 and
0.001068115, where the channel reports 0.000122072, 0.000274662,
0.000518806 and 0.001068131.
The name, anglevel_scale_available, has neither the in_ prefix nor
the anglvel spelling the core uses for IIO_ANGL_VEL, so it sits at the
device level and userspace that opens in_anglvel_scale_available finds
no such file.
Report the list through read_avail(), built from the same
IIO_DEGREE_TO_RAD() terms and U16_MAX that mpu3050_read_raw() uses so
the two cannot drift apart again, and delete the attribute along with
the comment describing the hardcoded factors.
Fixes: 3904b28efb2c ("iio: gyro: Add driver for the MPU-3050 gyroscope")
Signed-off-by: Arka Mondal <arka@arkamondal.net>
---
Notes:
Compile tested only; no relevant hardware available.
drivers/iio/gyro/mpu3050-core.c | 40 +++++++++++++++++++--------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
index 07c0f9011c63..0dfb5e6039fb 100644
--- a/drivers/iio/gyro/mpu3050-core.c
+++ b/drivers/iio/gyro/mpu3050-core.c
@@ -701,6 +701,8 @@ static const struct iio_chan_spec_ext_info mpu3050_ext_info[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
BIT(IIO_CHAN_INFO_CALIBBIAS), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
+ .info_mask_shared_by_type_available = \
+ BIT(IIO_CHAN_INFO_SCALE), \
.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\
.ext_info = mpu3050_ext_info, \
.scan_index = index, \
@@ -736,29 +738,33 @@ static const struct iio_chan_spec mpu3050_channels[] = {
/* Four channels apart from timestamp, scan mask = 0x0f */
static const unsigned long mpu3050_scan_masks[] = { 0xf, 0 };
-/*
- * These are just the hardcoded factors resulting from the more elaborate
- * calculations done with fractions in the scale raw get/set functions.
- */
-static IIO_CONST_ATTR(anglevel_scale_available,
- "0.000122070 "
- "0.000274658 "
- "0.000518798 "
- "0.001068115");
-
-static struct attribute *mpu3050_attributes[] = {
- &iio_const_attr_anglevel_scale_available.dev_attr.attr,
- NULL,
+static const int mpu3050_scale_avail[] = {
+ IIO_DEGREE_TO_RAD(250) * 2, U16_MAX,
+ IIO_DEGREE_TO_RAD(500) * 2, U16_MAX,
+ IIO_DEGREE_TO_RAD(1000) * 2, U16_MAX,
+ IIO_DEGREE_TO_RAD(2000) * 2, U16_MAX,
};
-static const struct attribute_group mpu3050_attribute_group = {
- .attrs = mpu3050_attributes,
-};
+static int mpu3050_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 = mpu3050_scale_avail;
+ *type = IIO_VAL_FRACTIONAL;
+ *length = ARRAY_SIZE(mpu3050_scale_avail);
+ return IIO_AVAIL_LIST;
+ default:
+ return -EINVAL;
+ }
+}
static const struct iio_info mpu3050_info = {
.read_raw = mpu3050_read_raw,
.write_raw = mpu3050_write_raw,
- .attrs = &mpu3050_attribute_group,
+ .read_avail = mpu3050_read_avail,
};
/**
--
2.56.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/6] iio: light: isl29125: Report the scale list via read_avail()
2026-11-02 7:46 ` [PATCH 1/6] iio: light: isl29125: Report the scale list via read_avail() Arka Mondal
@ 2026-11-02 22:26 ` Jonathan Cameron
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2026-11-02 22:26 UTC (permalink / raw)
To: Arka Mondal
Cc: Linus Walleij, David Lechner, Nuno Sá,
Andy Shevchenko, Peter Meerwald, Matt Ranostay, Robert Eshleman,
Leonard Crestez, linux-iio, linux-kernel
On Mon, 2 Nov 2026 16:46:55 +0900
Arka Mondal <arka@arkamondal.net> wrote:
> 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.
Hi Arka
Not quite true. The core would have done as you said if it was set in the
iio_info_mask_shared_by_type.
Now if it were in iio_info_mask_shared_by_all it would be called
scale_available and hence match the existing ABI.
The device presents 4 channels and arguably this one only applies
to 3 of them as it doesn't apply to the timestamp.
For that reason we generally only use the share_by_all mask for
things like sampling_frequency.
However, whilst less than ideal the change you are proposing here
is a userspace ABI change and it's a bit arguable whether the current
ABI is buggy or not. So in general I'd leave this one alone,
or as a simple cleanup rather than a fix, move it to the read_avail
callback and the mask that does generate the same ABI.
Other than that patch looks good.
Thanks,
Jonathan
>
> 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@arkamondal.net>
> static int isl29125_buffer_postenable(struct iio_dev *indio_dev)
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-02 22:26 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02 7:46 [PATCH 0/6] iio: Give the *_available attributes the names the core generates Arka Mondal
2026-11-02 7:46 ` [PATCH 1/6] iio: light: isl29125: Report the scale list via read_avail() Arka Mondal
2026-11-02 22:26 ` Jonathan Cameron
2026-11-02 7:46 ` [PATCH 2/6] iio: light: apds9960: Report the available lists " Arka Mondal
2026-11-02 7:46 ` [PATCH 3/6] iio: light: max44009: Report the integration time " Arka Mondal
2026-11-02 7:46 ` [PATCH 4/6] iio: light: max44000: Report the available lists " Arka Mondal
2026-11-02 7:46 ` [PATCH 5/6] iio: humidity: hdc100x: " Arka Mondal
2026-11-02 7:47 ` [PATCH 6/6] iio: gyro: mpu3050: Fix the scale list and report it " Arka Mondal
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®