From: Jean-Baptiste Maneyrol jean-baptiste.maneyrol@tdk.com
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@tdk.com Cc: stable@vger.kernel.org --- 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,
On Fri, Aug 8, 2025 at 9:40 AM Jean-Baptiste Maneyrol via B4 Relay devnull+jean-baptiste.maneyrol.tdk.com@kernel.org wrote:
Temperature sensor returns the temperature of the mechanical parts of the chip. If both accel and gyro are off, temperature sensor is
the temperature
also automatically turned off and return invalid data.
returns
In this case, returning EBUSY error code is better then EINVAL and
-EBUSY than -EINVAL
indicates userspace that it needs to retry reading temperature in another context.
...
/*
* Temperature data is invalid if both accel and gyro are off.
* Return EBUSY in this case.
-EBUSY
*/ if (*temp == INV_ICM42600_DATA_INVALID)
ret = -EINVAL;
ret = -EBUSY;
exit: mutex_unlock(&st->lock);
...
No need to resend just for the above, I hope Jonathan tweaks this whilst applying. Reviewed-by: Andy Shevchenko andy@kernel.org (assuming typos and signs are fixed)
On Fri, 8 Aug 2025 14:35:00 +0200 Andy Shevchenko andy.shevchenko@gmail.com wrote:
On Fri, Aug 8, 2025 at 9:40 AM Jean-Baptiste Maneyrol via B4 Relay devnull+jean-baptiste.maneyrol.tdk.com@kernel.org wrote:
Temperature sensor returns the temperature of the mechanical parts of the chip. If both accel and gyro are off, temperature sensor is
the temperature
also automatically turned off and return invalid data.
returns
In this case, returning EBUSY error code is better then EINVAL and
-EBUSY than -EINVAL
indicates userspace that it needs to retry reading temperature in another context.
...
/*
* Temperature data is invalid if both accel and gyro are off.
* Return EBUSY in this case.
-EBUSY
*/ if (*temp == INV_ICM42600_DATA_INVALID)
ret = -EINVAL;
ret = -EBUSY;
exit: mutex_unlock(&st->lock);
...
No need to resend just for the above, I hope Jonathan tweaks this whilst applying. Reviewed-by: Andy Shevchenko andy@kernel.org (assuming typos and signs are fixed)
Tweaked an applied to the fixes-togreg branch of iio.git. I've not marked this explicitly for stable as it's a kind of weird sort of 'fix'. If anyone wants is backported, then maybe we can consider that once it's upstream
Jonathan
On Fri, 08 Aug 2025 09:40:10 +0200 Jean-Baptiste Maneyrol via B4 Relay devnull+jean-baptiste.maneyrol.tdk.com@kernel.org wrote:
From: Jean-Baptiste Maneyrol jean-baptiste.maneyrol@tdk.com
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@tdk.com Cc: stable@vger.kernel.org
+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,
On Sat, Aug 09, 2025 at 08:24:40PM +0100, Jonathan Cameron wrote:
On Fri, 08 Aug 2025 09:40:10 +0200 Jean-Baptiste Maneyrol via B4 Relay devnull+jean-baptiste.maneyrol.tdk.com@kernel.org wrote:
From: Jean-Baptiste Maneyrol jean-baptiste.maneyrol@tdk.com
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@tdk.com Cc: stable@vger.kernel.org
+CC Sean who raised the issue.
Reviewed-by: Sean Nyekjaer sean@geanix.com
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,
linux-stable-mirror@lists.linaro.org