[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1457501295-8258-1-git-send-email-vladb@linux.com>
Date: Wed, 9 Mar 2016 00:28:15 -0500
From: Vlad Banea <vladb@...ux.com>
To: lars@...afoo.de, jic23@...nel.org, Michael.Hennerich@...log.com
Cc: linux-kernel@...r.kernel.org, Vlad Banea <vladb@...ux.com>
Subject: [PATCH] iio: adis16480: fix FNCTIO_CTRL corruption when enabling IRQ
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
Powered by blists - more mailing lists