Linux-IIO Archive on lore.kernel.org
 help / color / Atom feed
From: Beniamin Bia <beniamin.bia@analog.com>
To: <jic23@kernel.org>
Cc: <lars@metafoo.de>, <Michael.Hennerich@analog.com>,
	<knaack.h@gmx.de>, <pmeerw@pmeerw.net>,
	<gregkh@linuxfoundation.org>, <linux-iio@vger.kernel.org>,
	<devel@driverdev.osuosl.org>, <linux-kernel@vger.kernel.org>,
	<mark.rutland@arm.com>, <robh+dt@kernel.org>,
	<devicetree@vger.kernel.org>, <biabeniamin@outlook.com>,
	Beniamin Bia <beniamin.bia@analog.com>
Subject: [PATCH 5/5] iio: adc: ad7606: Add debug mode for ad7616
Date: Thu, 16 May 2019 17:32:08 +0300
Message-ID: <20190516143208.19294-5-beniamin.bia@analog.com> (raw)
In-Reply-To: <20190516143208.19294-1-beniamin.bia@analog.com>

Support for register access was added for spi devices.

Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
---
 drivers/iio/adc/ad7606.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index f77df3efe43f..b03bdce4fd4e 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -134,6 +134,30 @@ static int ad7606_spi_write_mask(struct ad7606_state *st,
 	return ad7606_spi_reg_write(st, addr, readval);
 }
 
+static int ad7606_reg_access(struct iio_dev *indio_dev,
+			     unsigned int reg,
+			     unsigned int writeval,
+			     unsigned int *readval)
+{
+	struct ad7606_state *st = iio_priv(indio_dev);
+	int ret;
+
+	mutex_lock(&st->lock);
+	if (readval) {
+		ret = ad7606_spi_reg_read(st, reg);
+		if (ret < 0)
+			goto err_unlock;
+		*readval = ret;
+		ret = 0;
+	} else {
+		ret = ad7606_spi_reg_write(st, reg, writeval);
+	}
+err_unlock:
+	mutex_unlock(&st->lock);
+
+	return ret;
+}
+
 static int ad7606_read_samples(struct ad7606_state *st)
 {
 	unsigned int num = st->chip_info->num_channels;
@@ -645,6 +669,7 @@ static const struct iio_info ad7606_info_no_os_or_range = {
 static const struct iio_info ad7606_info_os_and_range = {
 	.read_raw = &ad7606_read_raw,
 	.write_raw = &ad7606_write_raw,
+	.debugfs_reg_access = &ad7606_reg_access,
 	.attrs = &ad7606_attribute_group_os_and_range,
 	.validate_trigger = &ad7606_validate_trigger,
 };
-- 
2.17.1


  parent reply index

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16 14:32 [PATCH 1/5] iio: adc: ad7606: Move oversampling and scale options to chip info Beniamin Bia
2019-05-16 14:32 ` [PATCH 2/5] iio: adc: ad7606: Add software configuration Beniamin Bia
2019-05-18 10:07   ` Jonathan Cameron
2019-05-18 10:23     ` Jonathan Cameron
2019-05-16 14:32 ` [PATCH 3/5] iio: adc: ad7606: Make SPI register calculation generic and add spi support Beniamin Bia
2019-05-18 10:20   ` Jonathan Cameron
2019-05-16 14:32 ` [PATCH 4/5] iio: adc: ad7606: Add support for software mode for ad7616 Beniamin Bia
2019-05-18 10:20   ` Jonathan Cameron
2019-05-16 14:32 ` Beniamin Bia [this message]
2019-05-18 10:24   ` [PATCH 5/5] iio: adc: ad7606: Add debug " Jonathan Cameron
2019-05-18 10:04 ` [PATCH 1/5] iio: adc: ad7606: Move oversampling and scale options to chip info Jonathan Cameron
2019-05-18 10:22   ` Jonathan Cameron
2019-07-03 14:36 [PATCH 1/5] iio: adc: ad7606: Move common channel definition to header Beniamin Bia
2019-07-03 14:36 ` [PATCH 5/5] iio: adc: ad7606: Add debug mode for ad7616 Beniamin Bia
2019-07-14 15:57   ` Jonathan Cameron
2019-07-18  6:27 [PATCH 1/5] iio: adc: ad7606: Move common channel definition to header Beniamin Bia
2019-07-18  6:27 ` [PATCH 5/5] iio: adc: ad7606: Add debug mode for ad7616 Beniamin Bia
2019-07-28  7:58   ` Jonathan Cameron

Reply instructions:

You may reply publically 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=20190516143208.19294-5-beniamin.bia@analog.com \
    --to=beniamin.bia@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=biabeniamin@outlook.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pmeerw@pmeerw.net \
    --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

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org linux-iio@archiver.kernel.org
	public-inbox-index linux-iio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/ public-inbox