Re: [PATCH 2/2] iio: adc: ti-ads1015: Add support for label
From: Andy Shevchenko
Date: Wed Sep 02 2026 - 01:45:12 EST
On Tue, Sep 01, 2026 at 09:43:02PM +0300, Flaviu Nistor wrote:
> Add support for label sysfs attribute similar to other adc devices. This is
> particularly useful because the label can match the schematic signal name,
> identifying channel voltages easier if label is defined via device tree.
...
> +static int ads1015_read_label(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan, char *label)
> +{
> + struct ads1015_data *data = iio_priv(indio_dev);
> + const char *name = data->channel_data[chan->address].label;
> + /*
> + * Avoid printing "(null)" in the console in case label property
> + * is missing for the channel.
> + */
> + if (!name)
> + name = "";
No need, you can assign below whatever you want for the default case.
> + return sysfs_emit(label, "%s\n", name);
> +}
...
> static int ads1015_client_get_channels_config(struct i2c_client *client)
> struct ads1015_data *data = iio_priv(indio_dev);
> struct device *dev = &client->dev;
> int i = -1;
> + const char *label;
Keep reversed xmas tree order.
...
> + if (!fwnode_property_read_string(node, "label", &label))
> + data->channel_data[channel].label = label;
We want something like
if (fwnode_property_present(...)) {
ret = fwnode_property_read_string(...);
if (ret)
return ret;
...use label...
} else {
...assign default...
}
--
With Best Regards,
Andy Shevchenko