iio: dac: ad5592r: fix temperature scale
Subsystems (2)
PATCH 1/1 iio: dac: ad5592r: fix temperature scale
From: Marc Ferland <[email protected]>
For temperature readings, the remainder is returned as nano Celsius _but_ we mark it as IIO_VAL_INT_PLUS_MICRO. This results in incorrect temperature reporting through hwmon for example. I have a board here which reports the following when running 'sensors':
iio_hwmon-isa-0000
Adapter: ISA adapter
temp1: +93.3°C
With the patch applied, it returns the correct temperature:
iio_hwmon-isa-0000
Adapter: ISA adapter
temp1: +30.5°C
--- drivers/iio/dac/ad5592r-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ad5592r-base.c +1 -1
@@ -415,7 +415,7 @@ static int ad5592r_read_raw(struct iio_dev *iio_dev,s64 tmp = *val * (3767897513LL /25LL ); *val =div_s64_rem (tmp,1000000000LL , val2); -return IIO_VAL_INT_PLUS_MICRO ; +return IIO_VAL_INT_PLUS_NANO ; }mutex_lock (&st->lock);
base-commit: 98369dccd2f8e16bf4c6621053af7aa4821dcf8e
Signature · 1 line
2.34.1
Quoted 11 lines · On Tue, 30 Apr 2024 09:13:30 -0400 [email protected] wrote:
From: Marc Ferland <[email protected]>
For temperature readings, the remainder is returned as nano Celsius _but_ we mark it as
IIO_VAL_INT_PLUS_MICRO. This results in incorrect temperature reporting through hwmon for example. I have a board here which reports the following when running 'sensors':iio_hwmon-isa-0000
Adapter: ISA adapter
temp1: +93.3°C
Quoted 7 lines
With the patch applied, it returns the correct temperature:
iio_hwmon-isa-0000
Adapter: ISA adapter
temp1: +30.5°CSigned-off-by Marc Ferland <[email protected]>
IIO temperature units are milli celcius, so I'm not following the argument here. The driver might be reporting in pico celcius I suppose? Call out that this is the scale factor though, so it corresponds to 1LSB hence a small number is certainly plausible..
Reasonable to argue it's taking the integer and dividing by 10^9 hence INT_PLUS_NANO is the right answer, but it isn't nano celsius.
Jonathan
Quoted 19 lines
--- drivers/iio/dac/ad5592r-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/dac/ad5592r-base.c +1
-1@@ -415,7 +415,7 @@ static int ad5592r_read_raw(struct iio_dev *iio_dev,s64 tmp = *val * (3767897513LL /25LL ); *val =div_s64_rem (tmp,1000000000LL , val2); -return IIO_VAL_INT_PLUS_MICRO ; +return IIO_VAL_INT_PLUS_NANO ; }mutex_lock (&st->lock);base-commit:
98369dccd2f8e16bf4c6621053af7aa4821dcf8e
Quoted 23 lines · Jonathan Cameron
Quoted 11 lines · On Tue, 30 Apr 2024 09:13:30 -0400 [email protected] wrote:
From: Marc Ferland <[email protected]>
For temperature readings, the remainder is returned as nano Celsius _but_ we mark it as
IIO_VAL_INT_PLUS_MICRO. This results in incorrect temperature reporting through hwmon for example. I have a board here which reports the following when running 'sensors':iio_hwmon-isa-0000
Adapter: ISA adapter
temp1: +93.3°CQuoted 7 lines
With the patch applied, it returns the correct temperature:
iio_hwmon-isa-0000
Adapter: ISA adapter
temp1: +30.5°CSigned-off-by Marc Ferland <[email protected]>
Quoted 8 lines
IIO temperature units are milli celcius, so I'm not following the argument here. The driver might be reporting in pico celcius I suppose? Call out that this is the scale factor though, so it corresponds to 1LSB hence a small number is certainly plausible..
Reasonable to argue it's taking the integer and dividing by 10^9 hence
INT_PLUS_NANOis the right answer, but it isn't nano celsius.
Oups! you're obviously right. I'll update my commit message and resend. Marc