linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: mxs-lradc: Fix temperature offset
@ 2015-10-06 14:22 Alexandre Belloni
  2015-10-06 18:43 ` Stefan Wahren
  2015-10-06 23:13 ` Marek Vasut
  0 siblings, 2 replies; 8+ messages in thread
From: Alexandre Belloni @ 2015-10-06 14:22 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Marek Vasut, linux-iio, linux-kernel,
	Alexandre Belloni

0° Kelvin is actually −273.15°C, not -272.15°C. Fix the temperature offset.

Reported-by: Janusz Użycki <j.uzycki@elpromaelectronics.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/staging/iio/adc/mxs-lradc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index 3f7715c9968b..67bfa54c4fb1 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -916,10 +916,10 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
 		if (chan->type == IIO_TEMP) {
 			/* The calculated value from the ADC is in Kelvin, we
 			 * want Celsius for hwmon so the offset is
-			 * -272.15 * scale
+			 * -273.15 * scale
 			 */
-			*val = -1075;
-			*val2 = 691699;
+			*val = -1079;
+			*val2 = 644268;
 
 			return IIO_VAL_INT_PLUS_MICRO;
 		}
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] iio: mxs-lradc: Fix temperature offset
  2015-10-06 14:22 [PATCH] iio: mxs-lradc: Fix temperature offset Alexandre Belloni
@ 2015-10-06 18:43 ` Stefan Wahren
  2015-10-06 23:19   ` Marek Vasut
  2015-10-06 23:13 ` Marek Vasut
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Wahren @ 2015-10-06 18:43 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Lars-Peter Clausen, linux-kernel, linux-iio, Marek Vasut,
	Janusz Użycki, Jonathan Cameron

Hi,

> Alexandre Belloni <alexandre.belloni@free-electrons.com> hat am 6. Oktober
> 2015 um 16:22 geschrieben:
>
>
> 0° Kelvin is actually −273.15°C, not -272.15°C. Fix the temperature offset.
>
> Reported-by: Janusz Użycki <j.uzycki@elpromaelectronics.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> drivers/staging/iio/adc/mxs-lradc.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/mxs-lradc.c
> b/drivers/staging/iio/adc/mxs-lradc.c
> index 3f7715c9968b..67bfa54c4fb1 100644
> --- a/drivers/staging/iio/adc/mxs-lradc.c
> +++ b/drivers/staging/iio/adc/mxs-lradc.c
> @@ -916,10 +916,10 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
> if (chan->type == IIO_TEMP) {
> /* The calculated value from the ADC is in Kelvin, we
> * want Celsius for hwmon so the offset is
> - * -272.15 * scale
> + * -273.15 * scale
> */
> - *val = -1075;
> - *val2 = 691699;
> + *val = -1079;
> + *val2 = 644268;
>

i think it would be nice to break down the calculation of these magic values in
a second patch.

Regards
Stefan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iio: mxs-lradc: Fix temperature offset
  2015-10-06 14:22 [PATCH] iio: mxs-lradc: Fix temperature offset Alexandre Belloni
  2015-10-06 18:43 ` Stefan Wahren
@ 2015-10-06 23:13 ` Marek Vasut
  2015-10-11 14:03   ` Jonathan Cameron
  1 sibling, 1 reply; 8+ messages in thread
From: Marek Vasut @ 2015-10-06 23:13 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Jonathan Cameron, Lars-Peter Clausen, linux-iio, linux-kernel

On 10/06/2015 16:22, Alexandre Belloni wrote:
> 0° Kelvin is actually −273.15°C, not -272.15°C. Fix the temperature offset.
>
> Reported-by: Janusz Użycki <j.uzycki@elpromaelectronics.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Nice find :-)

Acked-by: Marek Vasut <marex@denx.de>

(I am using different MUA, please pardon the possible issues)

> ---
>   drivers/staging/iio/adc/mxs-lradc.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
> index 3f7715c9968b..67bfa54c4fb1 100644
> --- a/drivers/staging/iio/adc/mxs-lradc.c
> +++ b/drivers/staging/iio/adc/mxs-lradc.c
> @@ -916,10 +916,10 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
>   		if (chan->type == IIO_TEMP) {
>   			/* The calculated value from the ADC is in Kelvin, we
>   			 * want Celsius for hwmon so the offset is
> -			 * -272.15 * scale
> +			 * -273.15 * scale
>   			 */
> -			*val = -1075;
> -			*val2 = 691699;
> +			*val = -1079;
> +			*val2 = 644268;
>
>   			return IIO_VAL_INT_PLUS_MICRO;
>   		}
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iio: mxs-lradc: Fix temperature offset
  2015-10-06 18:43 ` Stefan Wahren
@ 2015-10-06 23:19   ` Marek Vasut
  2015-10-07  0:44     ` Alexandre Belloni
  0 siblings, 1 reply; 8+ messages in thread
From: Marek Vasut @ 2015-10-06 23:19 UTC (permalink / raw)
  To: Stefan Wahren, Alexandre Belloni
  Cc: Lars-Peter Clausen, linux-kernel, linux-iio, Janusz Użycki,
	Jonathan Cameron

On 10/06/2015 20:43, Stefan Wahren wrote:
> Hi,
>
>> Alexandre Belloni <alexandre.belloni@free-electrons.com> hat am 6. Oktober
>> 2015 um 16:22 geschrieben:
>>
>>
>> 0° Kelvin is actually −273.15°C, not -272.15°C. Fix the temperature offset.
>>
>> Reported-by: Janusz Użycki <j.uzycki@elpromaelectronics.com>
>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>> ---
>> drivers/staging/iio/adc/mxs-lradc.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/staging/iio/adc/mxs-lradc.c
>> b/drivers/staging/iio/adc/mxs-lradc.c
>> index 3f7715c9968b..67bfa54c4fb1 100644
>> --- a/drivers/staging/iio/adc/mxs-lradc.c
>> +++ b/drivers/staging/iio/adc/mxs-lradc.c
>> @@ -916,10 +916,10 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
>> if (chan->type == IIO_TEMP) {
>> /* The calculated value from the ADC is in Kelvin, we
>> * want Celsius for hwmon so the offset is
>> - * -272.15 * scale
>> + * -273.15 * scale
>> */
>> - *val = -1075;
>> - *val2 = 691699;
>> + *val = -1079;
>> + *val2 = 644268;
>>
>
> i think it would be nice to break down the calculation of these magic values in
> a second patch.

Indeed, I agree. I hope Alexandre can send another patch for that soon :-)

> Regards
> Stefan
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iio: mxs-lradc: Fix temperature offset
  2015-10-06 23:19   ` Marek Vasut
@ 2015-10-07  0:44     ` Alexandre Belloni
  2015-10-07  7:12       ` Stefan Wahren
  0 siblings, 1 reply; 8+ messages in thread
From: Alexandre Belloni @ 2015-10-07  0:44 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Stefan Wahren, Lars-Peter Clausen, linux-kernel, linux-iio,
	Janusz Użycki, Jonathan Cameron

Hi,

On 07/10/2015 at 01:19:09 +0200, Marek Vasut wrote :
> >>/* The calculated value from the ADC is in Kelvin, we
> >>* want Celsius for hwmon so the offset is
> >>- * -272.15 * scale
> >>+ * -273.15 * scale
> >>*/
> >>- *val = -1075;
> >>- *val2 = 691699;
> >>+ *val = -1079;
> >>+ *val2 = 644268;
> >>
> >
> >i think it would be nice to break down the calculation of these magic values in
> >a second patch.
> 
> Indeed, I agree. I hope Alexandre can send another patch for that soon :-)
> 

On my side, I'm not sure this is worth more than a comment. If
necessary, I can write that the datasheet specifies that the scale is
4/1.012 here also.

Else you end up with something like that (naive implementation):

#define SCALE (4 * 1000 / 1012)

val = -273150000 * SCALE / 1000000;
val2 = 273150000 * SCALE + 1000000 * val;

I don't feel this is any clearer because we can't use floating points in
the kernel anyway.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iio: mxs-lradc: Fix temperature offset
  2015-10-07  0:44     ` Alexandre Belloni
@ 2015-10-07  7:12       ` Stefan Wahren
  2015-10-08 21:12         ` Marek Vasut
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Wahren @ 2015-10-07  7:12 UTC (permalink / raw)
  To: Alexandre Belloni, Marek Vasut
  Cc: Lars-Peter Clausen, linux-kernel, linux-iio, Janusz Użycki,
	Jonathan Cameron

Am 07.10.2015 um 02:44 schrieb Alexandre Belloni:
> Hi,
>
> On 07/10/2015 at 01:19:09 +0200, Marek Vasut wrote :
>>>> /* The calculated value from the ADC is in Kelvin, we
>>>> * want Celsius for hwmon so the offset is
>>>> - * -272.15 * scale
>>>> + * -273.15 * scale
>>>> */
>>>> - *val = -1075;
>>>> - *val2 = 691699;
>>>> + *val = -1079;
>>>> + *val2 = 644268;
>>>>
>>> i think it would be nice to break down the calculation of these magic values in
>>> a second patch.
>> Indeed, I agree. I hope Alexandre can send another patch for that soon :-)
>>
> On my side, I'm not sure this is worth more than a comment. If
> necessary, I can write that the datasheet specifies that the scale is
> 4/1.012 here also.

I'm okay with that.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iio: mxs-lradc: Fix temperature offset
  2015-10-07  7:12       ` Stefan Wahren
@ 2015-10-08 21:12         ` Marek Vasut
  0 siblings, 0 replies; 8+ messages in thread
From: Marek Vasut @ 2015-10-08 21:12 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Alexandre Belloni, Lars-Peter Clausen, linux-kernel, linux-iio,
	Janusz Użycki, Jonathan Cameron

On Wednesday, October 07, 2015 at 09:12:56 AM, Stefan Wahren wrote:
> Am 07.10.2015 um 02:44 schrieb Alexandre Belloni:
> > Hi,
> > 
> > On 07/10/2015 at 01:19:09 +0200, Marek Vasut wrote :
> >>>> /* The calculated value from the ADC is in Kelvin, we
> >>>> * want Celsius for hwmon so the offset is
> >>>> - * -272.15 * scale
> >>>> + * -273.15 * scale
> >>>> */
> >>>> - *val = -1075;
> >>>> - *val2 = 691699;
> >>>> + *val = -1079;
> >>>> + *val2 = 644268;
> >>> 
> >>> i think it would be nice to break down the calculation of these magic
> >>> values in a second patch.
> >> 
> >> Indeed, I agree. I hope Alexandre can send another patch for that soon
> >> :-)
> > 
> > On my side, I'm not sure this is worth more than a comment. If
> > necessary, I can write that the datasheet specifies that the scale is
> > 4/1.012 here also.
> 
> I'm okay with that.

I'm fine either way, it's not worth wasting more time on this trivial stuff.
I'd say just pick this one.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iio: mxs-lradc: Fix temperature offset
  2015-10-06 23:13 ` Marek Vasut
@ 2015-10-11 14:03   ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2015-10-11 14:03 UTC (permalink / raw)
  To: Marek Vasut, Alexandre Belloni
  Cc: Lars-Peter Clausen, linux-iio, linux-kernel

On 07/10/15 00:13, Marek Vasut wrote:
> On 10/06/2015 16:22, Alexandre Belloni wrote:
>> 0° Kelvin is actually −273.15°C, not -272.15°C. Fix the temperature offset.
>>
>> Reported-by: Janusz Użycki <j.uzycki@elpromaelectronics.com>
>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> 
> Nice find :-)
> 
> Acked-by: Marek Vasut <marex@denx.de>
Ah, missed this when applying.  Have added your Ack to the V2 and will
push it out later.

J
> 
> (I am using different MUA, please pardon the possible issues)
> 
>> ---
>>   drivers/staging/iio/adc/mxs-lradc.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
>> index 3f7715c9968b..67bfa54c4fb1 100644
>> --- a/drivers/staging/iio/adc/mxs-lradc.c
>> +++ b/drivers/staging/iio/adc/mxs-lradc.c
>> @@ -916,10 +916,10 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
>>           if (chan->type == IIO_TEMP) {
>>               /* The calculated value from the ADC is in Kelvin, we
>>                * want Celsius for hwmon so the offset is
>> -             * -272.15 * scale
>> +             * -273.15 * scale
>>                */
>> -            *val = -1075;
>> -            *val2 = 691699;
>> +            *val = -1079;
>> +            *val2 = 644268;
>>
>>               return IIO_VAL_INT_PLUS_MICRO;
>>           }
>>
> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-10-11 14:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-06 14:22 [PATCH] iio: mxs-lradc: Fix temperature offset Alexandre Belloni
2015-10-06 18:43 ` Stefan Wahren
2015-10-06 23:19   ` Marek Vasut
2015-10-07  0:44     ` Alexandre Belloni
2015-10-07  7:12       ` Stefan Wahren
2015-10-08 21:12         ` Marek Vasut
2015-10-06 23:13 ` Marek Vasut
2015-10-11 14:03   ` Jonathan Cameron

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 NNTP newsgroup(s).