public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: George Stark <gnstark@sberdevices.ru>
To: <jic23@kernel.org>, <lars@metafoo.de>,
	<neil.armstrong@linaro.org>, <khilman@baylibre.com>,
	<jbrunet@baylibre.com>, <martin.blumenstingl@googlemail.com>,
	<andriy.shevchenko@linux.intel.com>, <nuno.sa@analog.com>,
	<gnstark@sberdevices.ru>
Cc: <linux-iio@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-amlogic@lists.infradead.org>, <kernel@sberdevices.ru>,
	George Stark <GNStark@sberdevices.ru>
Subject: [PATCH v7 5/6] iio: adc: meson: add channel labels
Date: Fri, 14 Jul 2023 14:37:52 +0300	[thread overview]
Message-ID: <20230714114010.293440-6-gnstark@sberdevices.ru> (raw)
In-Reply-To: <20230714114010.293440-1-gnstark@sberdevices.ru>

Add channel labels to provide human-readable names for the inputs.

Signed-off-by: George Stark <GNStark@sberdevices.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/adc/meson_saradc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

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 = {
-- 
2.38.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: George Stark <gnstark@sberdevices.ru>
To: jic23@kernel.org, lars@metafoo.de, neil.armstrong@linaro.org,
	khilman@baylibre.com, jbrunet@baylibre.com,
	martin.blumenstingl@googlemail.com,
	andriy.shevchenko@linux.intel.com, nuno.sa@analog.com,
	gnstark@sberdevices.ru
Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org,
	kernel@sberdevices.ru, George Stark <GNStark@sberdevices.ru>
Subject: [PATCH v7 5/6] iio: adc: meson: add channel labels
Date: Fri, 14 Jul 2023 14:37:52 +0300	[thread overview]
Message-ID: <20230714114010.293440-6-gnstark@sberdevices.ru> (raw)
Message-ID: <20230714113752.Fjf61uiReUaKFsYxoVh8nAEJpD2Ei9ErykSap09iidg@z> (raw)
In-Reply-To: <20230714114010.293440-1-gnstark@sberdevices.ru>

Add channel labels to provide human-readable names for the inputs.

Signed-off-by: George Stark <GNStark@sberdevices.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/adc/meson_saradc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

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 = {
-- 
2.38.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-07-14 11:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-14 11:37 [PATCH v7 0/6] meson saradc: add iio channels to read channel 7 mux inputs George Stark
2023-07-14 11:37 ` George Stark
2023-07-14 11:37 ` [PATCH v7 1/6] iio: adc: meson: remove unused timestamp channel George Stark
2023-07-14 11:37   ` George Stark
2023-07-14 11:37 ` [PATCH v7 2/6] iio: adc: meson: move enums declaration before variables declaration George Stark
2023-07-14 11:37   ` George Stark
2023-07-14 11:37 ` [PATCH v7 3/6] iio: adc: meson: move meson_sar_adc_set_chan7_mux routine upper George Stark
2023-07-14 11:37   ` George Stark
2023-07-14 11:37 ` [PATCH v7 4/6] iio: adc: meson: add enum for iio channel numbers George Stark
2023-07-14 11:37   ` George Stark
2023-07-14 11:37 ` George Stark [this message]
2023-07-14 11:37   ` [PATCH v7 5/6] iio: adc: meson: add channel labels George Stark
2023-07-14 11:37 ` [PATCH v7 6/6] iio: adc: meson: support reading from channel 7 mux inputs George Stark
2023-07-14 11:37   ` George Stark
2023-07-16 15:14 ` [PATCH v7 0/6] meson saradc: add iio channels to read " Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230714114010.293440-6-gnstark@sberdevices.ru \
    --to=gnstark@sberdevices.ru \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=jbrunet@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=kernel@sberdevices.ru \
    --cc=khilman@baylibre.com \
    --cc=lars@metafoo.de \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=neil.armstrong@linaro.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox