All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishant Malpani <nish.malpani25@gmail.com>
To: jic23@kernel.org, robh+dt@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, andy.shevchenko@gmail.com,
	Nishant Malpani <nish.malpani25@gmail.com>
Subject: [RESEND PATCH v3 3/3] iio: gyro: adxrs290: Add debugfs register access support
Date: Thu, 10 Sep 2020 23:34:50 +0530	[thread overview]
Message-ID: <20200910180450.29696-4-nish.malpani25@gmail.com> (raw)
In-Reply-To: <20200910180450.29696-1-nish.malpani25@gmail.com>

Extend support to read/write byte data from/to the device using
debugfs iio interface.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
---

Changes in v3:
  - refactor code based on Andy's suggestions

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

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)
-- 
2.20.1


  parent reply	other threads:[~2020-09-10 18:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10 18:04 [RESEND PATCH v3 0/3] iio: gyro: adxrs290: Add triggered buffer & debugfs support Nishant Malpani
2020-09-10 18:04 ` [RESEND PATCH v3 1/3] iio: gyro: adxrs290: Add triggered buffer support Nishant Malpani
2020-09-10 18:04 ` [RESEND PATCH v3 2/3] dt-bindings: iio: gyro: adxrs290: Add interrupts support Nishant Malpani
2020-09-13  9:54   ` Jonathan Cameron
2020-09-10 18:04 ` Nishant Malpani [this message]
2020-09-11  8:14 ` [RESEND PATCH v3 0/3] iio: gyro: adxrs290: Add triggered buffer & debugfs support Jonathan Cameron
2020-09-13  9:52   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200910180450.29696-4-nish.malpani25@gmail.com \
    --to=nish.malpani25@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.