iio: imu: inv_mpu6050: add debugfs register r/w interface
The debugfs interface provides direct access to read and write device registers if debugfs is enabled. Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
792897ce41
commit
4b7ef6040f
|
@ -1248,12 +1248,31 @@ static const struct attribute_group inv_attribute_group = {
|
|||
.attrs = inv_attributes
|
||||
};
|
||||
|
||||
static int inv_mpu6050_reg_access(struct iio_dev *indio_dev,
|
||||
unsigned int reg,
|
||||
unsigned int writeval,
|
||||
unsigned int *readval)
|
||||
{
|
||||
struct inv_mpu6050_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&st->lock);
|
||||
if (readval)
|
||||
ret = regmap_read(st->map, reg, readval);
|
||||
else
|
||||
ret = regmap_write(st->map, reg, writeval);
|
||||
mutex_unlock(&st->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct iio_info mpu_info = {
|
||||
.read_raw = &inv_mpu6050_read_raw,
|
||||
.write_raw = &inv_mpu6050_write_raw,
|
||||
.write_raw_get_fmt = &inv_write_raw_get_fmt,
|
||||
.attrs = &inv_attribute_group,
|
||||
.validate_trigger = inv_mpu6050_validate_trigger,
|
||||
.debugfs_reg_access = &inv_mpu6050_reg_access,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue