Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1241111

Re: [PATCH] iio: mxs-lradc: Fix temperature offset

From Alexandre Belloni <alexandre.belloni@free-electrons.com>
Newsgroups linux.kernel
Subject Re: [PATCH] iio: mxs-lradc: Fix temperature offset
Date 2015-10-07 02:50 +0200
Message-ID <qgL5E-5Lb-21@gated-at.bofh.it> (permalink)
References <qgBpF-hk-41@gated-at.bofh.it> <qgFtg-648-23@gated-at.bofh.it> <qgJGy-3T4-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] iio: mxs-lradc: Fix temperature offset Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2015-10-06 16:30 +0200
  Re: [PATCH] iio: mxs-lradc: Fix temperature offset Stefan Wahren <stefan.wahren@i2se.com> - 2015-10-06 20:50 +0200
    Re: [PATCH] iio: mxs-lradc: Fix temperature offset Marek Vasut <marex@denx.de> - 2015-10-07 01:20 +0200
      Re: [PATCH] iio: mxs-lradc: Fix temperature offset Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2015-10-07 02:50 +0200
        Re: [PATCH] iio: mxs-lradc: Fix temperature offset Stefan Wahren <stefan.wahren@i2se.com> - 2015-10-07 09:20 +0200
          Re: [PATCH] iio: mxs-lradc: Fix temperature offset Marek Vasut <marex@denx.de> - 2015-10-08 23:20 +0200
  Re: [PATCH] iio: mxs-lradc: Fix temperature offset Marek Vasut <marex@denx.de> - 2015-10-07 01:20 +0200
    Re: [PATCH] iio: mxs-lradc: Fix temperature offset Jonathan Cameron <jic23@kernel.org> - 2015-10-11 16:10 +0200

csiph-web