On Sun, Apr 05, 2026 at 04:52:21PM +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).

...

> +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);

When you have a validation the better style is to split definition and
assignment. This makes code robust against (theoretically) possible changes
that might reuse the same variable for something else.

> +     if (!ch)
> +             return -EINVAL;
> +     return sysfs_emit(label, "%s\n", ch->label);
> +}

Again, no need to resend now, just make it in the next version if that version
is asked for.

-- 
With Best Regards,
Andy Shevchenko



Reply via email to