[v1,2/3] meson saradc: add channel labels

Message ID 20230621062715.455652-3-gnstark@sberdevices.ru
State New
Headers
Series meson saradc: add iio channels to read channel 7 mux inputs |

Commit Message

George Stark June 21, 2023, 6:26 a.m. UTC
  patch adds channel attribute 'label' with channel name

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

Comments

Andy Shevchenko June 21, 2023, 2:08 p.m. UTC | #1
On Wed, Jun 21, 2023 at 09:26:09AM +0300, George Stark wrote:
> patch adds channel attribute 'label' with channel name

Please update commit message in accordance with English grammar and
Submitting Patches document (e.g. imperative mode should be used).
  

Patch

diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 42f0389e123d..66d6f527122c 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -1044,8 +1044,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, "%s\n", "temp-sensor");
+	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 = {