From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] hwmon: TI TMP121 SPI temperature sensor
Date: Mon, 15 Sep 2008 21:50:51 +0000 [thread overview]
Message-ID: <200809152350.51919.khali@linux-fr.org> (raw)
In-Reply-To: <20080915200636.GA11608@roarinelk.homelinux.net>
Hi Manuel,
Le lundi 15 septembre 2008, Manuel Lauss a écrit :
> Driver for the Texas Instruments TMP121/TMP123 SPI temperature sensors.
> The code is 99% identical to the LM70 driver; only the formula to
> calculate the temperature (in 1/1000 deg celsius) has been adjusted.
>
> Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
> ---
> drivers/hwmon/Kconfig | 10 +++
> drivers/hwmon/Makefile | 1 +
> drivers/hwmon/tmp121.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 179 insertions(+), 0 deletions(-)
> create mode 100644 drivers/hwmon/tmp121.c
Wouldn't it make more sense to just add support for the TMP121/TMP123
chips to the lm70 driver? Duplicating code is better avoided when
possible. Thankfully these drivers are relatively small, but still...
> --- /dev/null
> +++ b/drivers/hwmon/tmp121.c
> (...)
> + /*
> + * The "raw" temperature read into rxbuf[] is a 16-bit signed 2's
> + * complement value. Only the MSB 13 bits (1 sign + 12 temperature
> + * bits) are meaningful; the LSB 3 bits are to be discarded.
> + * Each bit represents 0.0625 degrees Celsius.
> + */
> + val = (raw * 625) / 80;
This does not actually discard the 3 LSB. In order to do that, you
would need to write the following:
val = (raw / 8) * 625 / 10;
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
prev parent reply other threads:[~2008-09-15 21:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-15 20:06 [lm-sensors] [PATCH] hwmon: TI TMP121 SPI temperature sensor driver Manuel Lauss
2008-09-15 21:50 ` 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=200809152350.51919.khali@linux-fr.org \
--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.