Skip to content

Commit 0b2884e

Browse files
scuciureanjic23
authored andcommitted
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: Sergiu Cuciurean <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 9bc1789 commit 0b2884e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

drivers/iio/dac/ad5686.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
127127

128128
switch (m) {
129129
case IIO_CHAN_INFO_RAW:
130-
mutex_lock(&indio_dev->mlock);
130+
mutex_lock(&st->lock);
131131
ret = st->read(st, chan->address);
132-
mutex_unlock(&indio_dev->mlock);
132+
mutex_unlock(&st->lock);
133133
if (ret < 0)
134134
return ret;
135135
*val = (ret >> chan->scan_type.shift) &
@@ -157,12 +157,12 @@ static int ad5686_write_raw(struct iio_dev *indio_dev,
157157
if (val > (1 << chan->scan_type.realbits) || val < 0)
158158
return -EINVAL;
159159

160-
mutex_lock(&indio_dev->mlock);
160+
mutex_lock(&st->lock);
161161
ret = st->write(st,
162162
AD5686_CMD_WRITE_INPUT_N_UPDATE_N,
163163
chan->address,
164164
val << chan->scan_type.shift);
165-
mutex_unlock(&indio_dev->mlock);
165+
mutex_unlock(&st->lock);
166166
break;
167167
default:
168168
ret = -EINVAL;
@@ -468,6 +468,8 @@ int ad5686_probe(struct device *dev,
468468
indio_dev->channels = st->chip_info->channels;
469469
indio_dev->num_channels = st->chip_info->num_channels;
470470

471+
mutex_init(&st->lock);
472+
471473
switch (st->chip_info->regmap_type) {
472474
case AD5310_REGMAP:
473475
cmd = AD5686_CMD_CONTROL_REG;

drivers/iio/dac/ad5686.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct ad5686_chip_info {
117117
* @pwr_down_mask: power down mask
118118
* @pwr_down_mode: current power down mode
119119
* @use_internal_vref: set to true if the internal reference voltage is used
120+
* @lock lock to protect the data buffer during regmap ops
120121
* @data: spi transfer buffers
121122
*/
122123

@@ -130,6 +131,7 @@ struct ad5686_state {
130131
ad5686_write_func write;
131132
ad5686_read_func read;
132133
bool use_internal_vref;
134+
struct mutex lock;
133135

134136
/*
135137
* DMA (thus cache coherency maintenance) requires the

0 commit comments

Comments
 (0)