Commit fa444a18 authored by Sergiu Cuciurean's avatar Sergiu Cuciurean Committed by Jonathan Cameron

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: default avatarSergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent fdd41663
...@@ -51,6 +51,7 @@ struct ad5380_chip_info { ...@@ -51,6 +51,7 @@ struct ad5380_chip_info {
* @vref_reg: vref supply regulator * @vref_reg: vref supply regulator
* @vref: actual reference voltage used in uA * @vref: actual reference voltage used in uA
* @pwr_down: whether the chip is currently in power down mode * @pwr_down: whether the chip is currently in power down mode
* @lock lock to protect the data buffer during regmap ops
*/ */
struct ad5380_state { struct ad5380_state {
...@@ -59,6 +60,7 @@ struct ad5380_state { ...@@ -59,6 +60,7 @@ struct ad5380_state {
struct regulator *vref_reg; struct regulator *vref_reg;
int vref; int vref;
bool pwr_down; bool pwr_down;
struct mutex lock;
}; };
enum ad5380_type { enum ad5380_type {
...@@ -98,7 +100,7 @@ static ssize_t ad5380_write_dac_powerdown(struct iio_dev *indio_dev, ...@@ -98,7 +100,7 @@ static ssize_t ad5380_write_dac_powerdown(struct iio_dev *indio_dev,
if (ret) if (ret)
return ret; return ret;
mutex_lock(&indio_dev->mlock); mutex_lock(&st->lock);
if (pwr_down) if (pwr_down)
ret = regmap_write(st->regmap, AD5380_REG_SF_PWR_DOWN, 0); 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, ...@@ -107,7 +109,7 @@ static ssize_t ad5380_write_dac_powerdown(struct iio_dev *indio_dev,
st->pwr_down = pwr_down; st->pwr_down = pwr_down;
mutex_unlock(&indio_dev->mlock); mutex_unlock(&st->lock);
return ret ? ret : len; return ret ? ret : len;
} }
...@@ -390,6 +392,8 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap, ...@@ -390,6 +392,8 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->num_channels = st->chip_info->num_channels; indio_dev->num_channels = st->chip_info->num_channels;
mutex_init(&st->lock);
ret = ad5380_alloc_channels(indio_dev); ret = ad5380_alloc_channels(indio_dev);
if (ret) { if (ret) {
dev_err(dev, "Failed to allocate channel spec: %d\n", ret); dev_err(dev, "Failed to allocate channel spec: %d\n", ret);
......
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