mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-24 01:41:39 +00:00
iio: imu: st_lsm6dsx: introduce st_lsm6dsx_device_set_enable routine
Introduce st_lsm6dsx_device_set_enable utility routine and remove duplicated code used to enable/disable sensors Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://lore.kernel.org/r/e3fbe5d4a3bed41130908669f745f78c8505cf47.1665399959.git.lorenzo@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
c1404d1b65
commit
cd83c5c100
3 changed files with 16 additions and 23 deletions
|
@ -509,6 +509,17 @@ st_lsm6dsx_get_mount_matrix(const struct iio_dev *iio_dev,
|
|||
return &hw->orientation;
|
||||
}
|
||||
|
||||
static inline int
|
||||
st_lsm6dsx_device_set_enable(struct st_lsm6dsx_sensor *sensor, bool enable)
|
||||
{
|
||||
if (sensor->id == ST_LSM6DSX_ID_EXT0 ||
|
||||
sensor->id == ST_LSM6DSX_ID_EXT1 ||
|
||||
sensor->id == ST_LSM6DSX_ID_EXT2)
|
||||
return st_lsm6dsx_shub_set_enable(sensor, enable);
|
||||
|
||||
return st_lsm6dsx_sensor_set_enable(sensor, enable);
|
||||
}
|
||||
|
||||
static const
|
||||
struct iio_chan_spec_ext_info __maybe_unused st_lsm6dsx_accel_ext_info[] = {
|
||||
IIO_MOUNT_MATRIX(IIO_SHARED_BY_ALL, st_lsm6dsx_get_mount_matrix),
|
||||
|
|
|
@ -673,17 +673,9 @@ int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (sensor->id == ST_LSM6DSX_ID_EXT0 ||
|
||||
sensor->id == ST_LSM6DSX_ID_EXT1 ||
|
||||
sensor->id == ST_LSM6DSX_ID_EXT2) {
|
||||
err = st_lsm6dsx_shub_set_enable(sensor, enable);
|
||||
if (err < 0)
|
||||
goto out;
|
||||
} else {
|
||||
err = st_lsm6dsx_sensor_set_enable(sensor, enable);
|
||||
if (err < 0)
|
||||
goto out;
|
||||
}
|
||||
err = st_lsm6dsx_device_set_enable(sensor, enable);
|
||||
if (err < 0)
|
||||
goto out;
|
||||
|
||||
err = st_lsm6dsx_set_fifo_odr(sensor, enable);
|
||||
if (err < 0)
|
||||
|
|
|
@ -2317,12 +2317,7 @@ static int st_lsm6dsx_suspend(struct device *dev)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (sensor->id == ST_LSM6DSX_ID_EXT0 ||
|
||||
sensor->id == ST_LSM6DSX_ID_EXT1 ||
|
||||
sensor->id == ST_LSM6DSX_ID_EXT2)
|
||||
err = st_lsm6dsx_shub_set_enable(sensor, false);
|
||||
else
|
||||
err = st_lsm6dsx_sensor_set_enable(sensor, false);
|
||||
err = st_lsm6dsx_device_set_enable(sensor, false);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
|
@ -2353,12 +2348,7 @@ static int st_lsm6dsx_resume(struct device *dev)
|
|||
if (!(hw->suspend_mask & BIT(sensor->id)))
|
||||
continue;
|
||||
|
||||
if (sensor->id == ST_LSM6DSX_ID_EXT0 ||
|
||||
sensor->id == ST_LSM6DSX_ID_EXT1 ||
|
||||
sensor->id == ST_LSM6DSX_ID_EXT2)
|
||||
err = st_lsm6dsx_shub_set_enable(sensor, true);
|
||||
else
|
||||
err = st_lsm6dsx_sensor_set_enable(sensor, true);
|
||||
err = st_lsm6dsx_device_set_enable(sensor, true);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
|
|
Loading…
Reference in a new issue