[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170523080729.20459-1-nikita.yoush@cogentembedded.com>
Date: Tue, 23 May 2017 11:07:29 +0300
From: Nikita Yushchenko <nikita.yoush@...entembedded.com>
To: Jonathan Cameron <jic23@...nel.org>,
Hartmut Knaack <knaack.h@....de>,
Lars-Peter Clausen <lars@...afoo.de>,
Peter Meerwald-Stadler <pmeerw@...erw.net>,
Sanchayan Maity <maitysanchayan@...il.com>,
Gregor Boirie <gregor.boirie@...rot.com>,
Matt Ranostay <mranostay@...il.com>
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
Chris Healy <Chris.Healy@....aero>,
Jeff White <Jeff.White@....aero>,
Vladimir Barinov <vladimir.barinov@...entembedded.com>,
Nikita Yushchenko <nikita.yoush@...entembedded.com>
Subject: [PATCH] iio: hi8435: fix race between event enable and event generation
Add locking to avoid interference between reading/processing current
sence in event enable and event generation paths.
Signed-off-by: Nikita Yushchenko <nikita.yoush@...entembedded.com>
---
drivers/iio/adc/hi8435.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/iio/adc/hi8435.c b/drivers/iio/adc/hi8435.c
index ab59969b7c49..28fc699f00f6 100644
--- a/drivers/iio/adc/hi8435.c
+++ b/drivers/iio/adc/hi8435.c
@@ -144,6 +144,8 @@ static int hi8435_write_event_config(struct iio_dev *idev,
int ret;
u32 tmp;
+ mutex_lock(&priv->lock);
+
if (state) {
ret = hi8435_readl(priv, HI8435_SO31_0_REG, &tmp);
if (ret < 0)
@@ -157,6 +159,8 @@ static int hi8435_write_event_config(struct iio_dev *idev,
} else
priv->event_scan_mask &= ~BIT(chan->channel);
+ mutex_unlock(&priv->lock);
+
return 0;
}
@@ -449,12 +453,16 @@ static irqreturn_t hi8435_trigger_handler(int irq, void *private)
u32 val;
int ret;
+ mutex_lock(&priv->lock);
+
ret = hi8435_readl(priv, HI8435_SO31_0_REG, &val);
if (ret < 0)
goto err_read;
hi8435_iio_push_event(idev, val);
+ mutex_unlock(&priv->lock);
+
err_read:
iio_trigger_notify_done(idev->trig);
--
2.11.0
Powered by blists - more mailing lists