Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: st_sensors: add debugfs register read hook

This adds a debugfs hook to read/write registers in the ST
sensors using debugfs. Proved to be awesome help when trying
to debug why IRQs do not arrive.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Linus Walleij and committed by
Jonathan Cameron
a0175b9c 8d96fc27

+30
+1
drivers/iio/accel/st_accel_core.c
··· 618 618 .attrs = &st_accel_attribute_group, 619 619 .read_raw = &st_accel_read_raw, 620 620 .write_raw = &st_accel_write_raw, 621 + .debugfs_reg_access = &st_sensors_debugfs_reg_access, 621 622 }; 622 623 623 624 #ifdef CONFIG_IIO_TRIGGER
+22
drivers/iio/common/st_sensors/st_sensors_core.c
··· 44 44 return err; 45 45 } 46 46 47 + int st_sensors_debugfs_reg_access(struct iio_dev *indio_dev, 48 + unsigned reg, unsigned writeval, 49 + unsigned *readval) 50 + { 51 + struct st_sensor_data *sdata = iio_priv(indio_dev); 52 + u8 readdata; 53 + int err; 54 + 55 + if (!readval) 56 + return sdata->tf->write_byte(&sdata->tb, sdata->dev, 57 + (u8)reg, (u8)writeval); 58 + 59 + err = sdata->tf->read_byte(&sdata->tb, sdata->dev, (u8)reg, &readdata); 60 + if (err < 0) 61 + return err; 62 + 63 + *readval = (unsigned)readdata; 64 + 65 + return 0; 66 + } 67 + EXPORT_SYMBOL(st_sensors_debugfs_reg_access); 68 + 47 69 static int st_sensors_match_odr(struct st_sensor_settings *sensor_settings, 48 70 unsigned int odr, struct st_sensor_odr_avl *odr_out) 49 71 {
+1
drivers/iio/gyro/st_gyro_core.c
··· 383 383 .attrs = &st_gyro_attribute_group, 384 384 .read_raw = &st_gyro_read_raw, 385 385 .write_raw = &st_gyro_write_raw, 386 + .debugfs_reg_access = &st_sensors_debugfs_reg_access, 386 387 }; 387 388 388 389 #ifdef CONFIG_IIO_TRIGGER
+1
drivers/iio/magnetometer/st_magn_core.c
··· 560 560 .attrs = &st_magn_attribute_group, 561 561 .read_raw = &st_magn_read_raw, 562 562 .write_raw = &st_magn_write_raw, 563 + .debugfs_reg_access = &st_sensors_debugfs_reg_access, 563 564 }; 564 565 565 566 #ifdef CONFIG_IIO_TRIGGER
+1
drivers/iio/pressure/st_pressure_core.c
··· 400 400 .attrs = &st_press_attribute_group, 401 401 .read_raw = &st_press_read_raw, 402 402 .write_raw = &st_press_write_raw, 403 + .debugfs_reg_access = &st_sensors_debugfs_reg_access, 403 404 }; 404 405 405 406 #ifdef CONFIG_IIO_TRIGGER
+4
include/linux/iio/common/st_sensors.h
··· 271 271 272 272 void st_sensors_power_disable(struct iio_dev *indio_dev); 273 273 274 + int st_sensors_debugfs_reg_access(struct iio_dev *indio_dev, 275 + unsigned reg, unsigned writeval, 276 + unsigned *readval); 277 + 274 278 int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr); 275 279 276 280 int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable);