mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vlad Banea <vladb@linux.com>
To: lars@metafoo.de, jic23@kernel.org, Michael.Hennerich@analog.com
Cc: linux-kernel@vger.kernel.org, Vlad Banea <vladb@linux.com>
Subject: [PATCH] iio: adis16480: fix FNCTIO_CTRL corruption when enabling IRQ
Date: Wed,  9 Mar 2016 00:28:15 -0500	[thread overview]
Message-ID: <1457501295-8258-1-git-send-email-vladb@linux.com> (raw)

Enabling the IRQ should leave all other settings in the FNCTIO_CTRL
register untouched: read the whole register, toggle just the enable bit,
before writing it back.
---
 drivers/iio/imu/adis16480.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index b94bfd3..8473859 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -738,8 +738,19 @@ static int adis16480_stop_device(struct iio_dev *indio_dev)
 
 static int adis16480_enable_irq(struct adis *adis, bool enable)
 {
-	return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL,
-		enable ? BIT(3) : 0);
+	u16 fnctio_ctrl;
+	int ret;
+
+	ret = adis_read_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, &fnctio_ctrl);
+	if (ret < 0)
+		return ret;
+
+	if (enable)
+		fnctio_ctrl |= BIT(3);
+	else
+		fnctio_ctrl &= ~BIT(3);
+
+	return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, fnctio_ctrl);
 }
 
 static int adis16480_initial_setup(struct iio_dev *indio_dev)
-- 
2.7.1

             reply	other threads:[~2016-03-09  5:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-09  5:28 Vlad Banea [this message]
2016-03-09  9:22 ` Lars-Peter Clausen
     [not found]   ` <CACBkv7uBy_eJv5aZRvaHAn6VY0rrjJkWF4mBXvv9_4wFJA9qiQ@mail.gmail.com>
2016-03-09 12:21     ` Lars-Peter Clausen
     [not found]       ` <CACBkv7v=D7frj6Uo7c9pd5aohVv_OUJU4jpoHdhP+S5KgmqHAw@mail.gmail.com>
2016-03-09 16:41         ` Lars-Peter Clausen
2016-03-09 17:06           ` Vlad Banea
2016-03-12 11:14             ` 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=1457501295-8258-1-git-send-email-vladb@linux.com \
    --to=vladb@linux.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®