[PATCH 11/16] iio: frequency: ad9523: use read_label() for channel names

From: Nuno Sá

Date: Mon Nov 30 2026 - 12:38:36 EST


The optional channel name is passed in as extend_name, which ends up in
the name of every sysfs attribute of the channel, like
out_altvoltage1_DAC_CLK_frequency. Using extend_name for this is
discouraged, and it does not fit names coming from firmware.

Expose the name through the channel label instead, so the attributes
keep their standard names. This changes the attribute names of named
channels, but the name can only be given through platform data, which
has no users.

Signed-off-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
---
drivers/iio/frequency/ad9523.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 66083af2be4e..dbf29797130b 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -392,6 +392,7 @@ struct ad9523_state {
unsigned long vco_freq;
unsigned long vco_out_freq[AD9523_NUM_CLK_SRC];
unsigned char vco_out_map[AD9523_NUM_CHAN];
+ const char *labels[AD9523_NUM_CHAN];

/*
* Lock for accessing device registers. Some operations require
@@ -860,9 +861,21 @@ static int ad9523_reg_access(struct iio_dev *indio_dev,
return ret;
}

+static int ad9523_read_label(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan, char *label)
+{
+ struct ad9523_state *st = iio_priv(indio_dev);
+
+ if (!st->labels[chan->channel])
+ return -ENOENT;
+
+ return sysfs_emit(label, "%s\n", st->labels[chan->channel]);
+}
+
static const struct iio_info ad9523_info = {
.read_raw = &ad9523_read_raw,
.write_raw = &ad9523_write_raw,
+ .read_label = &ad9523_read_label,
.debugfs_reg_access = &ad9523_reg_access,
.attrs = &ad9523_attribute_group,
};
@@ -1009,8 +1022,9 @@ static int ad9523_setup(struct iio_dev *indio_dev)
st->ad9523_channels[i].output = 1;
st->ad9523_channels[i].indexed = 1;
st->ad9523_channels[i].channel = chan->channel_num;
- st->ad9523_channels[i].extend_name =
- chan->extended_name;
+ if (chan->extended_name[0])
+ st->labels[chan->channel_num] =
+ chan->extended_name;
st->ad9523_channels[i].info_mask_separate =
BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_PHASE) |

--
2.56.0