Commit 0b2884ef authored by Sergiu Cuciurean's avatar Sergiu Cuciurean Committed by Jonathan Cameron

iio: dac: ad5686: Replace indio_dev->mlock with own device lock

As part of the general cleanup of indio_dev->mlock, this change replaces
it with a local lock on the device's state structure.
Signed-off-by: default avatarSergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 9bc17892
...@@ -127,9 +127,9 @@ static int ad5686_read_raw(struct iio_dev *indio_dev, ...@@ -127,9 +127,9 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
switch (m) { switch (m) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock); mutex_lock(&st->lock);
ret = st->read(st, chan->address); ret = st->read(st, chan->address);
mutex_unlock(&indio_dev->mlock); mutex_unlock(&st->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
*val = (ret >> chan->scan_type.shift) & *val = (ret >> chan->scan_type.shift) &
...@@ -157,12 +157,12 @@ static int ad5686_write_raw(struct iio_dev *indio_dev, ...@@ -157,12 +157,12 @@ static int ad5686_write_raw(struct iio_dev *indio_dev,
if (val > (1 << chan->scan_type.realbits) || val < 0) if (val > (1 << chan->scan_type.realbits) || val < 0)
return -EINVAL; return -EINVAL;
mutex_lock(&indio_dev->mlock); mutex_lock(&st->lock);
ret = st->write(st, ret = st->write(st,
AD5686_CMD_WRITE_INPUT_N_UPDATE_N, AD5686_CMD_WRITE_INPUT_N_UPDATE_N,
chan->address, chan->address,
val << chan->scan_type.shift); val << chan->scan_type.shift);
mutex_unlock(&indio_dev->mlock); mutex_unlock(&st->lock);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
...@@ -468,6 +468,8 @@ int ad5686_probe(struct device *dev, ...@@ -468,6 +468,8 @@ int ad5686_probe(struct device *dev,
indio_dev->channels = st->chip_info->channels; indio_dev->channels = st->chip_info->channels;
indio_dev->num_channels = st->chip_info->num_channels; indio_dev->num_channels = st->chip_info->num_channels;
mutex_init(&st->lock);
switch (st->chip_info->regmap_type) { switch (st->chip_info->regmap_type) {
case AD5310_REGMAP: case AD5310_REGMAP:
cmd = AD5686_CMD_CONTROL_REG; cmd = AD5686_CMD_CONTROL_REG;
......
...@@ -117,6 +117,7 @@ struct ad5686_chip_info { ...@@ -117,6 +117,7 @@ struct ad5686_chip_info {
* @pwr_down_mask: power down mask * @pwr_down_mask: power down mask
* @pwr_down_mode: current power down mode * @pwr_down_mode: current power down mode
* @use_internal_vref: set to true if the internal reference voltage is used * @use_internal_vref: set to true if the internal reference voltage is used
* @lock lock to protect the data buffer during regmap ops
* @data: spi transfer buffers * @data: spi transfer buffers
*/ */
...@@ -130,6 +131,7 @@ struct ad5686_state { ...@@ -130,6 +131,7 @@ struct ad5686_state {
ad5686_write_func write; ad5686_write_func write;
ad5686_read_func read; ad5686_read_func read;
bool use_internal_vref; bool use_internal_vref;
struct mutex lock;
/* /*
* DMA (thus cache coherency maintenance) requires the * DMA (thus cache coherency maintenance) requires the
......
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