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

iio: dac: ad5764: 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 19710bff
...@@ -46,6 +46,7 @@ struct ad5764_chip_info { ...@@ -46,6 +46,7 @@ struct ad5764_chip_info {
* @spi: spi_device * @spi: spi_device
* @chip_info: chip info * @chip_info: chip info
* @vref_reg: vref supply regulators * @vref_reg: vref supply regulators
* @lock lock to protect the data buffer during SPI ops
* @data: spi transfer buffers * @data: spi transfer buffers
*/ */
...@@ -53,6 +54,7 @@ struct ad5764_state { ...@@ -53,6 +54,7 @@ struct ad5764_state {
struct spi_device *spi; struct spi_device *spi;
const struct ad5764_chip_info *chip_info; const struct ad5764_chip_info *chip_info;
struct regulator_bulk_data vref_reg[2]; struct regulator_bulk_data vref_reg[2];
struct mutex lock;
/* /*
* DMA (thus cache coherency maintenance) requires the * DMA (thus cache coherency maintenance) requires the
...@@ -126,11 +128,11 @@ static int ad5764_write(struct iio_dev *indio_dev, unsigned int reg, ...@@ -126,11 +128,11 @@ static int ad5764_write(struct iio_dev *indio_dev, unsigned int reg,
struct ad5764_state *st = iio_priv(indio_dev); struct ad5764_state *st = iio_priv(indio_dev);
int ret; int ret;
mutex_lock(&indio_dev->mlock); mutex_lock(&st->lock);
st->data[0].d32 = cpu_to_be32((reg << 16) | val); st->data[0].d32 = cpu_to_be32((reg << 16) | val);
ret = spi_write(st->spi, &st->data[0].d8[1], 3); ret = spi_write(st->spi, &st->data[0].d8[1], 3);
mutex_unlock(&indio_dev->mlock); mutex_unlock(&st->lock);
return ret; return ret;
} }
...@@ -151,7 +153,7 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg, ...@@ -151,7 +153,7 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg,
}, },
}; };
mutex_lock(&indio_dev->mlock); mutex_lock(&st->lock);
st->data[0].d32 = cpu_to_be32((1 << 23) | (reg << 16)); st->data[0].d32 = cpu_to_be32((1 << 23) | (reg << 16));
...@@ -159,7 +161,7 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg, ...@@ -159,7 +161,7 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg,
if (ret >= 0) if (ret >= 0)
*val = be32_to_cpu(st->data[1].d32) & 0xffff; *val = be32_to_cpu(st->data[1].d32) & 0xffff;
mutex_unlock(&indio_dev->mlock); mutex_unlock(&st->lock);
return ret; return ret;
} }
...@@ -295,6 +297,8 @@ static int ad5764_probe(struct spi_device *spi) ...@@ -295,6 +297,8 @@ static int ad5764_probe(struct spi_device *spi)
indio_dev->num_channels = AD5764_NUM_CHANNELS; indio_dev->num_channels = AD5764_NUM_CHANNELS;
indio_dev->channels = st->chip_info->channels; indio_dev->channels = st->chip_info->channels;
mutex_init(&st->lock);
if (st->chip_info->int_vref == 0) { if (st->chip_info->int_vref == 0) {
st->vref_reg[0].supply = "vrefAB"; st->vref_reg[0].supply = "vrefAB";
st->vref_reg[1].supply = "vrefCD"; st->vref_reg[1].supply = "vrefCD";
......
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