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

iio: imu: st_lsm6dsx: add mount matrix support

Allow to read the mount-matrix device tree property and provide the
mount_matrix file for userspace to read.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Martin Kepplinger and committed by
Jonathan Cameron
04e6fedb 622b4339

+23
+19
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
··· 76 76 .endianness = IIO_LE, \ 77 77 }, \ 78 78 .event_spec = &st_lsm6dsx_event, \ 79 + .ext_info = st_lsm6dsx_accel_ext_info, \ 79 80 .num_event_specs = 1, \ 80 81 } 81 82 ··· 379 378 * @enable_event: enabled event bitmask. 380 379 * @iio_devs: Pointers to acc/gyro iio_dev instances. 381 380 * @settings: Pointer to the specific sensor settings in use. 381 + * @orientation: sensor chip orientation relative to main hardware. 382 382 */ 383 383 struct st_lsm6dsx_hw { 384 384 struct device *dev; ··· 406 404 struct iio_dev *iio_devs[ST_LSM6DSX_ID_MAX]; 407 405 408 406 const struct st_lsm6dsx_settings *settings; 407 + 408 + struct iio_mount_matrix orientation; 409 409 }; 410 410 411 411 static __maybe_unused const struct iio_event_spec st_lsm6dsx_event = { ··· 480 476 481 477 return err; 482 478 } 479 + 480 + static const inline struct iio_mount_matrix * 481 + st_lsm6dsx_get_mount_matrix(const struct iio_dev *iio_dev, 482 + const struct iio_chan_spec *chan) 483 + { 484 + struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); 485 + struct st_lsm6dsx_hw *hw = sensor->hw; 486 + 487 + return &hw->orientation; 488 + } 489 + 490 + static const struct iio_chan_spec_ext_info st_lsm6dsx_accel_ext_info[] = { 491 + IIO_MOUNT_MATRIX(IIO_SHARED_BY_ALL, st_lsm6dsx_get_mount_matrix), 492 + { } 493 + }; 483 494 484 495 #endif /* ST_LSM6DSX_H */
+4
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
··· 2337 2337 return err; 2338 2338 } 2339 2339 2340 + err = iio_read_mount_matrix(hw->dev, "mount-matrix", &hw->orientation); 2341 + if (err) 2342 + return err; 2343 + 2340 2344 for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { 2341 2345 if (!hw->iio_devs[i]) 2342 2346 continue;