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: remove event_threshold field from hw struct

This field is used to store the wakeup event detection threshold value.
When adding support for more event types, some of which may have different
threshold values for different axes, storing all threshold values for all
event sources would be cumbersome. Thus, remove this field altogether, and
read the currently configured value from the sensor when requested by
userspace.

Signed-off-by: Francesco Lavra <flavra@baylibre.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Francesco Lavra and committed by
Jonathan Cameron
b008b1ff da6279f7

+10 -5
+1 -2
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
··· 79 79 #define ST_LSM6DSX_MAX_TAGGED_WORD_LEN ((32 / ST_LSM6DSX_TAGGED_SAMPLE_SIZE) \ 80 80 * ST_LSM6DSX_TAGGED_SAMPLE_SIZE) 81 81 #define ST_LSM6DSX_SHIFT_VAL(val, mask) (((val) << __ffs(mask)) & (mask)) 82 + #define st_lsm6dsx_field_get(mask, reg) ((reg & mask) >> __ffs(mask)) 82 83 83 84 #define ST_LSM6DSX_CHANNEL_ACC(chan_type, addr, mod, scan_idx) \ 84 85 { \ ··· 440 439 * @sip: Total number of samples (acc/gyro/ts) in a given pattern. 441 440 * @buff: Device read buffer. 442 441 * @irq_routing: pointer to interrupt routing configuration. 443 - * @event_threshold: wakeup event threshold. 444 442 * @enable_event: enabled event bitmask. 445 443 * @iio_devs: Pointers to acc/gyro iio_dev instances. 446 444 * @settings: Pointer to the specific sensor settings in use. ··· 463 463 u8 sip; 464 464 465 465 u8 irq_routing; 466 - u8 event_threshold; 467 466 u8 enable_event; 468 467 469 468 u8 *buff;
+9 -3
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
··· 1908 1908 { 1909 1909 struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); 1910 1910 struct st_lsm6dsx_hw *hw = sensor->hw; 1911 + const struct st_lsm6dsx_reg *reg; 1912 + u8 data; 1913 + int err; 1911 1914 1912 1915 if (type != IIO_EV_TYPE_THRESH) 1913 1916 return -EINVAL; 1914 1917 1918 + reg = &hw->settings->event_settings.sources[ST_LSM6DSX_EVENT_WAKEUP].value; 1919 + err = st_lsm6dsx_read_locked(hw, reg->addr, &data, sizeof(data)); 1920 + if (err < 0) 1921 + return err; 1922 + 1915 1923 *val2 = 0; 1916 - *val = hw->event_threshold; 1924 + *val = st_lsm6dsx_field_get(reg->mask, data); 1917 1925 1918 1926 return IIO_VAL_INT; 1919 1927 } ··· 1952 1944 reg->mask, data); 1953 1945 if (err < 0) 1954 1946 return -EINVAL; 1955 - 1956 - hw->event_threshold = val; 1957 1947 1958 1948 return 0; 1959 1949 }