#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/iio/iio.h>
int val2,
long mask)
{
+ struct itg3200 *st = iio_priv(indio_dev);
int ret;
u8 t;
if (val == 0 || val2 != 0)
return -EINVAL;
- mutex_lock(&indio_dev->mlock);
+ mutex_lock(&st->lock);
ret = itg3200_read_reg_8(indio_dev, ITG3200_REG_DLPF, &t);
if (ret) {
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&st->lock);
return ret;
}
t = ((t & ITG3200_DLPF_CFG_MASK) ? 1000u : 8000u) / val - 1;
ITG3200_REG_SAMPLE_RATE_DIV,
t);
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&st->lock);
return ret;
default:
if (ret)
goto error_remove_trigger;
+ mutex_init(&st->lock);
+
ret = iio_device_register(indio_dev);
if (ret)
goto error_remove_trigger;
struct i2c_client *i2c;
struct iio_trigger *trig;
struct iio_mount_matrix orientation;
+ /* lock to protect against multiple access to the device */
+ struct mutex lock;
};
enum ITG3200_SCAN_INDEX {