diff options
author | Nishant Malpani | 2020-09-10 23:34:50 +0530 |
---|---|---|
committer | Jonathan Cameron | 2020-09-13 10:51:46 +0100 |
commit | d3e0e14d65178d73ee0f991934c5fa89737e3922 (patch) | |
tree | 21c5cc3eeaea1c1a60ebcec9b36ce7953208eaac | |
parent | 85434c2ab315978185ff60b6c9f5af6e6022ba84 (diff) |
iio: gyro: adxrs290: Add debugfs register access support
Extend support to read/write byte data from/to the device using
debugfs iio interface.
Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20200910180450.29696-4-nish.malpani25@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r-- | drivers/iio/gyro/adxrs290.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/iio/gyro/adxrs290.c b/drivers/iio/gyro/adxrs290.c index 41b1f995a143..ca6fc234076e 100644 --- a/drivers/iio/gyro/adxrs290.c +++ b/drivers/iio/gyro/adxrs290.c @@ -436,6 +436,31 @@ static int adxrs290_read_avail(struct iio_dev *indio_dev, } } +static int adxrs290_reg_access_rw(struct spi_device *spi, unsigned int reg, + unsigned int *readval) +{ + int ret; + + ret = spi_w8r8(spi, ADXRS290_READ_REG(reg)); + if (ret < 0) + return ret; + + *readval = ret; + + return 0; +} + +static int adxrs290_reg_access(struct iio_dev *indio_dev, unsigned int reg, + unsigned int writeval, unsigned int *readval) +{ + struct adxrs290_state *st = iio_priv(indio_dev); + + if (readval) + return adxrs290_reg_access_rw(st->spi, reg, readval); + else + return adxrs290_spi_write_reg(st->spi, reg, writeval); +} + static int adxrs290_data_rdy_trigger_set_state(struct iio_trigger *trig, bool state) { @@ -551,6 +576,7 @@ static const struct iio_info adxrs290_info = { .read_raw = &adxrs290_read_raw, .write_raw = &adxrs290_write_raw, .read_avail = &adxrs290_read_avail, + .debugfs_reg_access = &adxrs290_reg_access, }; static int adxrs290_probe_trigger(struct iio_dev *indio_dev) |