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

Configure Feed

Select the types of activity you want to include in your feed.

iio: imu: st_lsm6dsx: add event spec parameter to iio_chan_spec initializer

In preparation for adding support for more event sources, add to the
ST_LSM6DSX_CHANNEL_ACC() iio_chan_spec initializer macro an iio_event_spec
array argument, so that this macro can be used with different arrays by
sensors that support different event sources; change the st_lsm6dsx_event
struct declaration to an array (renamed as st_lsm6dsx_ev_motion) so that it
can be passed to the macro (and opportunistically move it from the header
file where it does not belong to the C file where it is used).
In addition, remove from this macro the channel type parameter and
hard-code IIO_ACCEL in the macro definition, since all callers use
IIO_ACCEL as channel type argument.

Signed-off-by: Francesco Lavra <flavra@baylibre.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Francesco Lavra and committed by
Jonathan Cameron
317c9bef 855119fa

+16 -14
+4 -11
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
··· 81 81 #define ST_LSM6DSX_SHIFT_VAL(val, mask) (((val) << __ffs(mask)) & (mask)) 82 82 #define st_lsm6dsx_field_get(mask, reg) ((reg & mask) >> __ffs(mask)) 83 83 84 - #define ST_LSM6DSX_CHANNEL_ACC(chan_type, addr, mod, scan_idx) \ 84 + #define ST_LSM6DSX_CHANNEL_ACC(addr, mod, scan_idx, events) \ 85 85 { \ 86 - .type = chan_type, \ 86 + .type = IIO_ACCEL, \ 87 87 .address = addr, \ 88 88 .modified = 1, \ 89 89 .channel2 = mod, \ ··· 97 97 .storagebits = 16, \ 98 98 .endianness = IIO_LE, \ 99 99 }, \ 100 - .event_spec = &st_lsm6dsx_event, \ 100 + .event_spec = events, \ 101 + .num_event_specs = ARRAY_SIZE(events), \ 101 102 .ext_info = st_lsm6dsx_ext_info, \ 102 - .num_event_specs = 1, \ 103 103 } 104 104 105 105 #define ST_LSM6DSX_CHANNEL(chan_type, addr, mod, scan_idx) \ ··· 484 484 __le16 channels[3]; 485 485 aligned_s64 ts; 486 486 } scan[ST_LSM6DSX_ID_MAX]; 487 - }; 488 - 489 - static __maybe_unused const struct iio_event_spec st_lsm6dsx_event = { 490 - .type = IIO_EV_TYPE_THRESH, 491 - .dir = IIO_EV_DIR_EITHER, 492 - .mask_separate = BIT(IIO_EV_INFO_VALUE) | 493 - BIT(IIO_EV_INFO_ENABLE) 494 487 }; 495 488 496 489 static __maybe_unused const unsigned long st_lsm6dsx_available_scan_masks[] = {
+12 -3
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
··· 94 94 95 95 #define ST_LSM6DSX_REG_WHOAMI_ADDR 0x0f 96 96 97 + static const struct iio_event_spec st_lsm6dsx_ev_motion[] = { 98 + { 99 + .type = IIO_EV_TYPE_THRESH, 100 + .dir = IIO_EV_DIR_EITHER, 101 + .mask_separate = BIT(IIO_EV_INFO_VALUE) | 102 + BIT(IIO_EV_INFO_ENABLE), 103 + }, 104 + }; 105 + 97 106 static const struct iio_chan_spec st_lsm6dsx_acc_channels[] = { 98 - ST_LSM6DSX_CHANNEL_ACC(IIO_ACCEL, 0x28, IIO_MOD_X, 0), 99 - ST_LSM6DSX_CHANNEL_ACC(IIO_ACCEL, 0x2a, IIO_MOD_Y, 1), 100 - ST_LSM6DSX_CHANNEL_ACC(IIO_ACCEL, 0x2c, IIO_MOD_Z, 2), 107 + ST_LSM6DSX_CHANNEL_ACC(0x28, IIO_MOD_X, 0, st_lsm6dsx_ev_motion), 108 + ST_LSM6DSX_CHANNEL_ACC(0x2a, IIO_MOD_Y, 1, st_lsm6dsx_ev_motion), 109 + ST_LSM6DSX_CHANNEL_ACC(0x2c, IIO_MOD_Z, 2, st_lsm6dsx_ev_motion), 101 110 IIO_CHAN_SOFT_TIMESTAMP(3), 102 111 }; 103 112