iio: core: Use datasheet name as fallback for label
PATCH 1/1 iio: core: Use datasheet name as fallback for label
Some IIO drivers do not provide labels or extended names for their channels. However they may provide datasheet names. axp20x-adc is one such example.
Use the datasheet name as a fallback for the channel label. This mainly benefits iio-hwmon by letting the produced hwmon sensors have more meaningful names rather than in_voltageX.
--- drivers/iio/industrialio-core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/industrialio-core.c +3 -0
@@ -749,6 +749,9 @@ ssize_t do_iio_read_channel_label(struct iio_dev *indio_dev,if (c->extend_name)return sysfs_emit (buf,"%s\n" , c->extend_name); +if (c->datasheet_name) +return sysfs_emit (buf,"%s\n" , c->datasheet_name); +return -EINVAL ; }
Signature · 1 line
2.47.3
Jonathan Cameron
maintainerQuoted 7 lines · On Mon, 27 Oct 2025 20:42:09 +0800 Chen-Yu Tsai <[email protected]> wrote:
Some IIO drivers do not provide labels or extended names for their channels. However they may provide datasheet names. axp20x-adc is one such example.
Use the datasheet name as a fallback for the channel label. This mainly benefits iio-hwmon by letting the produced hwmon sensors have more meaningful names rather than
in_voltageX.
I definitely don't want to have different behaviour for in kernel requests and for people reading the _label attributes.
https://elixir.bootlin.com/linux/v6.18-rc2/source/drivers/iio/industrialio-core.c#L1232
would need modifying to allow for the sysfs attributes to be created.
In general I'm not sure I want to do this. Datasheet names can be exceptionally obscure which is why we've kept them hidden from userspace. At least dts writers tend to have those names on their circuit diagrams and tend to have datasheet access.
Let's see if anyone else has feedback on this suggestion over next week or so.
Thanks,
Jonathan
Quoted 20 lines
Signed-off-by Chen-Yu Tsai <[email protected]>--- drivers/iio/industrialio-core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/iio/industrialio-core.c +3
-0@@ -749,6 +749,9 @@ ssize_t do_iio_read_channel_label(struct iio_dev *indio_dev,if (c->extend_name)return sysfs_emit (buf,"%s\n" , c->extend_name); +if (c->datasheet_name) +return sysfs_emit (buf,"%s\n" , c->datasheet_name); +return -EINVAL ; }
Quoted 16 lines · Jonathan Cameron
Quoted 7 lines · On Mon, 27 Oct 2025 20:42:09 +0800 Chen-Yu Tsai <[email protected]> wrote:
Some IIO drivers do not provide labels or extended names for their channels. However they may provide datasheet names. axp20x-adc is one such example.
Use the datasheet name as a fallback for the channel label. This mainly benefits iio-hwmon by letting the produced hwmon sensors have more meaningful names rather than
in_voltageX.I definitely don't want to have different behaviour for in kernel requests and for people reading the
_labelattributes.
https://elixir.bootlin.com/linux/v6.18-rc2/source/drivers/iio/industrialio-core.c#L1232
would need modifying to allow for the sysfs attributes to be created.
Quoted 5 lines
In general I'm not sure I want to do this. Datasheet names can be exceptionally obscure which is why we've kept them hidden from userspace. At least dts writers tend to have those names on their circuit diagrams and tend to have datasheet access.
Let's see if anyone else has feedback on this suggestion over next week or so.
This is an ABI change without
1) proper documentation;
2) backward compatibility (i.e. there is no knob to opt-out the change, or make it opt-in).
In this form is definitely NAK.
If you wish something like this, better to have a separate attribute. But the problem maybe also that the same component (or 100% compatible one) made by different vendors and have different datasheet names. This means that the new attribute may still be ambiguous. Hence I see a little sense to have it, rather better to have these links / names to be put in DT schema. At least there we have different vendors and compatibility mappings.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 24 lines · Andy Shevchenko
Quoted 23 lines · Jonathan Cameron
Quoted 7 lines · On Mon, 27 Oct 2025 20:42:09 +0800 Chen-Yu Tsai <[email protected]> wrote:
Some IIO drivers do not provide labels or extended names for their channels. However they may provide datasheet names. axp20x-adc is one such example.
Use the datasheet name as a fallback for the channel label. This mainly benefits iio-hwmon by letting the produced hwmon sensors have more meaningful names rather than
in_voltageX.I definitely don't want to have different behaviour for in kernel requests and for people reading the
_labelattributes.
https://elixir.bootlin.com/linux/v6.18-rc2/source/drivers/iio/industrialio-core.c#L1232
would need modifying to allow for the sysfs attributes to be created.In general I'm not sure I want to do this. Datasheet names can be exceptionally
obscure which is why we've kept them hidden from userspace. At least dts writers
tend to have those names on their circuit diagrams and tend to have datasheet access.
Quoted 4 lines
Quoted 2 lines
Let's see if anyone else has feedback on this suggestion over next week or so.
This is an ABI change without
Indeed...
Quoted 7 lines
1) proper documentation;
2) backward compatibility (i.e. there is no knob to opt-out the change, or make
it opt-in).In this form is definitely NAK.
Quoted 7 lines
If you wish something like this, better to have a separate attribute. But the problem maybe also that the same component (or 100% compatible one) made by different vendors and have different datasheet names. This means that the new attribute may still be ambiguous. Hence I see a little sense to have it, rather
better to have these links / names to be put in DT schema. At least there we have different vendors and compatibility mappings.
I mean, we already have labels for channels so this all looks like a bit of overlap to me (though I see the temptation of going this way). For extended_names, there was a reason why it came as a fallback for .label() [1]. For this, I'm not really convinced for now. There is also at least one driver already exporting the .datasheet_name as a label [2] so maybe we should do that instead (again, I understand that doing it like this we only need to change one place...)? Otherwise we should clean up those and that should definitely be part of the series (if we even consider this).
[1]: https://lore.kernel.org/linux-iio/[email protected]/
[2]: https://elixir.bootlin.com/linux/v6.18-rc2/source/drivers/iio/adc/xilinx-ams.c#L539
- Nuno Sá
Quoted 48 lines · Nuno Sá
Quoted 24 lines · Andy Shevchenko
Quoted 23 lines · Jonathan Cameron
Quoted 7 lines · On Mon, 27 Oct 2025 20:42:09 +0800 Chen-Yu Tsai <[email protected]> wrote:
Some IIO drivers do not provide labels or extended names for their channels. However they may provide datasheet names. axp20x-adc is one such example.
Use the datasheet name as a fallback for the channel label. This mainly benefits iio-hwmon by letting the produced hwmon sensors have more meaningful names rather than
in_voltageX.I definitely don't want to have different behaviour for in kernel requests and for people reading the
_labelattributes.
https://elixir.bootlin.com/linux/v6.18-rc2/source/drivers/iio/industrialio-core.c#L1232
would need modifying to allow for the sysfs attributes to be created.In general I'm not sure I want to do this. Datasheet names can be exceptionally
obscure which is why we've kept them hidden from userspace. At least dts writers
tend to have those names on their circuit diagrams and tend to have datasheet access.Quoted 4 lines
Quoted 2 lines
Let's see if anyone else has feedback on this suggestion over next week or so.
This is an ABI change without
Indeed...
Quoted 7 lines
1) proper documentation;
2) backward compatibility (i.e. there is no knob to opt-out the change, or make
it opt-in).In this form is definitely NAK.
Quoted 7 lines
If you wish something like this, better to have a separate attribute. But the problem maybe also that the same component (or 100% compatible one) made by different vendors and have different datasheet names. This means that the new attribute may still be ambiguous. Hence I see a little sense to have it, rather
better to have these links / names to be put in DT schema. At least there we have different vendors and compatibility mappings.
Quoted 8 lines
I mean, we already have labels for channels so this all looks like a bit of overlap to me (though I see the temptation of going this way). For
extended_names, there was a reason why it came as a fallback for .label() [1]. For this, I'm not really convinced for now. There is also at least one driver already exporting the .datasheet_name as a label [2] so maybe we should do that instead (again, I understand that doing it like this we only need to change one place...)? Otherwise we should clean up those and that should definitely be part of the series (if we even consider this).
Thanks for the pointers. In my case I think either solution works.
The axp20x-adc driver currently provides _no_ labels. Would adding labels now be considered backward incompatible?
Thanks
ChenYu
Quoted 1 line · Chen-Yu Tsai
On Tue, Oct 28, 2025 at 5:22 PM Nuno Sá <[email protected]> wrote:
...
Quoted 2 lines
The axp20x-adc driver currently provides _no_ labels. Would adding labels now be considered backward incompatible?
It can be considered forward-incompatible :-)
This kind of discussions happen in IIO in the past and probably still will in the future. Namely "What should be unique (enough?) string to recognise chip (platform?)?"
So, you see, we need to answer first "What do we want to recognise? The platform or the chip?" Then decide what uniquiness will be enough.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 71 lines · Chen-Yu Tsai
Quoted 56 lines · Nuno Sá
Quoted 27 lines · Andy Shevchenko
Quoted 26 lines · Jonathan Cameron
Quoted 8 lines · On Mon, 27 Oct 2025 20:42:09 +0800 Chen-Yu Tsai <[email protected]> wrote:
Some IIO drivers do not provide labels or extended names for their channels. However they may provide datasheet names. axp20x-adc is one such example.
Use the datasheet name as a fallback for the channel label. This mainly
benefits iio-hwmon by letting the produced hwmon sensors have more meaningful names rather thanin_voltageX.I definitely don't want to have different behaviour for in kernel requests
and for people reading the_labelattributes.
https://elixir.bootlin.com/linux/v6.18-rc2/source/drivers/iio/industrialio-core.c#L1232
would need modifying to allow for the sysfs attributes to be created.In general I'm not sure I want to do this. Datasheet names can be exceptionally
obscure which is why we've kept them hidden from userspace. At least dts
writers
tend to have those names on their circuit diagrams and tend to have datasheet access.Quoted 5 lines
Quoted 3 lines
Let's see if anyone else has feedback on this suggestion over next week or
so.This is an ABI change without
Indeed...
Quoted 7 lines
1) proper documentation;
2) backward compatibility (i.e. there is no knob to opt-out the change, or make
it opt-in).In this form is definitely NAK.
Quoted 11 lines
If you wish something like this, better to have a separate attribute. But the
problem maybe also that the same component (or 100% compatible one) made by
different vendors and have different datasheet names. This means that the new
attribute may still be ambiguous. Hence I see a little sense to have it, rather
better to have these links / names to be put in DT schema. At least there we
have different vendors and compatibility mappings.Quoted 13 lines
I mean, we already have labels for channels so this all looks like a bit of overlap to me (though I see the temptation of going this way). For
extended_names, there was a reason why it came as a fallback for .label() [1].
For this, I'm not really convinced for now. There is also at least one driver
already exporting the .datasheet_name as a label [2] so maybe we should do that
instead (again, I understand that doing it like this we only need to change one
place...)? Otherwise we should clean up those and that should definitely be part
of the series (if we even consider this).
Quoted 5 lines
Thanks for the pointers. In my case I think either solution works.
The axp20x-adc driver currently provides _no_ labels. Would adding labels now be considered backward incompatible?
Jonathan should know better but I'm not seeing any reason why you could not add .label support for axp20x-adc (exporting the .datasheet_name for the channels) instead of the current patch.
- Nuno Sá
Jonathan Cameron
maintainerQuoted 74 lines · On Tue, 28 Oct 2025 15:17:24 +0000 Nuno Sá <[email protected]> wrote:
Quoted 73 lines · Chen-Yu Tsai
Quoted 56 lines · Nuno Sá
Quoted 27 lines · Andy Shevchenko
Quoted 26 lines · Jonathan Cameron
Quoted 8 lines · On Mon, 27 Oct 2025 20:42:09 +0800 Chen-Yu Tsai <[email protected]> wrote:
Some IIO drivers do not provide labels or extended names for their channels. However they may provide datasheet names. axp20x-adc is one such example.
Use the datasheet name as a fallback for the channel label. This mainly
benefits iio-hwmon by letting the produced hwmon sensors have more meaningful names rather thanin_voltageX.I definitely don't want to have different behaviour for in kernel requests
and for people reading the_labelattributes.
https://elixir.bootlin.com/linux/v6.18-rc2/source/drivers/iio/industrialio-core.c#L1232
would need modifying to allow for the sysfs attributes to be created.In general I'm not sure I want to do this. Datasheet names can be exceptionally
obscure which is why we've kept them hidden from userspace. At least dts
writers
tend to have those names on their circuit diagrams and tend to have datasheet access.Quoted 5 lines
Quoted 3 lines
Let's see if anyone else has feedback on this suggestion over next week or
so.This is an ABI change without
Indeed...
Quoted 7 lines
1) proper documentation;
2) backward compatibility (i.e. there is no knob to opt-out the change, or make
it opt-in).In this form is definitely NAK.
Quoted 11 lines
If you wish something like this, better to have a separate attribute. But the
problem maybe also that the same component (or 100% compatible one) made by
different vendors and have different datasheet names. This means that the new
attribute may still be ambiguous. Hence I see a little sense to have it, rather
better to have these links / names to be put in DT schema. At least there we
have different vendors and compatibility mappings.Quoted 13 lines
I mean, we already have labels for channels so this all looks like a bit of overlap to me (though I see the temptation of going this way). For
extended_names, there was a reason why it came as a fallback for .label() [1].
For this, I'm not really convinced for now. There is also at least one driver
already exporting the .datasheet_name as a label [2] so maybe we should do that
instead (again, I understand that doing it like this we only need to change one
place...)? Otherwise we should clean up those and that should definitely be part
of the series (if we even consider this).Thanks for the pointers. In my case I think either solution works.
Quoted 7 lines
Quoted 3 lines
The axp20x-adc driver currently provides _no_ labels. Would adding labels now be considered backward incompatible?
Jonathan should know better but I'm not seeing any reason why you could not add .label support for axp20x-adc (exporting the .datasheet_name for the channels) instead of the current patch.
I'd prefer a per driver version of this as then the author can look for the sorts of issues Andy raised. Basically it boils down to are the datasheet names convenient and human readable names that it makes sense to reuse for a particular set of devices (if no label in DT is provided)?
So basically side step the insane by doing it where we can evaluate that the names meet this criteria.
Jonathan
Quoted 3 lines
- Nuno Sá