Skip to content

Commit fa444a1

Browse files
scuciureanjic23
authored andcommitted
iio: dac: ad5380: 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 fdd4166 commit fa444a1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/iio/dac/ad5380.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct ad5380_chip_info {
5151
* @vref_reg: vref supply regulator
5252
* @vref: actual reference voltage used in uA
5353
* @pwr_down: whether the chip is currently in power down mode
54+
* @lock lock to protect the data buffer during regmap ops
5455
*/
5556

5657
struct ad5380_state {
@@ -59,6 +60,7 @@ struct ad5380_state {
5960
struct regulator *vref_reg;
6061
int vref;
6162
bool pwr_down;
63+
struct mutex lock;
6264
};
6365

6466
enum ad5380_type {
@@ -98,7 +100,7 @@ static ssize_t ad5380_write_dac_powerdown(struct iio_dev *indio_dev,
98100
if (ret)
99101
return ret;
100102

101-
mutex_lock(&indio_dev->mlock);
103+
mutex_lock(&st->lock);
102104

103105
if (pwr_down)
104106
ret = regmap_write(st->regmap, AD5380_REG_SF_PWR_DOWN, 0);
@@ -107,7 +109,7 @@ static ssize_t ad5380_write_dac_powerdown(struct iio_dev *indio_dev,
107109

108110
st->pwr_down = pwr_down;
109111

110-
mutex_unlock(&indio_dev->mlock);
112+
mutex_unlock(&st->lock);
111113

112114
return ret ? ret : len;
113115
}
@@ -390,6 +392,8 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
390392
indio_dev->modes = INDIO_DIRECT_MODE;
391393
indio_dev->num_channels = st->chip_info->num_channels;
392394

395+
mutex_init(&st->lock);
396+
393397
ret = ad5380_alloc_channels(indio_dev);
394398
if (ret) {
395399
dev_err(dev, "Failed to allocate channel spec: %d\n", ret);

0 commit comments

Comments
 (0)