struct ad7746_chip_info {
struct i2c_client *client;
+ struct mutex lock; /* protect sensor state */
/*
* Capacitive channel digital filter setup;
* conversion time/update rate setup per channel
if (!doit)
return 0;
- mutex_lock(&indio_dev->mlock);
+ mutex_lock(&chip->lock);
regval |= chip->config;
ret = i2c_smbus_write_byte_data(chip->client, AD7746_REG_CFG, regval);
if (ret < 0) {
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&chip->lock);
return ret;
}
msleep(20);
ret = i2c_smbus_read_byte_data(chip->client, AD7746_REG_CFG);
if (ret < 0) {
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&chip->lock);
return ret;
}
} while ((ret == regval) && timeout--);
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&chip->lock);
return len;
}
struct ad7746_chip_info *chip = iio_priv(indio_dev);
int ret, reg;
- mutex_lock(&indio_dev->mlock);
+ mutex_lock(&chip->lock);
switch (mask) {
case IIO_CHAN_INFO_CALIBSCALE:
}
out:
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&chip->lock);
return ret;
}
int ret, delay, idx;
u8 regval, reg;
- mutex_lock(&indio_dev->mlock);
+ mutex_lock(&chip->lock);
switch (mask) {
case IIO_CHAN_INFO_RAW:
ret = -EINVAL;
}
out:
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&chip->lock);
return ret;
}
if (!indio_dev)
return -ENOMEM;
chip = iio_priv(indio_dev);
+ mutex_init(&chip->lock);
/* this is only used for device removal purposes */
i2c_set_clientdata(client, indio_dev);