Commit 399b883ec828 ("iio: imu: bno055: fix OOB access of hw_xlate array") also reversed the hw_xlate table of the gyroscope scale. bno055_gyr_scale_vals[] runs from 125 to 2000 dps, which the chip encodes as 4 to 0 (datasheet, Table 3-9 "Gyroscope configurations"). With fusion off, in_anglvel_scale now reports and selects the ranges in reverse order. Restore the order. Fixes: 399b883ec828 ("iio: imu: bno055: fix OOB access of hw_xlate array") Cc: stable@vger.kernel.org Signed-off-by: Maoyi Xie --- Noticed during an LLM-assisted review of the hw_xlate lookup check [1]. Reproduced in a userspace harness. Not tested on hardware. I used an LLM to help write the harness and this patch. [1] https://lore.kernel.org/linux-iio/20261123135554.2983499-3-maoyixie.tju@gmail.com/ drivers/iio/imu/bno055/bno055.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/imu/bno055/bno055.c b/drivers/iio/imu/bno055/bno055.c index b1c7b4f88bf10e7e0477a1d424bbb4815f59c6a9..50543ac35f044c18b6734224dba94286e6292c76 100644 --- a/drivers/iio/imu/bno055/bno055.c +++ b/drivers/iio/imu/bno055/bno055.c @@ -171,7 +171,7 @@ static const int bno055_gyr_scale_vals[] = { 1000, 1877467, 2000, 1877467, }; -static const int bno055_gyr_scale_hw_xlate[] = {0, 1, 2, 3, 4}; +static const int bno055_gyr_scale_hw_xlate[] = {4, 3, 2, 1, 0}; static const struct bno055_sysfs_attr bno055_gyr_scale = { .vals = bno055_gyr_scale_vals, .len = ARRAY_SIZE(bno055_gyr_scale_vals), -- 2.34.1