* [PATCH 0/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels from DT @ 2026-03-25 21:02 Antony Kurniawan Soemardi 2026-03-25 21:02 ` [PATCH 1/2] ARM: dts: qcom: pm8921: add labels for ADC channels Antony Kurniawan Soemardi 2026-03-25 21:02 ` [PATCH 2/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels Antony Kurniawan Soemardi 0 siblings, 2 replies; 9+ messages in thread From: Antony Kurniawan Soemardi @ 2026-03-25 21:02 UTC (permalink / raw) To: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko Cc: linux-arm-msm, devicetree, linux-kernel, linux-iio, phone-devel, Antony Kurniawan Soemardi This series adds support for reading channel labels from the device tree in the the Qualcomm PM8xxx XOADC driver, along with the corresponding DT updates for the PM8921 PMIC. Tested on Sony Xperia SP (PM8921): > cat /sys/bus/iio/devices/iio\:device0/in_voltage7_label usb_vbus > cat /sys/bus/iio/devices/iio\:device0/in_temp12_label ref_muxoff This patch was originally part of the larger series addressing the said driver improvements. As the calibration fixes are not yet ready, the label support is split out to allow independent review and merging. Changes since original patch: - The label is now read from the platform description (device tree) instead of the internal datasheet name. - Link to original patch: https://lore.kernel.org/all/20251028-pm8xxx-xoadc-fix-v1-1-b000e1036e41@smankusors.com/ Signed-off-by: Antony Kurniawan Soemardi <linux@smankusors.com> --- Antony Kurniawan Soemardi (2): ARM: dts: qcom: pm8921: add labels for ADC channels iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels arch/arm/boot/dts/qcom/pm8921.dtsi | 12 ++++++++++++ drivers/iio/adc/qcom-pm8xxx-xoadc.c | 26 +++++++++++++++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) --- base-commit: c612261bedd6bbab7109f798715e449c9d20ff2f change-id: 20260321-pm8xxx-xoadc-label-47afdf7f06a9 Best regards, -- Antony Kurniawan Soemardi <linux@smankusors.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] ARM: dts: qcom: pm8921: add labels for ADC channels 2026-03-25 21:02 [PATCH 0/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels from DT Antony Kurniawan Soemardi @ 2026-03-25 21:02 ` Antony Kurniawan Soemardi 2026-03-26 11:01 ` Konrad Dybcio 2026-03-25 21:02 ` [PATCH 2/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels Antony Kurniawan Soemardi 1 sibling, 1 reply; 9+ messages in thread From: Antony Kurniawan Soemardi @ 2026-03-25 21:02 UTC (permalink / raw) To: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko Cc: linux-arm-msm, devicetree, linux-kernel, linux-iio, phone-devel, Antony Kurniawan Soemardi Add label properties to all XOADC ADC channel nodes in the PM8921 PMIC device tree. This allows userspace and drivers to identify channels by name rather than relying on datasheet name. Signed-off-by: Antony Kurniawan Soemardi <linux@smankusors.com> --- arch/arm/boot/dts/qcom/pm8921.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm/boot/dts/qcom/pm8921.dtsi b/arch/arm/boot/dts/qcom/pm8921.dtsi index 535cb6a2543f69bc30abc89bff4e14a19147ce38..15246f4bd2672ccd4fc3359b66541d53d4da88b4 100644 --- a/arch/arm/boot/dts/qcom/pm8921.dtsi +++ b/arch/arm/boot/dts/qcom/pm8921.dtsi @@ -75,50 +75,62 @@ pm8921_xoadc: xoadc@197 { vcoin: adc-channel@0 { reg = <0x00 0x00>; + label = "vcoin"; }; vbat: adc-channel@1 { reg = <0x00 0x01>; + label = "vbat"; }; dcin: adc-channel@2 { reg = <0x00 0x02>; + label = "dcin"; }; vph_pwr: adc-channel@4 { reg = <0x00 0x04>; + label = "vph_pwr"; }; batt_therm: adc-channel@8 { reg = <0x00 0x08>; + label = "batt_therm"; }; batt_id: adc-channel@9 { reg = <0x00 0x09>; + label = "batt_id"; }; usb_vbus: adc-channel@a { reg = <0x00 0x0a>; + label = "usb_vbus"; }; die_temp: adc-channel@b { reg = <0x00 0x0b>; + label = "die_temp"; }; ref_625mv: adc-channel@c { reg = <0x00 0x0c>; + label = "ref_625mv"; }; ref_1250mv: adc-channel@d { reg = <0x00 0x0d>; + label = "ref_1250mv"; }; chg_temp: adc-channel@e { reg = <0x00 0x0e>; + label = "chg_temp"; }; ref_muxoff: adc-channel@f { reg = <0x00 0x0f>; + label = "ref_muxoff"; }; }; }; -- 2.34.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] ARM: dts: qcom: pm8921: add labels for ADC channels 2026-03-25 21:02 ` [PATCH 1/2] ARM: dts: qcom: pm8921: add labels for ADC channels Antony Kurniawan Soemardi @ 2026-03-26 11:01 ` Konrad Dybcio 0 siblings, 0 replies; 9+ messages in thread From: Konrad Dybcio @ 2026-03-26 11:01 UTC (permalink / raw) To: Antony Kurniawan Soemardi, Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko Cc: linux-arm-msm, devicetree, linux-kernel, linux-iio, phone-devel On 3/25/26 10:02 PM, Antony Kurniawan Soemardi wrote: > Add label properties to all XOADC ADC channel nodes in the PM8921 PMIC > device tree. This allows userspace and drivers to identify channels by > name rather than relying on datasheet name. > > Signed-off-by: Antony Kurniawan Soemardi <linux@smankusors.com> > --- I can't find a reference but these look reasonable Acked-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Konrad ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels 2026-03-25 21:02 [PATCH 0/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels from DT Antony Kurniawan Soemardi 2026-03-25 21:02 ` [PATCH 1/2] ARM: dts: qcom: pm8921: add labels for ADC channels Antony Kurniawan Soemardi @ 2026-03-25 21:02 ` Antony Kurniawan Soemardi 2026-03-26 10:18 ` Andy Shevchenko 1 sibling, 1 reply; 9+ messages in thread From: Antony Kurniawan Soemardi @ 2026-03-25 21:02 UTC (permalink / raw) To: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko Cc: linux-arm-msm, devicetree, linux-kernel, linux-iio, phone-devel, Antony Kurniawan Soemardi Implement the .read_label callback to allow userspace to identify ADC channels via the "label" property in the device tree. The name field in pm8xxx_chan_info is renamed to label to better reflect its purpose. If no label is provided in the device tree, it defaults to the hardware datasheet name. Tested-on: Sony Xperia SP (PM8921) Signed-off-by: Antony Kurniawan Soemardi <linux@smankusors.com> --- drivers/iio/adc/qcom-pm8xxx-xoadc.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c index 31f88cf7f7f18297132d152648b312c0fb60608e..206a379ea74113264d4e5e75a81f838204174700 100644 --- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c +++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c @@ -369,7 +369,7 @@ static const struct xoadc_channel pm8921_xoadc_channels[] = { /** * struct pm8xxx_chan_info - ADC channel information - * @name: name of this channel + * @label: label of this channel from device tree (defaults to datasheet name if not specified) * @hwchan: pointer to hardware channel information (muxing & scaling settings) * @calibration: whether to use absolute or ratiometric calibration * @decimation: 0,1,2,3 @@ -377,7 +377,7 @@ static const struct xoadc_channel pm8921_xoadc_channels[] = { * calibration: 0, 1, 2, 4, 5. */ struct pm8xxx_chan_info { - const char *name; + const char *label; const struct xoadc_channel *hwchan; enum vadc_calibration calibration; u8 decimation:2; @@ -446,7 +446,7 @@ static int pm8xxx_read_channel_rsv(struct pm8xxx_xoadc *adc, u8 lsb, msb; dev_dbg(adc->dev, "read channel \"%s\", amux %d, prescale/mux: %d, rsv %d\n", - ch->name, ch->hwchan->amux_channel, ch->hwchan->pre_scale_mux, rsv); + ch->label, ch->hwchan->amux_channel, ch->hwchan->pre_scale_mux, rsv); mutex_lock(&adc->lock); @@ -725,8 +725,22 @@ 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) +{ + struct pm8xxx_xoadc *adc = iio_priv(indio_dev); + struct pm8xxx_chan_info *ch = pm8xxx_get_channel(adc, chan->address); + + if (!ch) { + dev_err(adc->dev, "no such channel %lu\n", chan->address); + return -EINVAL; + } + return sysfs_emit(label, "%s\n", ch->label); +} + static const struct iio_info pm8xxx_xoadc_info = { .fwnode_xlate = pm8xxx_fwnode_xlate, + .read_label = pm8xxx_read_label, .read_raw = pm8xxx_read_raw, }; @@ -770,7 +784,9 @@ static int pm8xxx_xoadc_parse_channel(struct device *dev, pre_scale_mux, amux_channel); return -EINVAL; } - ch->name = name; + ret = fwnode_property_read_string(fwnode, "label", &ch->label); + if (ret) + ch->label = hwchan->datasheet_name; ch->hwchan = hwchan; /* Everyone seems to use absolute calibration except in special cases */ ch->calibration = VADC_CALIB_ABSOLUTE; @@ -812,7 +828,7 @@ static int pm8xxx_xoadc_parse_channel(struct device *dev, dev_dbg(dev, "channel [PRESCALE/MUX: %02x AMUX: %02x] \"%s\" ref voltage: %d, decimation %d prescale %d/%d, scale function %d\n", - hwchan->pre_scale_mux, hwchan->amux_channel, ch->name, + hwchan->pre_scale_mux, hwchan->amux_channel, ch->label, ch->amux_ip_rsv, ch->decimation, hwchan->prescale.numerator, hwchan->prescale.denominator, hwchan->scale_fn_type); -- 2.34.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels 2026-03-25 21:02 ` [PATCH 2/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels Antony Kurniawan Soemardi @ 2026-03-26 10:18 ` Andy Shevchenko 2026-03-26 12:00 ` Antony Kurniawan Soemardi 0 siblings, 1 reply; 9+ messages in thread From: Andy Shevchenko @ 2026-03-26 10:18 UTC (permalink / raw) To: Antony Kurniawan Soemardi Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-arm-msm, devicetree, linux-kernel, linux-iio, phone-devel On Wed, Mar 25, 2026 at 09:02:41PM +0000, Antony Kurniawan Soemardi wrote: > Implement the .read_label callback to allow userspace to identify ADC > channels via the "label" property in the device tree. The name field in > pm8xxx_chan_info is renamed to label to better reflect its purpose. If > no label is provided in the device tree, it defaults to the hardware > datasheet name. > Tested-on: Sony Xperia SP (PM8921) Interesting, never saw this tag before. > Signed-off-by: Antony Kurniawan Soemardi <linux@smankusors.com> ... > +static int pm8xxx_read_label(struct iio_dev *indio_dev, > + struct iio_chan_spec const *chan, char *label) > +{ > + struct pm8xxx_xoadc *adc = iio_priv(indio_dev); > + struct pm8xxx_chan_info *ch = pm8xxx_get_channel(adc, chan->address); > + if (!ch) { > + dev_err(adc->dev, "no such channel %lu\n", chan->address); > + return -EINVAL; > + } Isn't it a dead code? Also poisoning dmesg with this recurrent message is not good idea to begin with (the user space will have a door to flood it, which might be considered as an assistance to hackers to clear immediate logs after a successful attack). > + return sysfs_emit(label, "%s\n", ch->label); > +} -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels 2026-03-26 10:18 ` Andy Shevchenko @ 2026-03-26 12:00 ` Antony Kurniawan Soemardi 2026-03-26 19:04 ` Andy Shevchenko 0 siblings, 1 reply; 9+ messages in thread From: Antony Kurniawan Soemardi @ 2026-03-26 12:00 UTC (permalink / raw) To: Andy Shevchenko Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-arm-msm, devicetree, linux-kernel, linux-iio, phone-devel On 3/26/2026 5:18 PM, Andy Shevchenko wrote: >> Tested-on: Sony Xperia SP (PM8921) > > Interesting, never saw this tag before. Oh, I just realized I misremember Tested-by tag as Tested-on... Let me know if it's not acceptable. >> + if (!ch) { >> + dev_err(adc->dev, "no such channel %lu\n", chan->address); >> + return -EINVAL; >> + } > > Isn't it a dead code? Also poisoning dmesg with this recurrent message is not > good idea to begin with (the user space will have a door to flood it, which > might be considered as an assistance to hackers to clear immediate logs after > a successful attack). Good point about the successful attack hint! I was copying the existing code from pm8xxx_read_raw. Do you think those checks are unnecessary for pm8xxx_read_raw as well? Thanks, Antony K. S. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels 2026-03-26 12:00 ` Antony Kurniawan Soemardi @ 2026-03-26 19:04 ` Andy Shevchenko 2026-03-27 19:05 ` Antony Kurniawan Soemardi 0 siblings, 1 reply; 9+ messages in thread From: Andy Shevchenko @ 2026-03-26 19:04 UTC (permalink / raw) To: Antony Kurniawan Soemardi Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-arm-msm, devicetree, linux-kernel, linux-iio, phone-devel On Thu, Mar 26, 2026 at 12:00:52PM +0000, Antony Kurniawan Soemardi wrote: > On 3/26/2026 5:18 PM, Andy Shevchenko wrote: ... > >> Tested-on: Sony Xperia SP (PM8921) > > > > Interesting, never saw this tag before. > > Oh, I just realized I misremember Tested-by tag as Tested-on... Let me > know if it's not acceptable. You can just put it in a free text: "The change has been tested on ..." ... > >> + if (!ch) { > >> + dev_err(adc->dev, "no such channel %lu\n", chan->address); > >> + return -EINVAL; > >> + } > > > > Isn't it a dead code? Also poisoning dmesg with this recurrent message is > > not good idea to begin with (the user space will have a door to flood it, > > which might be considered as an assistance to hackers to clear immediate > > logs after a successful attack). > > Good point about the successful attack hint! I was copying the existing > code from pm8xxx_read_raw. Do you think those checks are unnecessary for > pm8xxx_read_raw as well? Yes, I think they are not as the returned code should be enough to identify the problem. (For no such channel I would rather see -ENOENT, but we can't simply replace that in the existing code as it's part of ABI.) -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels 2026-03-26 19:04 ` Andy Shevchenko @ 2026-03-27 19:05 ` Antony Kurniawan Soemardi 2026-03-29 11:54 ` Andy Shevchenko 0 siblings, 1 reply; 9+ messages in thread From: Antony Kurniawan Soemardi @ 2026-03-27 19:05 UTC (permalink / raw) To: Andy Shevchenko Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-arm-msm, devicetree, linux-kernel, linux-iio, phone-devel On 3/27/2026 2:04 AM, Andy Shevchenko wrote: > On Thu, Mar 26, 2026 at 12:00:52PM +0000, Antony Kurniawan Soemardi wrote: >> On 3/26/2026 5:18 PM, Andy Shevchenko wrote: > ... >>>> + if (!ch) { >>>> + dev_err(adc->dev, "no such channel %lu\n", chan->address); >>>> + return -EINVAL; >>>> + } >>> >>> Isn't it a dead code? Also poisoning dmesg with this recurrent message is >>> not good idea to begin with (the user space will have a door to flood it, >>> which might be considered as an assistance to hackers to clear immediate >>> logs after a successful attack). >> >> Good point about the successful attack hint! I was copying the existing >> code from pm8xxx_read_raw. Do you think those checks are unnecessary for >> pm8xxx_read_raw as well? > > Yes, I think they are not as the returned code should be enough to identify > the problem. (For no such channel I would rather see -ENOENT, but we can't > simply replace that in the existing code as it's part of ABI.) Just to re-clarify, do you mean for both pm8xxx_read_label & pm8xxx_read_raw: 1. if the check fails, it should only return -EINVAL without any logging; or 2. remove the checks because there's no way it's not found? -- Thanks, Antony K. S. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels 2026-03-27 19:05 ` Antony Kurniawan Soemardi @ 2026-03-29 11:54 ` Andy Shevchenko 0 siblings, 0 replies; 9+ messages in thread From: Andy Shevchenko @ 2026-03-29 11:54 UTC (permalink / raw) To: Antony Kurniawan Soemardi Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-arm-msm, devicetree, linux-kernel, linux-iio, phone-devel On Fri, Mar 27, 2026 at 07:05:04PM +0000, Antony Kurniawan Soemardi wrote: > On 3/27/2026 2:04 AM, Andy Shevchenko wrote: > > On Thu, Mar 26, 2026 at 12:00:52PM +0000, Antony Kurniawan Soemardi wrote: > > > On 3/26/2026 5:18 PM, Andy Shevchenko wrote: ... > > > > > + if (!ch) { > > > > > + dev_err(adc->dev, "no such channel %lu\n", chan->address); > > > > > + return -EINVAL; > > > > > + } > > > > > > > > Isn't it a dead code? Also poisoning dmesg with this recurrent message is > > > > not good idea to begin with (the user space will have a door to flood it, > > > > which might be considered as an assistance to hackers to clear immediate > > > > logs after a successful attack). > > > > > > Good point about the successful attack hint! I was copying the existing > > > code from pm8xxx_read_raw. Do you think those checks are unnecessary for > > > pm8xxx_read_raw as well? > > > > Yes, I think they are not as the returned code should be enough to identify > > the problem. (For no such channel I would rather see -ENOENT, but we can't > > simply replace that in the existing code as it's part of ABI.) > > Just to re-clarify, do you mean for both pm8xxx_read_label & > pm8xxx_read_raw: > 1. if the check fails, it should only return -EINVAL without any > logging; or > 2. remove the checks because there's no way it's not found? The first one. And yeah, -EINVAL in the both cases for the sake of consistency. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-03-29 11:54 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-25 21:02 [PATCH 0/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels from DT Antony Kurniawan Soemardi 2026-03-25 21:02 ` [PATCH 1/2] ARM: dts: qcom: pm8921: add labels for ADC channels Antony Kurniawan Soemardi 2026-03-26 11:01 ` Konrad Dybcio 2026-03-25 21:02 ` [PATCH 2/2] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels Antony Kurniawan Soemardi 2026-03-26 10:18 ` Andy Shevchenko 2026-03-26 12:00 ` Antony Kurniawan Soemardi 2026-03-26 19:04 ` Andy Shevchenko 2026-03-27 19:05 ` Antony Kurniawan Soemardi 2026-03-29 11:54 ` Andy Shevchenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox