Re: [PATCH] iio: imu: inv_icm42600: change invalid data error to EBUSY

From: Jonathan Cameron
Date: Sat Aug 09 2025 - 15:24:59 EST


On Fri, 08 Aug 2025 09:40:10 +0200
Jean-Baptiste Maneyrol via B4 Relay <devnull+jean-baptiste.maneyrol.tdk.com@xxxxxxxxxx> wrote:

> From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@xxxxxxx>
>
> Temperature sensor returns the temperature of the mechanical parts
> of the chip. If both accel and gyro are off, temperature sensor is
> also automatically turned off and return 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: bc3eb0207fb5 ("iio: imu: inv_icm42600: add temperature sensor support")
> Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@xxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
+CC Sean who raised the issue.

> ---
> drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c
> index 8b15afca498cb5dfa7e056a60d3c78e419f11b29..1756f3d07049a26038776a35d9242f3dd1320354 100644
> --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c
> +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c
> @@ -32,8 +32,12 @@ static int inv_icm42600_temp_read(struct inv_icm42600_state *st, s16 *temp)
> goto exit;
>
> *temp = (s16)be16_to_cpup(raw);
> + /*
> + * Temperature data is invalid if both accel and gyro are off.
> + * Return EBUSY in this case.
> + */
> if (*temp == INV_ICM42600_DATA_INVALID)
> - ret = -EINVAL;
> + ret = -EBUSY;
>
> exit:
> mutex_unlock(&st->lock);
>
> ---
> base-commit: 6408dba154079656d069a6a25fb3a8954959474c
> change-id: 20250807-inv-icm42600-change-temperature-error-code-65d16a98c6e1
>
> Best regards,