Commit 9854a1b5 authored by Aishwarya Pant's avatar Aishwarya Pant Committed by Jonathan Cameron

staging:iio:cdc:ade7746 replace mlock with driver private lock

The IIO subsystem is redefining iio_dev mlock to be used by IIO core
only for protecting device operating mode changes.

In driver ad7746 wherever mlock was used to protect hardware state
changes, it has been replaced with a driver private lock.
Signed-off-by: default avatarAishwarya Pant <aishpant@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 0bdd35bd
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
struct ad7746_chip_info { struct ad7746_chip_info {
struct i2c_client *client; struct i2c_client *client;
struct mutex lock; /* protect sensor state */
/* /*
* Capacitive channel digital filter setup; * Capacitive channel digital filter setup;
* conversion time/update rate setup per channel * conversion time/update rate setup per channel
...@@ -298,11 +299,11 @@ static inline ssize_t ad7746_start_calib(struct device *dev, ...@@ -298,11 +299,11 @@ static inline ssize_t ad7746_start_calib(struct device *dev,
if (!doit) if (!doit)
return 0; return 0;
mutex_lock(&indio_dev->mlock); mutex_lock(&chip->lock);
regval |= chip->config; regval |= chip->config;
ret = i2c_smbus_write_byte_data(chip->client, AD7746_REG_CFG, regval); ret = i2c_smbus_write_byte_data(chip->client, AD7746_REG_CFG, regval);
if (ret < 0) { if (ret < 0) {
mutex_unlock(&indio_dev->mlock); mutex_unlock(&chip->lock);
return ret; return ret;
} }
...@@ -310,12 +311,12 @@ static inline ssize_t ad7746_start_calib(struct device *dev, ...@@ -310,12 +311,12 @@ static inline ssize_t ad7746_start_calib(struct device *dev,
msleep(20); msleep(20);
ret = i2c_smbus_read_byte_data(chip->client, AD7746_REG_CFG); ret = i2c_smbus_read_byte_data(chip->client, AD7746_REG_CFG);
if (ret < 0) { if (ret < 0) {
mutex_unlock(&indio_dev->mlock); mutex_unlock(&chip->lock);
return ret; return ret;
} }
} while ((ret == regval) && timeout--); } while ((ret == regval) && timeout--);
mutex_unlock(&indio_dev->mlock); mutex_unlock(&chip->lock);
return len; return len;
} }
...@@ -426,7 +427,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev, ...@@ -426,7 +427,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev,
struct ad7746_chip_info *chip = iio_priv(indio_dev); struct ad7746_chip_info *chip = iio_priv(indio_dev);
int ret, reg; int ret, reg;
mutex_lock(&indio_dev->mlock); mutex_lock(&chip->lock);
switch (mask) { switch (mask) {
case IIO_CHAN_INFO_CALIBSCALE: case IIO_CHAN_INFO_CALIBSCALE:
...@@ -521,7 +522,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev, ...@@ -521,7 +522,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev,
} }
out: out:
mutex_unlock(&indio_dev->mlock); mutex_unlock(&chip->lock);
return ret; return ret;
} }
...@@ -534,7 +535,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev, ...@@ -534,7 +535,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
int ret, delay, idx; int ret, delay, idx;
u8 regval, reg; u8 regval, reg;
mutex_lock(&indio_dev->mlock); mutex_lock(&chip->lock);
switch (mask) { switch (mask) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
...@@ -658,7 +659,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev, ...@@ -658,7 +659,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
ret = -EINVAL; ret = -EINVAL;
} }
out: out:
mutex_unlock(&indio_dev->mlock); mutex_unlock(&chip->lock);
return ret; return ret;
} }
...@@ -686,6 +687,7 @@ static int ad7746_probe(struct i2c_client *client, ...@@ -686,6 +687,7 @@ static int ad7746_probe(struct i2c_client *client,
if (!indio_dev) if (!indio_dev)
return -ENOMEM; return -ENOMEM;
chip = iio_priv(indio_dev); chip = iio_priv(indio_dev);
mutex_init(&chip->lock);
/* this is only used for device removal purposes */ /* this is only used for device removal purposes */
i2c_set_clientdata(client, indio_dev); i2c_set_clientdata(client, indio_dev);
......
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