All of lore.kernel.org
 help / color / mirror / Atom feed
From: khali@linux-fr.org (Jean Delvare)
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] temp1,temp2 calculation in w83781d.c
Date: Tue, 21 Jun 2005 15:27:40 +0000	[thread overview]
Message-ID: <2Aab4pK2.1119360186.1634200.khali@localhost> (raw)
In-Reply-To: <2ef564dc05062100266adaab51@mail.gmail.com>


Hi Sukhdeep,

On 2005-06-21, Sukhdeep Johar wrote:
> I see the temp1 being read as :
>           val*10
> where val is the value read from the register.
>
> While temp2 is read as :
>          (val/128) *5
> where val is a two byte value read from the registers.
> I understand the reason behind the division by 128.
>
> But am not able to understand the multiplication by 5 & 10.

The temp1 value is read from the chip with LSB = 1 degree C, and it
happens that the driver exports the value with a magnitude of 1 (LSB 0.1 degree C). The multiplication by 10 converts from LSB=1 to LSB=0.1.
We could as well have exported the value with a magnitude of 0, this
would have saved the multiplcation. I can't tell why it was done that
way.

The temp2 value is read from the chip with LSB = 0.5 degree C, and is
exported with a magnitude of 1, so again LSB = 0.1 degree C, thus the
multiplication by 5.

The magnitude is returned by the callback functions (e.g. w83781d_temp)
when called with operation = SENSORS_PROC_REAL_INFO, so you can check
them.

Note that all this was completely reworked in Linux 2.6. All temperatures
are now reported with a magnitude of 3 (resolution of 0.001 degree C),
so the conversions are different there. If you are trying to figure our
how hardware monitoring drivers work, I'd suggest that you don't waste
your time with 2.4 code and learn from 2.6 directly.

Hope that helps,
--
Jean Delvare

      reply	other threads:[~2005-06-21 15:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-21  9:27 [lm-sensors] temp1,temp2 calculation in w83781d.c Sukhdeep Johar
2005-06-21 15:27 ` Jean Delvare [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2Aab4pK2.1119360186.1634200.khali@localhost \
    --to=khali@linux-fr.org \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.