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: bmi160: Fix time needed to sleep after command execution

Datasheet specifies typical and maximum execution times for which CMD
register is occupied after previous command execution. We took these
values as minimum and maximum time for usleep_range() call before making
a new command execution.

To be sure, that the CMD register is no longer occupied we need to wait
*at least* the maximum time specified by datasheet.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Marcin Niestroj and committed by
Jonathan Cameron
01d1f7a9 e91c3dfc

+6 -19
+6 -19
drivers/iio/imu/bmi160/bmi160_core.c
··· 66 66 67 67 #define BMI160_REG_DUMMY 0x7F 68 68 69 - #define BMI160_ACCEL_PMU_MIN_USLEEP 3200 70 - #define BMI160_ACCEL_PMU_MAX_USLEEP 3800 71 - #define BMI160_GYRO_PMU_MIN_USLEEP 55000 72 - #define BMI160_GYRO_PMU_MAX_USLEEP 80000 69 + #define BMI160_ACCEL_PMU_MIN_USLEEP 3800 70 + #define BMI160_GYRO_PMU_MIN_USLEEP 80000 73 71 #define BMI160_SOFTRESET_USLEEP 1000 74 72 75 73 #define BMI160_CHANNEL(_type, _axis, _index) { \ ··· 149 151 }, 150 152 }; 151 153 152 - struct bmi160_pmu_time { 153 - unsigned long min; 154 - unsigned long max; 155 - }; 156 - 157 - static struct bmi160_pmu_time bmi160_pmu_time[] = { 158 - [BMI160_ACCEL] = { 159 - .min = BMI160_ACCEL_PMU_MIN_USLEEP, 160 - .max = BMI160_ACCEL_PMU_MAX_USLEEP 161 - }, 162 - [BMI160_GYRO] = { 163 - .min = BMI160_GYRO_PMU_MIN_USLEEP, 164 - .max = BMI160_GYRO_PMU_MIN_USLEEP, 165 - }, 154 + static unsigned long bmi160_pmu_time[] = { 155 + [BMI160_ACCEL] = BMI160_ACCEL_PMU_MIN_USLEEP, 156 + [BMI160_GYRO] = BMI160_GYRO_PMU_MIN_USLEEP, 166 157 }; 167 158 168 159 struct bmi160_scale { ··· 276 289 if (ret < 0) 277 290 return ret; 278 291 279 - usleep_range(bmi160_pmu_time[t].min, bmi160_pmu_time[t].max); 292 + usleep_range(bmi160_pmu_time[t], bmi160_pmu_time[t] + 1000); 280 293 281 294 return 0; 282 295 }