diff mbox series

[v2,3/3] iio: gyro: adxrs290: Add debugfs register access support

Message ID 20200903130950.6274-4-nish.malpani25@gmail.com (mailing list archive)
State New, archived
Headers show
Series iio: gyro: adxrs290: Add triggered buffer & debugfs support | expand

Commit Message

Nishant Malpani Sept. 3, 2020, 1:09 p.m. UTC
Extend support to read/write byte data from/to the device using
debugfs iio interface.

Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
---

No changes in v2
---
 drivers/iio/gyro/adxrs290.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Jonathan Cameron Sept. 6, 2020, 3:03 p.m. UTC | #1
On Thu, 3 Sep 2020 16:59:12 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Thu, Sep 3, 2020 at 4:57 PM Nishant Malpani <nish.malpani25@gmail.com> wrote:
> > On Thu, Sep 3, 2020 at 6:55 PM Andy Shevchenko
> > <andy.shevchenko@gmail.com> wrote:  
> 
> ...
> 
> > Umm, I'm sorry, I don't see why'd it be favourable for us to do it
> > this way. Also, I *think* Jonathan is fine with how it's being done
> > now.  
> 
> I have no strong opinion, so whatever Jonathan thinks better.
> 

Andy's suggestion is a little bit nicer, so as you are doing a v3,
might as well roll that change in as well :)

Jonathan
diff mbox series

Patch

diff --git a/drivers/iio/gyro/adxrs290.c b/drivers/iio/gyro/adxrs290.c
index 4099b8917d3e..132fd16789f0 100644
--- a/drivers/iio/gyro/adxrs290.c
+++ b/drivers/iio/gyro/adxrs290.c
@@ -434,6 +434,24 @@  static int adxrs290_read_avail(struct iio_dev *indio_dev,
 	}
 }
 
+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);
+	int ret;
+
+	if (!readval)
+		return adxrs290_spi_write_reg(st->spi, reg, writeval);
+
+	ret = spi_w8r8(st->spi, ADXRS290_READ_REG(reg));
+	if (ret < 0)
+		return ret;
+
+	*readval = ret;
+
+	return 0;
+}
+
 static int adxrs290_data_rdy_trigger_set_state(struct iio_trigger *trig, bool state)
 {
 	struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
@@ -546,6 +564,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)