mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/2] iio: adc: ti-ads1015: Add support for label
@ 2026-09-08 19:20 Flaviu Nistor
  2026-09-08 19:20 ` [PATCH v4 1/2] dt-bindings: iio: adc: ti,ads1015: Add label property Flaviu Nistor
  2026-09-08 19:20 ` [PATCH v4 2/2] iio: adc: ti-ads1015: Add support for label Flaviu Nistor
  0 siblings, 2 replies; 5+ messages in thread
From: Flaviu Nistor @ 2026-09-08 19:20 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sa, Andy Shevchenko,
	Krzysztof Kozlowski, Rob Herring, Conor Dooley, Daniel Baluta,
	Antoniu Miclaus
  Cc: Flaviu Nistor, devicetree, linux-kernel, linux-iio

This patch series intention is to add support for label sysfs attribute
similar to other ADC devices for ti-ads1015. The patch series adds label
property in the dt-binding and the needed functionality in the driver.

Changes in v4:
- Added this cover letter
- Use Uper Case letters for "ADC" instead of "adc" in both commit messages
and move static label assignment to probe as suggested by Andy Shevchenko.
- Link to v3: https://lore.kernel.org/all/20260907152304.4992-1-flaviu.nistor@gmail.com/
Changes in v3:
- Return datasheet_name of the channel in user space if label is not present in dts. 
- Link to v2: https://lore.kernel.org/all/20260902172230.5234-2-flaviu.nistor@gmail.com/
Changes in v2:
- Implement changes suggested by Andy Shevchenko. 
- Link to v1: https://lore.kernel.org/all/20260901184302.8127-2-flaviu.nistor@gmail.com/


Flaviu Nistor (2):
  iio: adc: ti-ads1015: Add support for label
  dt-bindings: iio: adc: ti,ads1015: Add label property

 .../bindings/iio/adc/ti,ads1015.yaml          |  6 ++++
 drivers/iio/adc/ti-ads1015.c                  | 30 +++++++++++++++++++
 2 files changed, 36 insertions(+)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 1/2] dt-bindings: iio: adc: ti,ads1015: Add label property
  2026-09-08 19:20 [PATCH v4 0/2] iio: adc: ti-ads1015: Add support for label Flaviu Nistor
@ 2026-09-08 19:20 ` Flaviu Nistor
  2026-09-08 19:20 ` [PATCH v4 2/2] iio: adc: ti-ads1015: Add support for label Flaviu Nistor
  1 sibling, 0 replies; 5+ messages in thread
From: Flaviu Nistor @ 2026-09-08 19:20 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sa, Andy Shevchenko,
	Krzysztof Kozlowski, Rob Herring, Conor Dooley, Daniel Baluta,
	Antoniu Miclaus
  Cc: Flaviu Nistor, devicetree, linux-kernel, linux-iio, Krzysztof Kozlowski

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.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
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	[flat|nested] 5+ messages in thread

* [PATCH v4 2/2] iio: adc: ti-ads1015: Add support for label
  2026-09-08 19:20 [PATCH v4 0/2] iio: adc: ti-ads1015: Add support for label Flaviu Nistor
  2026-09-08 19:20 ` [PATCH v4 1/2] dt-bindings: iio: adc: ti,ads1015: Add label property Flaviu Nistor
@ 2026-09-08 19:20 ` Flaviu Nistor
  2026-09-09 14:07   ` Andy Shevchenko
  1 sibling, 1 reply; 5+ messages in thread
From: Flaviu Nistor @ 2026-09-08 19:20 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sa, Andy Shevchenko,
	Krzysztof Kozlowski, Rob Herring, Conor Dooley, Daniel Baluta,
	Antoniu Miclaus
  Cc: Flaviu Nistor, devicetree, linux-kernel, linux-iio

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 | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index 0fbfa4e499aa..0f9244107c6d 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,15 @@ 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);
+
+	return sysfs_emit(label, "%s\n",
+			  data->channel_data[chan->address].label);
+}
+
 static int ads1015_write_raw(struct iio_dev *indio_dev,
 			     struct iio_chan_spec const *chan, int val,
 			     int val2, long mask)
@@ -843,6 +853,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 +864,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,
 };
 
@@ -861,7 +873,9 @@ static int ads1015_client_get_channels_config(struct i2c_client *client)
 	struct iio_dev *indio_dev = i2c_get_clientdata(client);
 	struct ads1015_data *data = iio_priv(indio_dev);
 	struct device *dev = &client->dev;
+	const char *label;
 	int i = -1;
+	int ret;
 
 	device_for_each_child_node_scoped(dev, node) {
 		u32 pval;
@@ -897,6 +911,15 @@ static int ads1015_client_get_channels_config(struct i2c_client *client)
 			}
 		}
 
+		if (fwnode_property_present(node, "label")) {
+			ret = fwnode_property_read_string(node, "label", &label);
+			if (ret) {
+				dev_err(dev, "invalid label on %pfw\n", node);
+				return ret;
+			}
+			data->channel_data[channel].label = label;
+		}
+
 		data->channel_data[channel].pga = pga;
 		data->channel_data[channel].data_rate = data_rate;
 
@@ -985,6 +1008,13 @@ static int ads1015_probe(struct i2c_client *client)
 	/* we need to keep this ABI the same as used by hwmon ADS1015 driver */
 	ads1015_get_channels_config(client);
 
+	/* Channels without a label property fall back to the datasheet name */
+	for (i = 0; i < ADS1015_CHANNELS; i++) {
+		if (!data->channel_data[i].label)
+			data->channel_data[i].label =
+				indio_dev->channels[i].datasheet_name;
+	}
+
 	data->regmap = devm_regmap_init_i2c(client, chip->has_comparator ?
 					    &ads1015_regmap_config :
 					    &tla2024_regmap_config);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 2/2] iio: adc: ti-ads1015: Add support for label
  2026-09-08 19:20 ` [PATCH v4 2/2] iio: adc: ti-ads1015: Add support for label Flaviu Nistor
@ 2026-09-09 14:07   ` Andy Shevchenko
  2026-09-10 20:00     ` Flaviu Nistor
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2026-09-09 14:07 UTC (permalink / raw)
  To: Flaviu Nistor
  Cc: Jonathan Cameron, David Lechner, Nuno Sa, Andy Shevchenko,
	Krzysztof Kozlowski, Rob Herring, Conor Dooley, Daniel Baluta,
	Antoniu Miclaus, devicetree, linux-kernel, linux-iio

On Tue, Sep 08, 2026 at 10:20:36PM +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.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 2/2] iio: adc: ti-ads1015: Add support for label
  2026-09-09 14:07   ` Andy Shevchenko
@ 2026-09-10 20:00     ` Flaviu Nistor
  0 siblings, 0 replies; 5+ messages in thread
From: Flaviu Nistor @ 2026-09-10 20:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jonathan Cameron, David Lechner, Nuno Sa, Krzysztof Kozlowski,
	Rob Herring, Conor Dooley, Daniel Baluta, Antoniu Miclaus,
	Flaviu Nistor, devicetree, linux-kernel, linux-iio

On Wed, Sep 9, 2026 at 5:07 PM, Andy Shevchenko wrote:
>On Tue, Sep 08, 2026 at 10:20:36PM +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.
>
>Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
>
Thanks,
Flaviu
>--
>With Best Regards,
>Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-10 20:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-08 19:20 [PATCH v4 0/2] iio: adc: ti-ads1015: Add support for label Flaviu Nistor
2026-09-08 19:20 ` [PATCH v4 1/2] dt-bindings: iio: adc: ti,ads1015: Add label property Flaviu Nistor
2026-09-08 19:20 ` [PATCH v4 2/2] iio: adc: ti-ads1015: Add support for label Flaviu Nistor
2026-09-09 14:07   ` Andy Shevchenko
2026-09-10 20:00     ` Flaviu Nistor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®