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: bno055: fix BNO055_SCAN_CH_COUNT off by one

Fix an off-by-one error in the BNO055_SCAN_CH_COUNT macro. The count
is derived by taking the difference of the last and first register
addresses, dividing by the size of each channel (2 bytes). It needs to
also add 1 to account for the fact that the count is inclusive of both
the first and last channels.

Thanks to the aligned_s64 timestamp field, there was already extra
padding in the buffer, so there were no runtime issues caused by this
bug.

Fixes: 4aefe1c2bd0c ("iio: imu: add Bosch Sensortec BNO055 core driver")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
773ef9f9 c47ac75f

+1 -1
+1 -1
drivers/iio/imu/bno055/bno055.c
··· 64 64 #define BNO055_GRAVITY_DATA_X_LSB_REG 0x2E 65 65 #define BNO055_GRAVITY_DATA_Y_LSB_REG 0x30 66 66 #define BNO055_GRAVITY_DATA_Z_LSB_REG 0x32 67 - #define BNO055_SCAN_CH_COUNT ((BNO055_GRAVITY_DATA_Z_LSB_REG - BNO055_ACC_DATA_X_LSB_REG) / 2) 67 + #define BNO055_SCAN_CH_COUNT ((BNO055_GRAVITY_DATA_Z_LSB_REG - BNO055_ACC_DATA_X_LSB_REG) / 2 + 1) 68 68 #define BNO055_TEMP_REG 0x34 69 69 #define BNO055_CALIB_STAT_REG 0x35 70 70 #define BNO055_CALIB_STAT_MAGN_SHIFT 0