* [PATCH] iio: dac: ad5592r: fix temperature scale
@ 2024-04-30 13:13 marc.ferland
2024-04-30 13:59 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: marc.ferland @ 2024-04-30 13:13 UTC (permalink / raw
To: lars; +Cc: Michael.Hennerich, jic23, linux-iio, linux-kernel, Marc Ferland
From: Marc Ferland <marc.ferland@sonatest.com>
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
Signed-off-by: Marc Ferland <marc.ferland@sonatest.com>
---
drivers/iio/dac/ad5592r-base.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
index 076bc9ecfb49..4763402dbcd6 100644
--- a/drivers/iio/dac/ad5592r-base.c
+++ b/drivers/iio/dac/ad5592r-base.c
@@ -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
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: dac: ad5592r: fix temperature scale
2024-04-30 13:13 [PATCH] iio: dac: ad5592r: fix temperature scale marc.ferland
@ 2024-04-30 13:59 ` Jonathan Cameron
2024-04-30 14:26 ` Marc Ferland
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2024-04-30 13:59 UTC (permalink / raw
To: marc.ferland
Cc: lars, Michael.Hennerich, jic23, linux-iio, linux-kernel,
Marc Ferland
On Tue, 30 Apr 2024 09:13:30 -0400
marc.ferland@gmail.com wrote:
> From: Marc Ferland <marc.ferland@sonatest.com>
>
> 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
>
> Signed-off-by: Marc Ferland <marc.ferland@sonatest.com>
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
> ---
> drivers/iio/dac/ad5592r-base.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
> index 076bc9ecfb49..4763402dbcd6 100644
> --- a/drivers/iio/dac/ad5592r-base.c
> +++ b/drivers/iio/dac/ad5592r-base.c
> @@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: dac: ad5592r: fix temperature scale
2024-04-30 13:59 ` Jonathan Cameron
@ 2024-04-30 14:26 ` Marc Ferland
0 siblings, 0 replies; 3+ messages in thread
From: Marc Ferland @ 2024-04-30 14:26 UTC (permalink / raw
To: Jonathan Cameron
Cc: lars, Michael.Hennerich, jic23, linux-iio, linux-kernel,
Marc Ferland
On Tue, Apr 30, 2024 at 9:59 AM Jonathan Cameron
<Jonathan.Cameron@huawei.com> wrote:
>
> On Tue, 30 Apr 2024 09:13:30 -0400
> marc.ferland@gmail.com wrote:
>
> > From: Marc Ferland <marc.ferland@sonatest.com>
> >
> > 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
> >
> > Signed-off-by: Marc Ferland <marc.ferland@sonatest.com>
>
> 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.
>
Oups! you're obviously right. I'll update my commit message and resend.
Marc
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-30 14:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-30 13:13 [PATCH] iio: dac: ad5592r: fix temperature scale marc.ferland
2024-04-30 13:59 ` Jonathan Cameron
2024-04-30 14:26 ` Marc Ferland
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).