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: rework code to check for enabled events

The enable_event field in struct st_lsm6dsx_hw does not lend itself well to
handling multiple event sources, so it will have to be modified to add
support for more event sources. As a preparatory step, remove references to
this field from code that does not deal with event management; rework the
st_lsm6dsx_check_events() function so that it returns whether any events
are currently enabled on a given sensor.

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
da6279f7 87c3e0c1

+8 -10
+8 -10
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
··· 1753 1753 } 1754 1754 1755 1755 static int 1756 - st_lsm6dsx_check_events(struct st_lsm6dsx_sensor *sensor, bool enable) 1756 + st_lsm6dsx_check_events(struct st_lsm6dsx_sensor *sensor) 1757 1757 { 1758 1758 struct st_lsm6dsx_hw *hw = sensor->hw; 1759 1759 1760 - if (sensor->id == ST_LSM6DSX_ID_GYRO || enable) 1760 + if (sensor->id != ST_LSM6DSX_ID_ACC) 1761 1761 return 0; 1762 1762 1763 1763 return hw->enable_event; ··· 1766 1766 int st_lsm6dsx_sensor_set_enable(struct st_lsm6dsx_sensor *sensor, 1767 1767 bool enable) 1768 1768 { 1769 - if (st_lsm6dsx_check_events(sensor, enable)) 1769 + if (st_lsm6dsx_check_events(sensor)) 1770 1770 return 0; 1771 1771 1772 1772 return __st_lsm6dsx_sensor_set_enable(sensor, enable); ··· 1794 1794 if (err < 0) 1795 1795 return err; 1796 1796 1797 - if (!hw->enable_event) { 1798 - err = st_lsm6dsx_sensor_set_enable(sensor, false); 1799 - if (err < 0) 1800 - return err; 1801 - } 1797 + err = st_lsm6dsx_sensor_set_enable(sensor, false); 1798 + if (err < 0) 1799 + return err; 1802 1800 1803 1801 *val = (s16)le16_to_cpu(data); 1804 1802 ··· 2750 2752 continue; 2751 2753 2752 2754 if (device_may_wakeup(dev) && 2753 - sensor->id == ST_LSM6DSX_ID_ACC && hw->enable_event) { 2755 + st_lsm6dsx_check_events(sensor)) { 2754 2756 /* Enable wake from IRQ */ 2755 2757 enable_irq_wake(hw->irq); 2756 2758 continue; ··· 2781 2783 2782 2784 sensor = iio_priv(hw->iio_devs[i]); 2783 2785 if (device_may_wakeup(dev) && 2784 - sensor->id == ST_LSM6DSX_ID_ACC && hw->enable_event) 2786 + st_lsm6dsx_check_events(sensor)) 2785 2787 disable_irq_wake(hw->irq); 2786 2788 2787 2789 if (!(hw->suspend_mask & BIT(sensor->id)))