aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorAlexandru Ardelean <alexandru.ardelean@analog.com>2019-05-30 16:18:09 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-06-17 21:06:47 +0100
commitdbcf6b5d2625b904f13810b168773b05d891204b (patch)
tree87c821c831af398a4fb94c603bba6d85fe09f261 /drivers/iio
parentiio: amplifiers: update license information (diff)
downloadlinux-dev-dbcf6b5d2625b904f13810b168773b05d891204b.tar.xz
linux-dev-dbcf6b5d2625b904f13810b168773b05d891204b.zip
iio: amplifiers: ad8366: use own lock to guard state
This driver is still using iio_dev's mlock to guard against inconsistent state. This has been discouraged for some time. This change switches to using it's own mutex, defined on the state struct. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/amplifiers/ad8366.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 82ac15914ff3..24ff5475d9f2 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -21,6 +21,7 @@
struct ad8366_state {
struct spi_device *spi;
struct regulator *reg;
+ struct mutex lock; /* protect sensor state */
unsigned char ch[2];
/*
* DMA (thus cache coherency maintenance) requires the
@@ -58,7 +59,7 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
int ret;
unsigned code;
- mutex_lock(&indio_dev->mlock);
+ mutex_lock(&st->lock);
switch (m) {
case IIO_CHAN_INFO_HARDWAREGAIN:
code = st->ch[chan->channel];
@@ -73,7 +74,7 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
default:
ret = -EINVAL;
}
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&st->lock);
return ret;
};
@@ -99,7 +100,7 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
code = (code - 4500) / 253;
- mutex_lock(&indio_dev->mlock);
+ mutex_lock(&st->lock);
switch (mask) {
case IIO_CHAN_INFO_HARDWAREGAIN:
st->ch[chan->channel] = code;
@@ -108,7 +109,7 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
default:
ret = -EINVAL;
}
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&st->lock);
return ret;
}
@@ -151,6 +152,7 @@ static int ad8366_probe(struct spi_device *spi)
}
spi_set_drvdata(spi, indio_dev);
+ mutex_init(&st->lock);
st->spi = spi;
indio_dev->dev.parent = &spi->dev;