Skip to content

Commit

Permalink
staging: iio: resolver: ad2s1210: add label attribute support
Browse files Browse the repository at this point in the history
The ad2s1210 resolver driver has quite a few channels, mostly for
internal signals for event support. This makes it difficult to know
which channel is which. This patch adds a label attribute to the
channels to make it easier to identify them.

Signed-off-by: David Lechner <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
dlech committed Oct 31, 2023
1 parent 5416cc1 commit a5bbcfb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions drivers/staging/iio/resolver/ad2s1210.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,34 @@ static int ad2s1210_initial(struct ad2s1210_state *st)
return ret;
}

static int ad2s1210_read_label(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
char *label)
{
if (chan->type == IIO_ANGL) {
if (chan->channel == 0)
return sprintf(label, "position\n");
if (chan->channel == 1)
return sprintf(label, "tracking error\n");
}
if (chan->type == IIO_ANGL_VEL)
return sprintf(label, "velocity\n");
if (chan->type == IIO_PHASE)
return sprintf(label, "synthetic reference\n");
if (chan->type == IIO_ALTVOLTAGE) {
if (chan->output)
return sprintf(label, "excitation\n");
if (chan->channel == 0)
return sprintf(label, "monitor signal\n");
if (chan->channel == 1)
return sprintf(label, "cosine\n");
if (chan->channel == 2)
return sprintf(label, "sine\n");
}

return -EINVAL;
}

static int ad2s1210_read_event_value(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
enum iio_event_type type,
Expand Down Expand Up @@ -1338,6 +1366,7 @@ static const struct iio_info ad2s1210_info = {
.read_raw = ad2s1210_read_raw,
.read_avail = ad2s1210_read_avail,
.write_raw = ad2s1210_write_raw,
.read_label = ad2s1210_read_label,
.attrs = &ad2s1210_attribute_group,
.read_event_value = ad2s1210_read_event_value,
.write_event_value = ad2s1210_write_event_value,
Expand Down

0 comments on commit a5bbcfb

Please sign in to comment.