* [PATCH 1/2] dt-bindings: iio: adc: ti,ads1015: Add label property @ 2026-09-01 18:43 Flaviu Nistor 2026-09-01 18:43 ` [PATCH 2/2] iio: adc: ti-ads1015: Add support for label Flaviu Nistor 0 siblings, 1 reply; 3+ messages in thread From: Flaviu Nistor @ 2026-09-01 18:43 UTC (permalink / raw) To: Jonathan Cameron, David Lechner, Nuno Sa, Andy Shevchenko, Antoniu Miclaus, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Daniel Baluta Cc: Flaviu Nistor, linux-iio, linux-kernel, devicetree Add support for an optional label property per channel similar to other adc chips. This allows assigning distinct names for each channel which can match the schematic signal name. Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com> --- Documentation/devicetree/bindings/iio/adc/ti,ads1015.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/ti,ads1015.yaml b/Documentation/devicetree/bindings/iio/adc/ti,ads1015.yaml index 718f633c6e04..777a75c21d7f 100644 --- a/Documentation/devicetree/bindings/iio/adc/ti,ads1015.yaml +++ b/Documentation/devicetree/bindings/iio/adc/ti,ads1015.yaml @@ -66,6 +66,11 @@ patternProperties: - minimum: 0 maximum: 7 + label: + $ref: /schemas/types.yaml#/definitions/string + description: + A descriptive name for this channel, like "vcc_ram" or "CH3". + ti,gain: $ref: /schemas/types.yaml#/definitions/uint32 minimum: 0 @@ -125,6 +130,7 @@ examples: reg = <4>; ti,gain = <3>; ti,datarate = <5>; + label = "CH3"; }; }; }; -- 2.34.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] iio: adc: ti-ads1015: Add support for label 2026-09-01 18:43 [PATCH 1/2] dt-bindings: iio: adc: ti,ads1015: Add label property Flaviu Nistor @ 2026-09-01 18:43 ` Flaviu Nistor 2026-09-02 5:39 ` Andy Shevchenko 0 siblings, 1 reply; 3+ messages in thread From: Flaviu Nistor @ 2026-09-01 18:43 UTC (permalink / raw) To: Jonathan Cameron, David Lechner, Nuno Sa, Andy Shevchenko, Antoniu Miclaus, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Daniel Baluta Cc: Flaviu Nistor, linux-iio, linux-kernel, devicetree 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. Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com> --- drivers/iio/adc/ti-ads1015.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index 0fbfa4e499aa..399a3322732d 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -233,6 +233,7 @@ static const struct iio_event_spec ads1015_events[] = { struct ads1015_channel_data { unsigned int pga; unsigned int data_rate; + const char *label; }; struct ads1015_thresh_data { @@ -586,6 +587,22 @@ static int ads1015_read_raw(struct iio_dev *indio_dev, } } +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 = ""; + + return sysfs_emit(label, "%s\n", name); +} + static int ads1015_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) @@ -843,6 +860,7 @@ static const struct iio_buffer_setup_ops ads1015_buffer_setup_ops = { static const struct iio_info ads1015_info = { .read_avail = ads1015_read_avail, .read_raw = ads1015_read_raw, + .read_label = ads1015_read_label, .write_raw = ads1015_write_raw, .read_event_value = ads1015_read_event, .write_event_value = ads1015_write_event, @@ -853,6 +871,7 @@ static const struct iio_info ads1015_info = { static const struct iio_info tla2024_info = { .read_avail = ads1015_read_avail, .read_raw = ads1015_read_raw, + .read_label = ads1015_read_label, .write_raw = ads1015_write_raw, }; @@ -862,6 +881,7 @@ 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; device_for_each_child_node_scoped(dev, node) { u32 pval; @@ -897,6 +917,9 @@ static int ads1015_client_get_channels_config(struct i2c_client *client) } } + if (!fwnode_property_read_string(node, "label", &label)) + data->channel_data[channel].label = label; + data->channel_data[channel].pga = pga; data->channel_data[channel].data_rate = data_rate; -- 2.34.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] iio: adc: ti-ads1015: Add support for label 2026-09-01 18:43 ` [PATCH 2/2] iio: adc: ti-ads1015: Add support for label Flaviu Nistor @ 2026-09-02 5:39 ` Andy Shevchenko 0 siblings, 0 replies; 3+ messages in thread From: Andy Shevchenko @ 2026-09-02 5:39 UTC (permalink / raw) To: Flaviu Nistor Cc: Jonathan Cameron, David Lechner, Nuno Sa, Andy Shevchenko, Antoniu Miclaus, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Daniel Baluta, linux-iio, linux-kernel, devicetree 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-02 5:39 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-09-01 18:43 [PATCH 1/2] dt-bindings: iio: adc: ti,ads1015: Add label property Flaviu Nistor 2026-09-01 18:43 ` [PATCH 2/2] iio: adc: ti-ads1015: Add support for label Flaviu Nistor 2026-09-02 5:39 ` Andy Shevchenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox