[PATCH 1/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels

Antony Kurniawan Soemardi posted 2 patches 3 months, 2 weeks ago
[PATCH 1/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels
Posted by Antony Kurniawan Soemardi 3 months, 2 weeks ago
This allows user-space tools to identify ADC channels by name through
the IIO sysfs interface.

Signed-off-by: Antony Kurniawan Soemardi <linux@smankusors.com>
---
 drivers/iio/adc/qcom-pm8xxx-xoadc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
index 31f88cf7f7f18297132d152648b312c0fb60608e..8555f34036fb13c41ac720dc02c1dc39876e9198 100644
--- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c
+++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
@@ -725,8 +725,15 @@ static int pm8xxx_fwnode_xlate(struct iio_dev *indio_dev,
 	return -EINVAL;
 }
 
+static int pm8xxx_read_label(struct iio_dev *indio_dev,
+			     struct iio_chan_spec const *chan, char *label)
+{
+	return sysfs_emit(label, "%s\n", chan->datasheet_name);
+}
+
 static const struct iio_info pm8xxx_xoadc_info = {
 	.fwnode_xlate = pm8xxx_fwnode_xlate,
+	.read_label = pm8xxx_read_label,
 	.read_raw = pm8xxx_read_raw,
 };
 

-- 
2.34.1
Re: [PATCH 1/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels
Posted by Andy Shevchenko 3 months, 2 weeks ago
On Mon, Oct 27, 2025 at 05:29:16PM +0000, Antony Kurniawan Soemardi wrote:
> This allows user-space tools to identify ADC channels by name through
> the IIO sysfs interface.

...

> +static int pm8xxx_read_label(struct iio_dev *indio_dev,
> +			     struct iio_chan_spec const *chan, char *label)
> +{
> +	return sysfs_emit(label, "%s\n", chan->datasheet_name);
> +}

Hmm... In another thread there is a discussion on label vs. datasheet_name.
So, why datasheet name and not something that it's more reliable as a platform
description? As far as I understand there many mysterious ways of HW
engineering and how to connect available pins to something interesting. Even
datasheet names may be quite mislead on a certain platform (due to above).
I would expect this to come from DT or another platform description and user
space should rely on the information from _there_.

-- 
With Best Regards,
Andy Shevchenko