Skip to content

Commit 9fcc740

Browse files
jmaneyrol-invngregkh
authored andcommitted
iio: imu: inv_icm42600: change invalid data error to -EBUSY
[ Upstream commit dfdc31e ] Temperature sensor returns the temperature of the mechanical parts of the chip. If both accel and gyro are off, the temperature sensor is also automatically turned off and returns invalid data. In this case, returning -EBUSY error code is better then -EINVAL and indicates userspace that it needs to retry reading temperature in another context. Fixes: bc3eb02 ("iio: imu: inv_icm42600: add temperature sensor support") Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Cc: stable@vger.kernel.org Reviewed-by: Andy Shevchenko <andy@kernel.org> Reviewed-by: Sean Nyekjaer <sean@geanix.com> Link: https://patch.msgid.link/20250808-inv-icm42600-change-temperature-error-code-v1-1-986fbf63b77d@tdk.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 96abc49 commit 9fcc740

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ static int inv_icm42600_temp_read(struct inv_icm42600_state *st, s16 *temp)
3232
goto exit;
3333

3434
*temp = (s16)be16_to_cpup(raw);
35+
/*
36+
* Temperature data is invalid if both accel and gyro are off.
37+
* Return -EBUSY in this case.
38+
*/
3539
if (*temp == INV_ICM42600_DATA_INVALID)
36-
ret = -EINVAL;
40+
ret = -EBUSY;
3741

3842
exit:
3943
mutex_unlock(&st->lock);

0 commit comments

Comments
 (0)