[PATCH v4 18/19] iio: accel: bma220: add debugfs reg access

Petre Rodan
2025-10-05T13:13:13Z

Allow read/write access to sensor registers for use in unit-tests.

Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
---
v1->v4 no change
---
drivers/iio/accel/bma220_core.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/drivers/iio/accel/bma220_core.c b/drivers/iio/accel/bma220_core.c
index 7109759e28397d2660f17707124a8803a254cb14..0d6c301b1c47a04cfca5bae157f8ce6144f0b854 100644
--- a/drivers/iio/accel/bma220_core.c
+++ b/drivers/iio/accel/bma220_core.c
@@ -375,10 +375,21 @@ static int bma220_read_avail(struct iio_dev *indio_dev,
}
}

+static int bma220_reg_access(struct iio_dev *indio_dev, unsigned int reg,
+ unsigned int writeval, unsigned int *readval)
+{
+ struct bma220_data *data = iio_priv(indio_dev);
+
+ if (readval)
+ return regmap_read(data->regmap, reg, readval);
+ return regmap_write(data->regmap, reg, writeval);
+}
+
static const struct iio_info bma220_info = {
.read_raw = bma220_read_raw,
.write_raw = bma220_write_raw,
.read_avail = bma220_read_avail,
+ .debugfs_reg_access = &bma220_reg_access,
};

static int bma220_reset(struct bma220_data *data, bool up)

--
2.49.1