[PATCH RFC 8/8] iio: frequency: ad9910: add channel labels

Rodrigo Alencar via B4 Relay posted 8 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH RFC 8/8] iio: frequency: ad9910: add channel labels
Posted by Rodrigo Alencar via B4 Relay 1 month, 1 week ago
From: Rodrigo Alencar <rodrigo.alencar@analog.com>

Add human-readable labels for all AD9910 IIO channels via the read_label
callback: single_tone, parallel_port, digital_ramp_generator, ram_control,
and output_shift_keying.

Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
 drivers/iio/frequency/ad9910.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/iio/frequency/ad9910.c b/drivers/iio/frequency/ad9910.c
index b1540b157a0e..e983614805b4 100644
--- a/drivers/iio/frequency/ad9910.c
+++ b/drivers/iio/frequency/ad9910.c
@@ -1814,10 +1814,26 @@ static const struct attribute_group ad9910_attrs_group = {
 	.bin_attrs = ad9910_bin_attrs,
 };
 
+static const char * const ad9910_channel_str[] = {
+	[AD9910_CHANNEL_SINGLE_TONE] = "single_tone",
+	[AD9910_CHANNEL_PARALLEL_PORT] = "parallel_port",
+	[AD9910_CHANNEL_DRG] = "digital_ramp_generator",
+	[AD9910_CHANNEL_RAM] = "ram_control",
+	[AD9910_CHANNEL_OSK] = "output_shift_keying",
+};
+
+static int ad9910_read_label(struct iio_dev *indio_dev,
+			     struct iio_chan_spec const *chan,
+			     char *label)
+{
+	return sprintf(label, "%s\n", ad9910_channel_str[chan->channel]);
+}
+
 static const struct iio_info ad9910_info = {
 	.read_raw = ad9910_read_raw,
 	.write_raw = ad9910_write_raw,
 	.write_raw_get_fmt = ad9910_write_raw_get_fmt,
+	.read_label = ad9910_read_label,
 	.attrs = &ad9910_attrs_group,
 	.debugfs_reg_access = &ad9910_reg_access,
 };

-- 
2.43.0