From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, sensors@stimpy.netroedge.com
Subject: Re: [PATCH] i2c driver fixes for 2.6.1
Date: Mon, 19 Jan 2004 15:59:22 -0800 [thread overview]
Message-ID: <10745567623125@kroah.com> (raw)
In-Reply-To: <10745567623617@kroah.com>
ChangeSet 1.1474.98.11, 2004/01/14 11:27:58-08:00, khali@linux-fr.org
[PATCH] I2C: Fix w83781d temp
This patch fixes the temperature handling in the w83781d driver:
1* Fix bad magnitude.
2* Use MMH's lm75.h.
3* Allow negative temperatures.
drivers/i2c/chips/w83781d.c | 30 ++++++++++++++----------------
1 files changed, 14 insertions(+), 16 deletions(-)
diff -Nru a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c
--- a/drivers/i2c/chips/w83781d.c Mon Jan 19 15:31:21 2004
+++ b/drivers/i2c/chips/w83781d.c Mon Jan 19 15:31:21 2004
@@ -43,6 +43,7 @@
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
#include <asm/io.h>
+#include "lm75.h"
/* RT Table support #defined so we can take it out if it gets bothersome */
#define W83781D_RT 1
@@ -170,17 +171,14 @@
((val) == 255 ? 0 : \
1350000 / ((val) * (div))))
-#define TEMP_TO_REG(val) (SENSORS_LIMIT(((val / 10) < 0 ? (((val / 10) - 5) / 10) : \
- ((val / 10) + 5) / 10), 0, 255))
-#define TEMP_FROM_REG(val) ((((val ) > 0x80 ? (val) - 0x100 : (val)) * 10) * 10)
-
-#define TEMP_ADD_TO_REG(val) (SENSORS_LIMIT(((((val / 10) + 2) / 5) << 7),\
- 0, 0xffff))
-#define TEMP_ADD_FROM_REG(val) ((((val) >> 7) * 5) * 10)
-
-#define AS99127_TEMP_ADD_TO_REG(val) (SENSORS_LIMIT((((((val / 10) + 2)*4)/10) \
- << 7), 0, 0xffff))
-#define AS99127_TEMP_ADD_FROM_REG(val) (((((val) >> 7) * 10) / 4) * 10)
+#define TEMP_TO_REG(val) (SENSORS_LIMIT(((val) < 0 ? (val)+0x100*1000 \
+ : (val)) / 1000, 0, 0xff))
+#define TEMP_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000)
+
+#define AS99127_TEMP_ADD_TO_REG(val) (SENSORS_LIMIT((((val) < 0 ? (val)+0x10000*250 \
+ : (val)) / 250) << 7, 0, 0xffff))
+#define AS99127_TEMP_ADD_FROM_REG(val) ((((val) & 0x8000 ? (val)-0x10000 : (val)) \
+ >> 7) * 250)
#define ALARMS_FROM_REG(val) (val)
#define PWM_FROM_REG(val) (val)
@@ -437,8 +435,8 @@
return sprintf(buf,"%ld\n", \
(long)AS99127_TEMP_ADD_FROM_REG(data->reg##_add[nr-2])); \
} else { \
- return sprintf(buf,"%ld\n", \
- (long)TEMP_ADD_FROM_REG(data->reg##_add[nr-2])); \
+ return sprintf(buf,"%d\n", \
+ LM75_TEMP_FROM_REG(data->reg##_add[nr-2])); \
} \
} else { /* TEMP1 */ \
return sprintf(buf,"%ld\n", (long)TEMP_FROM_REG(data->reg)); \
@@ -453,15 +451,15 @@
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct w83781d_data *data = i2c_get_clientdata(client); \
- u32 val; \
+ s32 val; \
\
- val = simple_strtoul(buf, NULL, 10); \
+ val = simple_strtol(buf, NULL, 10); \
\
if (nr >= 2) { /* TEMP2 and TEMP3 */ \
if (data->type == as99127f) \
data->temp_##reg##_add[nr-2] = AS99127_TEMP_ADD_TO_REG(val); \
else \
- data->temp_##reg##_add[nr-2] = TEMP_ADD_TO_REG(val); \
+ data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \
\
w83781d_write_value(client, W83781D_REG_TEMP_##REG(nr), \
data->temp_##reg##_add[nr-2]); \
next prev parent reply other threads:[~2004-01-20 2:28 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-19 23:57 [BK PATCH] i2c driver fixes for 2.6.1 Greg KH
2004-01-19 23:59 ` [PATCH] " Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH [this message]
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-19 23:59 ` Greg KH
2004-01-21 21:50 ` Jean Delvare
2004-01-21 23:56 ` Greg KH
2004-01-31 8:56 ` Jean Delvare
2004-01-31 15:23 ` Greg KH
2004-01-20 22:03 ` Jean Delvare
2004-01-20 22:07 ` Greg KH
2004-01-21 20:47 ` Jean Delvare
2004-01-24 1:14 ` Greg KH
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=10745567623125@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sensors@stimpy.netroedge.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox