Commit 755d0da4 authored by Arushi Singhal's avatar Arushi Singhal Committed by Jonathan Cameron

staging: ad7606: Replace mlock with driver private lock

The IIO subsystem is redefining iio_dev->mlock to be used by
the IIO core only for protecting device operating mode changes.
ie. Changes between INDIO_DIRECT_MODE, INDIO_BUFFER_* modes.

In this driver, mlock was being used to protect hardware state
changes.  Replace it with a lock in the devices global data.
Signed-off-by: default avatarArushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 64822be4
...@@ -208,7 +208,7 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, ...@@ -208,7 +208,7 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
switch (mask) { switch (mask) {
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
ret = -EINVAL; ret = -EINVAL;
mutex_lock(&indio_dev->mlock); mutex_lock(&st->lock);
for (i = 0; i < ARRAY_SIZE(scale_avail); i++) for (i = 0; i < ARRAY_SIZE(scale_avail); i++)
if (val2 == scale_avail[i][1]) { if (val2 == scale_avail[i][1]) {
gpiod_set_value(st->gpio_range, i); gpiod_set_value(st->gpio_range, i);
...@@ -217,7 +217,7 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, ...@@ -217,7 +217,7 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
ret = 0; ret = 0;
break; break;
} }
mutex_unlock(&indio_dev->mlock); mutex_unlock(&st->lock);
return ret; return ret;
case IIO_CHAN_INFO_OVERSAMPLING_RATIO: case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
...@@ -231,11 +231,11 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, ...@@ -231,11 +231,11 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
values[1] = (ret >> 1) & 1; values[1] = (ret >> 1) & 1;
values[2] = (ret >> 2) & 1; values[2] = (ret >> 2) & 1;
mutex_lock(&indio_dev->mlock); mutex_lock(&st->lock);
gpiod_set_array_value(ARRAY_SIZE(values), st->gpio_os->desc, gpiod_set_array_value(ARRAY_SIZE(values), st->gpio_os->desc,
values); values);
st->oversampling = val; st->oversampling = val;
mutex_unlock(&indio_dev->mlock); mutex_unlock(&st->lock);
return 0; return 0;
default: default:
...@@ -413,6 +413,7 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address, ...@@ -413,6 +413,7 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
st = iio_priv(indio_dev); st = iio_priv(indio_dev);
st->dev = dev; st->dev = dev;
mutex_init(&st->lock);
st->bops = bops; st->bops = bops;
st->base_address = base_address; st->base_address = base_address;
/* tied to logic low, analog input range is +/- 5V */ /* tied to logic low, analog input range is +/- 5V */
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
* @name: identification string for chip * @name: identification string for chip
* @channels: channel specification * @channels: channel specification
* @num_channels: number of channels * @num_channels: number of channels
* @lock protect sensor state
*/ */
struct ad7606_chip_info { struct ad7606_chip_info {
...@@ -23,6 +24,7 @@ struct ad7606_chip_info { ...@@ -23,6 +24,7 @@ struct ad7606_chip_info {
/** /**
* struct ad7606_state - driver instance specific data * struct ad7606_state - driver instance specific data
* @lock protect sensor state
*/ */
struct ad7606_state { struct ad7606_state {
...@@ -37,6 +39,7 @@ struct ad7606_state { ...@@ -37,6 +39,7 @@ struct ad7606_state {
bool done; bool done;
void __iomem *base_address; void __iomem *base_address;
struct mutex lock; /* protect sensor state */
struct gpio_desc *gpio_convst; struct gpio_desc *gpio_convst;
struct gpio_desc *gpio_reset; struct gpio_desc *gpio_reset;
struct gpio_desc *gpio_range; struct gpio_desc *gpio_range;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment