iio: imu: inv_mpu6050: add debugfs register r/w interface
Subsystems (2)
PATCH v2 1/1 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.
---
Changelog v1->v2
* grab a lock to protect driver state
* add a comma at the end of structure member initialisation
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +19 -0
@@ -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 =0 ; + +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, };/**
Signature · 1 line
2.23.0.385.gbc12974a89
Quoted 18 lines · Rohit Sarkar
The debugfs interface provides direct access to read and write device registers if debugfs is enabled.
Signed-off-by Rohit Sarkar <[email protected]>---
Changelogv1->v2
* grab a lock to protect driver state
* add a comma at the end of structure member initialisationdrivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +0
-0@@ -1248,12 +1248,31 @@ static const struct attribute_group inv_attribute_group = { .attrs = inv_attributes
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c static const struct attribute_group inv_attribute_group = { · line 1258
Quoted 10 lines
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +7
-0}; +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 =0 ;
Assignment is redundant, but I think maintainers may update this when applying.
Quoted 24 lines
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +12
-0+ +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, };/**
Signature · 1 line
2.23.0.385.gbc12974a89
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerQuoted 28 lines · On Fri, 27 Mar 2020 15:19:01 +0200 Andy Shevchenko…
Quoted 26 lines · Rohit Sarkar
The debugfs interface provides direct access to read and write device registers if debugfs is enabled.
Signed-off-by Rohit Sarkar <[email protected]>---
Changelogv1->v2
* grab a lock to protect driver state
* add a comma at the end of structure member initialisationdrivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +6
-0@@ -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);
Quoted 3 lines
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c static const struct attribute_group inv_attribute_group = { · line 1257
Quoted 1 line
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +1
-0+int ret =0 ;Assignment is redundant, but I think maintainers may update this when applying.
Fixed up and applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Jonathan
Quoted 26 lines
Quoted 25 lines
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +12
-0+ +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, };/** Signature · 1 line
2.23.0.385.gbc12974a89
Quoted 2 lines · Rohit Sarkar
The debugfs interface provides direct access to read and write device registers if debugfs is enabled.
FWIW,
Quoted 48 lines
Signed-off-by Rohit Sarkar <[email protected]>---
Changelogv1->v2
* grab a lock to protect driver state
* add a comma at the end of structure member initialisationdrivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +19
-0@@ -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 =0 ; + +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, };/** Signature · 1 line
2.23.0.385.gbc12974a89
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hello,
thanks, it's OK for me.
Best regards,
JB
From: Rohit Sarkar <[email protected]>
Sent: Friday, March 27, 2020 14:10
To: [email protected] <[email protected]>
Cc: Jonathan Cameron <[email protected]>; Hartmut Knaack <[email protected]>; Lars-Peter Clausen <[email protected]>; Peter Meerwald-Stadler <[email protected]>; Jean-Baptiste Maneyrol <[email protected]>; Linus Walleij <[email protected]>;
Andy Shevchenko <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Subject: [PATCH v2] iio: imu: inv_mpu6050: add debugfs register r/w interface
CAUTION: This email originated from outside of the organization. Please make sure the sender is who they say they are and do not click links or open attachments unless you recognize the sender and know the content is safe.
The debugfs interface provides direct access to read and write device
registers if debugfs is enabled.
---
Changelog v1->v2
* grab a lock to protect driver state
* add a comma at the end of structure member initialisation
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +0 -0
index 7cb9ff3d3e94..381a3fb09858 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -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 = 0;
+
+ 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,
};
/**
Signature · 1 line
2.23.0.385.gbc12974a89