* [PATCH] iio: imu: inv_mpu6050: add debugfs register r/w interface
@ 2020-03-19 6:07 Rohit Sarkar
2020-03-19 10:24 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Rohit Sarkar @ 2020-03-19 6:07 UTC (permalink / raw)
To: linux-iio, linux-kernel
Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
Peter Meerwald-Stadler, Jean-Baptiste Maneyrol, Andy Shevchenko,
Linus Walleij, linux-iio, linux-kernel
The iio debugfs interface provides direct access to read and write device
registers if debugfs is enabled.
Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 7cb9ff3d3e94..3f40db8ea9e2 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -1248,12 +1248,26 @@ 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);
+
+ if (readval)
+ return regmap_read(st->map, reg, readval);
+ else
+ return regmap_write(st->map, reg, writeval);
+}
+
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
};
/**
--
2.23.0.385.gbc12974a89
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] iio: imu: inv_mpu6050: add debugfs register r/w interface
2020-03-19 6:07 [PATCH] iio: imu: inv_mpu6050: add debugfs register r/w interface Rohit Sarkar
@ 2020-03-19 10:24 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2020-03-19 10:24 UTC (permalink / raw)
To: Rohit Sarkar
Cc: linux-iio, Linux Kernel Mailing List, Jonathan Cameron,
Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
Jean-Baptiste Maneyrol, Andy Shevchenko, Linus Walleij
On Thu, Mar 19, 2020 at 8:10 AM Rohit Sarkar <rohitsarkar5398@gmail.com> wrote:
>
> The iio debugfs interface provides direct access to read and write device
> registers if debugfs is enabled.
But regmap API provides at least reading facility. Isn't it enough?
...
> 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
Leaving comma is helpful for future development.
> };
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-03-19 10:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 6:07 [PATCH] iio: imu: inv_mpu6050: add debugfs register r/w interface Rohit Sarkar
2020-03-19 10:24 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome