All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Fuzzey <mfuzzey@parkeon.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org
Subject: [PATCH V5 2/7] iio: mma8452: Add access to registers via DebugFS
Date: Mon, 01 Jun 2015 15:39:47 +0200	[thread overview]
Message-ID: <20150601133947.24925.93766.stgit@localhost> (raw)
In-Reply-To: <20150601133943.24925.83080.stgit@localhost>

Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com>
---
 drivers/iio/accel/mma8452.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 001a7db..877ce29 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -34,6 +34,8 @@
 #define MMA8452_CTRL_REG2 0x2b
 #define MMA8452_CTRL_REG2_RST		BIT(6)
 
+#define MMA8452_MAX_REG 0x31
+
 #define MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0))
 
 #define MMA8452_CTRL_DR_MASK (BIT(5) | BIT(4) | BIT(3))
@@ -292,6 +294,28 @@ done:
 	return IRQ_HANDLED;
 }
 
+static int mma8452_reg_access_dbg(struct iio_dev *indio_dev,
+				  unsigned reg, unsigned writeval,
+				  unsigned *readval)
+{
+	int ret;
+	struct mma8452_data *data = iio_priv(indio_dev);
+
+	if (reg > MMA8452_MAX_REG)
+		return -EINVAL;
+
+	if (!readval)
+		return mma8452_change_config(data, reg, writeval);
+
+	ret = i2c_smbus_read_byte_data(data->client, reg);
+	if (ret < 0)
+		return ret;
+
+	*readval = ret;
+
+	return 0;
+}
+
 #define MMA8452_CHANNEL(axis, idx) { \
 	.type = IIO_ACCEL, \
 	.modified = 1, \
@@ -331,6 +355,7 @@ static const struct iio_info mma8452_info = {
 	.attrs = &mma8452_group,
 	.read_raw = &mma8452_read_raw,
 	.write_raw = &mma8452_write_raw,
+	.debugfs_reg_access = &mma8452_reg_access_dbg,
 	.driver_module = THIS_MODULE,
 };
 

  parent reply	other threads:[~2015-06-01 13:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01 13:39 [PATCH V5 0/7] iio: mma8452 enhancements Martin Fuzzey
2015-06-01 13:39 ` [PATCH V5 1/7] iio: mma8452: Initialise before activating Martin Fuzzey
2015-06-01 13:39 ` Martin Fuzzey [this message]
2015-06-01 13:39 ` [PATCH V5 3/7] iio: core: add high pass filter attributes Martin Fuzzey
2015-06-01 13:39 ` [PATCH V5 4/7] iio: mma8452: Basic support for transient events Martin Fuzzey
2015-06-07 16:20   ` Jonathan Cameron
2015-06-01 13:39 ` [PATCH V5 5/7] iio: mma8452: Add support for transient event debouncing Martin Fuzzey
2015-06-07 16:20   ` Jonathan Cameron
2015-06-01 13:39 ` [PATCH V5 6/7] iio: mma8452: Add highpass filter configuration Martin Fuzzey
2015-06-07 16:21   ` Jonathan Cameron
2015-06-01 13:39 ` [PATCH V5 7/7] iio: mma8452: Add support for interrupt driven triggers Martin Fuzzey
2015-06-07 16:22   ` Jonathan Cameron
2015-06-07 16:13 ` [PATCH V5 0/7] iio: mma8452 enhancements Jonathan Cameron
2015-06-07 16:14 ` Jonathan Cameron
2015-06-07 16:23   ` 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=20150601133947.24925.93766.stgit@localhost \
    --to=mfuzzey@parkeon.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.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.