Skip to content

Commit 3af0c1f

Browse files
Francesco Lavrajic23
authored andcommitted
iio: imu: st_lsm6dsx: fix array size for st_lsm6dsx_settings fields
The `decimator` and `batch` fields of struct st_lsm6dsx_settings are arrays indexed by sensor type, not by sensor hardware identifier; moreover, the `batch` field is only used for the accelerometer and gyroscope. Change the array size for `decimator` from ST_LSM6DSX_MAX_ID to ST_LSM6DSX_ID_MAX, and change the array size for `batch` from ST_LSM6DSX_MAX_ID to 2; move the enum st_lsm6dsx_sensor_id definition so that the ST_LSM6DSX_ID_MAX value is usable within the struct st_lsm6dsx_settings definition. Fixes: 801a6e0 ("iio: imu: st_lsm6dsx: add support to LSM6DSO") Signed-off-by: Francesco Lavra <flavra@baylibre.com> Acked-by: Lorenzo Bianconi <lorenzo@kernel.org> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent c92c1bc commit 3af0c1f

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,15 @@ struct st_lsm6dsx_event_settings {
252252
u8 wakeup_src_x_mask;
253253
};
254254

255+
enum st_lsm6dsx_sensor_id {
256+
ST_LSM6DSX_ID_GYRO,
257+
ST_LSM6DSX_ID_ACC,
258+
ST_LSM6DSX_ID_EXT0,
259+
ST_LSM6DSX_ID_EXT1,
260+
ST_LSM6DSX_ID_EXT2,
261+
ST_LSM6DSX_ID_MAX
262+
};
263+
255264
enum st_lsm6dsx_ext_sensor_id {
256265
ST_LSM6DSX_ID_MAGN,
257266
};
@@ -337,23 +346,14 @@ struct st_lsm6dsx_settings {
337346
struct st_lsm6dsx_odr_table_entry odr_table[2];
338347
struct st_lsm6dsx_samples_to_discard samples_to_discard[2];
339348
struct st_lsm6dsx_fs_table_entry fs_table[2];
340-
struct st_lsm6dsx_reg decimator[ST_LSM6DSX_MAX_ID];
341-
struct st_lsm6dsx_reg batch[ST_LSM6DSX_MAX_ID];
349+
struct st_lsm6dsx_reg decimator[ST_LSM6DSX_ID_MAX];
350+
struct st_lsm6dsx_reg batch[2];
342351
struct st_lsm6dsx_fifo_ops fifo_ops;
343352
struct st_lsm6dsx_hw_ts_settings ts_settings;
344353
struct st_lsm6dsx_shub_settings shub_settings;
345354
struct st_lsm6dsx_event_settings event_settings;
346355
};
347356

348-
enum st_lsm6dsx_sensor_id {
349-
ST_LSM6DSX_ID_GYRO,
350-
ST_LSM6DSX_ID_ACC,
351-
ST_LSM6DSX_ID_EXT0,
352-
ST_LSM6DSX_ID_EXT1,
353-
ST_LSM6DSX_ID_EXT2,
354-
ST_LSM6DSX_ID_MAX,
355-
};
356-
357357
enum st_lsm6dsx_fifo_mode {
358358
ST_LSM6DSX_FIFO_BYPASS = 0x0,
359359
ST_LSM6DSX_FIFO_CONT = 0x6,

0 commit comments

Comments
 (0)