Skip to content

Commit

Permalink
iio: adc: cf_axi_adc_core: Add read_label cb() and forward
Browse files Browse the repository at this point in the history
Not sure how this behaves for client devices which don't set it...

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
  • Loading branch information
mhennerich authored and cristiantpop committed Jan 28, 2022
1 parent 8ece9df commit 06dfcb7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/iio/adc/cf_axi_adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ struct axiadc_converter {
enum iio_event_direction dir,
int state);

int (*read_label)(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, char *label);

int (*post_setup)(struct iio_dev *indio_dev);
int (*post_iio_register)(struct iio_dev *indio_dev);
int (*set_pnsel)(struct iio_dev *indio_dev, unsigned chan,
Expand Down
15 changes: 15 additions & 0 deletions drivers/iio/adc/cf_axi_adc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,20 @@ static int axiadc_write_raw(struct iio_dev *indio_dev,
}
}

static int axiadc_read_label(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, char *label)
{
struct axiadc_state *st = iio_priv(indio_dev);
struct axiadc_converter *conv = to_converter(st->dev_spi);

if (conv && conv->read_label)
return conv->read_label(indio_dev, chan, label);
else if (chan->extend_name)
return sprintf(label, "%s\n", chan->extend_name);
else
return -ENOSYS;
}

static int axiadc_read_event_value(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, enum iio_event_type type,
enum iio_event_direction dir, enum iio_event_info info, int *val,
Expand Down Expand Up @@ -784,6 +798,7 @@ static const struct iio_info axiadc_info = {
.write_event_config = &axiadc_write_event_config,
.debugfs_reg_access = &axiadc_reg_access,
.update_scan_mode = &axiadc_update_scan_mode,
.read_label = &axiadc_read_label,
};

struct axiadc_spidev {
Expand Down

0 comments on commit 06dfcb7

Please sign in to comment.