iio: imu: inv_icm42600: Fix temperature calculation
Subsystems (2)
PATCH 1/1 iio: imu: inv_icm42600: Fix temperature calculation
From the documentation:
"offset to be added to <type>[Y]_raw prior toscaling by <type>[Y]_scale" Offset should be applied before multiplying scale, so divide offset by scale to make this correct.
--- drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c +5 -3
@@ -67,16 +67,18 @@ int inv_icm42600_temp_read_raw(struct iio_dev *indio_dev,return IIO_VAL_INT ;/* * T°C = (temp / 132.48) + 25 -* Tm°C = 1000 * ((temp * 100 / 13248) + 25) +* Tm°C = 1000 * ((temp / 132.48) + 25) +* Tm°C = 7.548309 * temp + 25000 +* Tm°C = (temp + 3312) * 7.548309 * scale: 100000 / 13248 ~= 7.548309 -* offset: 25000 +* offset: 3312 */ case IIO_CHAN_INFO_SCALE : *val =7 ; *val2 =548309 ;return IIO_VAL_INT_PLUS_MICRO ;case IIO_CHAN_INFO_OFFSET : - *val =25000 ; + *val =3312 ;return IIO_VAL_INT ;default :return -EINVAL ;
---
base-commit: 609bc31eca06c7408e6860d8b46311ebe45c1fef
change-id: 20250502-imu-edc0faa6dae9
Best regards,
Signature · 1 line
Sean Nyekjaer <[email protected]>
Jonathan Cameron
maintainerQuoted 7 lines · On Fri, 02 May 2025 11:37:26 +0200 Sean Nyekjaer <[email protected]> wrote:
From the documentation:
"offset to be added to <type>[Y]_raw prior toscaling by <type>[Y]_scale" Offset should be applied before multiplying scale, so divide offset by scale to make this correct.Fixes bc3eb0207fb5 ("iio: imu: inv_icm42600: add temperature sensor support")Signed-off-by Sean Nyekjaer <[email protected]>
Looks correct to me. Given this is going to have impacts on userspace I'd definitely like to know Jean-Baptiste has seen it though before I apply. So, Jean-Baptiste please take a look!
Thanks,
Jonathan
Quoted 36 lines
--- drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c +5
-4@@ -67,16 +67,18 @@ int inv_icm42600_temp_read_raw(struct iio_dev *indio_dev,return IIO_VAL_INT ;/* * T°C = (temp / 132.48) + 25 -* Tm°C = 1000 * ((temp * 100 / 13248) + 25) +* Tm°C = 1000 * ((temp / 132.48) + 25) +* Tm°C = 7.548309 * temp + 25000 +* Tm°C = (temp + 3312) * 7.548309 * scale: 100000 / 13248 ~= 7.548309 -* offset: 25000 +* offset: 3312 */ case IIO_CHAN_INFO_SCALE : *val =7 ; *val2 =548309 ;return IIO_VAL_INT_PLUS_MICRO ;case IIO_CHAN_INFO_OFFSET : - *val =25000 ; + *val =3312 ;return IIO_VAL_INT ;default :return -EINVAL ; ---base-commit:
609bc31eca06c7408e6860d8b46311ebe45c1fef
change-id: 20250502-imu-edc0faa6dae9Best regards,
Hello Sean, Jonathan,
good catch indeed!
This is all good for me, thanks for your fix.
Best regards,
JB
________________________________________
From: Jonathan Cameron <[email protected]>
Sent: Sunday, May 4, 2025 17:28
To: Sean Nyekjaer <[email protected]>
Cc: Jean-Baptiste Maneyrol <[email protected]>; Lars-Peter Clausen <[email protected]>; Jean-Baptiste Maneyrol <[email protected]>; Jonathan Cameron <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> Subject: Re: [PATCH] iio: imu: inv_icm42600: Fix temperature calculation
This Message Is From an External Sender
This message came from outside your organization.
Quoted 7 lines · On Fri, 02 May 2025 11:37:26 +0200 Sean Nyekjaer <[email protected]> wrote:
From the documentation:
"offset to be added to <type>[Y]_raw prior toscaling by <type>[Y]_scale" Offset should be applied before multiplying scale, so divide offset by scale to make this correct.Fixes bc3eb0207fb5 ("iio: imu: inv_icm42600: add temperature sensor support")Signed-off-by Sean Nyekjaer <[email protected]>
Looks correct to me. Given this is going to have impacts on userspace I'd definitely like to know Jean-Baptiste has seen it though before I apply. So, Jean-Baptiste please take a look!
Thanks,
Jonathan
Quoted 36 lines
--- drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c +5
-4@@ -67,16 +67,18 @@ int inv_icm42600_temp_read_raw(struct iio_dev *indio_dev,return IIO_VAL_INT ;/* * T°C = (temp / 132.48) + 25 -* Tm°C = 1000 * ((temp * 100 / 13248) + 25) +* Tm°C = 1000 * ((temp / 132.48) + 25) +* Tm°C = 7.548309 * temp + 25000 +* Tm°C = (temp + 3312) * 7.548309 * scale: 100000 / 13248 ~= 7.548309 -* offset: 25000 +* offset: 3312 */ case IIO_CHAN_INFO_SCALE : *val =7 ; *val2 =548309 ;return IIO_VAL_INT_PLUS_MICRO ;case IIO_CHAN_INFO_OFFSET : - *val =25000 ; + *val =3312 ;return IIO_VAL_INT ;default :return -EINVAL ; ---base-commit:
609bc31eca06c7408e6860d8b46311ebe45c1fef
change-id: 20250502-imu-edc0faa6dae9Best regards,
Quoted 7 lines · On Sun, 4 May 2025 16:46:00 +0000 Jean-Baptiste Maneyrol…
Hello Sean, Jonathan,
good catch indeed!
This is all good for me, thanks for your fix.
Applied.
Quoted 69 lines
Best regards,
JB________________________________________
From: Jonathan Cameron <[email protected]>
Sent: Sunday, May 4, 2025 17:28
To: Sean Nyekjaer <[email protected]>
Cc: Jean-Baptiste Maneyrol <[email protected]>; Lars-Peter Clausen <[email protected]>; Jean-Baptiste Maneyrol <[email protected]>; Jonathan Cameron <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> Subject: Re: [PATCH] iio: imu:inv_icm42600: Fix temperature calculation
This Message Is From an External Sender
This message came from outside your organization.Quoted 7 lines · On Fri, 02 May 2025 11:37:26 +0200 Sean Nyekjaer <[email protected]> wrote:
From the documentation:
"offset to be added to <type>[Y]_raw prior toscaling by <type>[Y]_scale" Offset should be applied before multiplying scale, so divide offset by scale to make this correct.Fixes bc3eb0207fb5 ("iio: imu: inv_icm42600: add temperature sensor support")Signed-off-by Sean Nyekjaer <[email protected]>Looks correct to me. Given this is going to have impacts on userspace I'd definitely like to know Jean-Baptiste has seen it though before I apply. So, Jean-Baptiste please take a look!
Thanks,
Jonathan
Quoted 36 lines
--- drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c +5
-4@@ -67,16 +67,18 @@ int inv_icm42600_temp_read_raw(struct iio_dev *indio_dev,return IIO_VAL_INT ;/* * T°C = (temp / 132.48) + 25 -* Tm°C = 1000 * ((temp * 100 / 13248) + 25) +* Tm°C = 1000 * ((temp / 132.48) + 25) +* Tm°C = 7.548309 * temp + 25000 +* Tm°C = (temp + 3312) * 7.548309 * scale: 100000 / 13248 ~= 7.548309 -* offset: 25000 +* offset: 3312 */ case IIO_CHAN_INFO_SCALE : *val =7 ; *val2 =548309 ;return IIO_VAL_INT_PLUS_MICRO ;case IIO_CHAN_INFO_OFFSET : - *val =25000 ; + *val =3312 ;return IIO_VAL_INT ;default :return -EINVAL ; ---base-commit:
609bc31eca06c7408e6860d8b46311ebe45c1fef
change-id: 20250502-imu-edc0faa6dae9Best regards,