diff mbox series

[v4,5/6] iio: adc: meson: add channel labels

Message ID 20230707153322.114302-6-gnstark@sberdevices.ru (mailing list archive)
State Superseded
Headers show
Series iio: adc: meson: add iio channels to read channel 7 mux inputs | expand

Commit Message

George Stark July 7, 2023, 3:27 p.m. UTC
Add channel labels to provide human-readable names for the channles.

Signed-off-by: George Stark <GNStark@sberdevices.ru>
---
 drivers/iio/adc/meson_saradc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Andy Shevchenko July 10, 2023, 9:29 a.m. UTC | #1
On Fri, Jul 07, 2023 at 06:27:42PM +0300, George Stark wrote:
> Add channel labels to provide human-readable names for the channles.

Either drop first "channel" or "for the channels" to avoid tautology.
diff mbox series

Patch

diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index b14c66656bcc..918bd5da3605 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -1055,8 +1055,20 @@  static int meson_sar_adc_calib(struct iio_dev *indio_dev)
 	return ret;
 }
 
+static int read_label(struct iio_dev *indio_dev,
+		      struct iio_chan_spec const *chan,
+		      char *label)
+{
+	if (chan->type == IIO_TEMP)
+		return sprintf(label, "temp-sensor\n");
+	if (chan->type == IIO_VOLTAGE)
+		return sprintf(label, "channel-%d\n", chan->channel);
+	return 0;
+}
+
 static const struct iio_info meson_sar_adc_iio_info = {
 	.read_raw = meson_sar_adc_iio_info_read_raw,
+	.read_label = read_label,
 };
 
 static const struct meson_sar_adc_param meson_sar_adc_meson8_param = {