Re: [PATCH v2 3/3] iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels

From: Andy Shevchenko

Date: Sat Apr 04 2026 - 15:28:22 EST


On Fri, Apr 03, 2026 at 09:23:21AM +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.
>
> The change has been tested on Sony Xperia SP (PM8921).

...

> + ret = fwnode_property_read_string(fwnode, "label", &ch->label);
> + if (ret)
> + ch->label = hwchan->datasheet_name;

Branch is not needed.

ch->label = hwchan->datasheet_name;
fwnode_property_read_string(fwnode, "label", &ch->label);

will have the same effect. But if you want to handle errors, you may do

if (fwnode_property_present(...)) {
ret = fwnode_property_read_string(...);
if (ret)
return ret;
} else {
...assign default...
}


--
With Best Regards,
Andy Shevchenko