public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] More i2c driver changes for 2.5.70
@ 2003-06-12 10:22 Margit Schubert-While
  2003-06-16 18:42 ` Greg KH
  0 siblings, 1 reply; 13+ messages in thread
From: Margit Schubert-While @ 2003-06-12 10:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg KH

[-- Attachment #1: Type: text/plain, Size: 154 bytes --]

OK Here's the patch which :
1) Fixes the race conditions
2) Correctly reports the temps :-)
3) Removes a bit of gunk in the defines which I forgot

Margit

[-- Attachment #2: lm85patch --]
[-- Type: application/octet-stream, Size: 4193 bytes --]

diff -Naur linux-2.5.70/drivers/i2c/chips/lm85.c linux-2.5.70mw/drivers/i2c/chips/lm85.c
--- linux-2.5.70/drivers/i2c/chips/lm85.c	2003-06-12 10:37:45.000000000 +0200
+++ linux-2.5.70mw/drivers/i2c/chips/lm85.c	2003-06-12 11:38:16.000000000 +0200
@@ -148,20 +148,17 @@
 #define SCALE(val,from,to)		(((val)*(to) + ((from)/2))/(from))
 #define INS_TO_REG(n,val)		(SENSORS_LIMIT(SCALE(val,lm85_scaling[n],192),0,255))
 #define INSEXT_FROM_REG(n,val,ext)	(SCALE((val)*4 + (ext),192*4,lm85_scaling[n]))
-/*
 #define INS_FROM_REG(n,val)		(INSEXT_FROM_REG(n,val,0))
-*/
-#define INS_FROM_REG(n,val)		( ( (val*4*lm85_scaling[n]) + (192*4/2) ) / (192*4) )
 
 /* FAN speed is measured using 90kHz clock */
 #define FAN_TO_REG(val)		(SENSORS_LIMIT( (val)<=0?0: 5400000/(val),0,65534))
 #define FAN_FROM_REG(val)	((val)==0?-1:(val)==0xffff?0:5400000/(val))
 
-/* Temperature is reported in .01 degC increments */
-#define TEMP_TO_REG(val)		(SENSORS_LIMIT(((val)+50)/100,-127,127))
-#define TEMPEXT_FROM_REG(val,ext)	((val)*100 + (ext)*25)
+/* Temperature is reported in .001 degC increments */
+#define TEMP_TO_REG(val)		(SENSORS_LIMIT(((val)+500)/1000,-127,127))
+#define TEMPEXT_FROM_REG(val,ext)	((val)*1000 + (ext)*250)
 #define TEMP_FROM_REG(val)		(TEMPEXT_FROM_REG(val,0))
-#define EXTTEMP_TO_REG(val)		(SENSORS_LIMIT((val)/25,-127,127))
+#define EXTTEMP_TO_REG(val)		(SENSORS_LIMIT((val)/250,-127,127))
 
 #define PWM_TO_REG(val)			(SENSORS_LIMIT(val,0,255))
 #define PWM_FROM_REG(val)		(val)
@@ -437,10 +434,13 @@
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct lm85_data *data = i2c_get_clientdata(client);
+	int	val;
 
-	int val = simple_strtol(buf, NULL, 10);
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
 	data->fan_min[nr] = FAN_TO_REG(val);
 	lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]);
+	up(&data->update_lock);
 	return count;
 }
 
@@ -528,10 +528,13 @@
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct lm85_data *data = i2c_get_clientdata(client);
+	int	val;
 
-	int val = simple_strtol(buf, NULL, 10);
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
 	data->pwm[nr] = PWM_TO_REG(val);
 	lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]);
+	up(&data->update_lock);
 	return count;
 }
 static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr)
@@ -590,10 +593,13 @@
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct lm85_data *data = i2c_get_clientdata(client);
+	int	val;
 
-	int val = simple_strtol(buf, NULL, 10);
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
 	data->in_min[nr] = INS_TO_REG(nr, val);
 	lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]);
+	up(&data->update_lock);
 	return count;
 }
 static ssize_t show_in_max(struct device *dev, char *buf, int nr)
@@ -609,10 +615,13 @@
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct lm85_data *data = i2c_get_clientdata(client);
+	int	val;
 
-	int val = simple_strtol(buf, NULL, 10);
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
 	data->in_max[nr] = INS_TO_REG(nr, val);
 	lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]);
+	up(&data->update_lock);
 	return count;
 }
 #define show_in_reg(offset)						\
@@ -673,10 +682,13 @@
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct lm85_data *data = i2c_get_clientdata(client);
+	int	val;
 
-	int val = simple_strtol(buf, NULL, 10);
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
 	data->temp_min[nr] = TEMP_TO_REG(val);
 	lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]);
+	up(&data->update_lock);
 	return count;
 }
 static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
@@ -692,10 +704,13 @@
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct lm85_data *data = i2c_get_clientdata(client);
+	int	val;
 
-	int val = simple_strtol(buf, NULL, 10);
+	down(&data->update_lock);
+	val = simple_strtol(buf, NULL, 10);
 	data->temp_max[nr] = TEMP_TO_REG(val);
 	lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]);
+	up(&data->update_lock);
 	return count;
 }
 #define show_temp_reg(offset)						\

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: [PATCH] More i2c driver changes for 2.5.70
@ 2003-06-12  9:16 Margit Schubert-While
  0 siblings, 0 replies; 13+ messages in thread
From: Margit Schubert-While @ 2003-06-12  9:16 UTC (permalink / raw)
  To: linux-kernel

 > I think there is a race condition here in the "set" functions.
Hi Philip, long time no see :-)
Yes, you are right.
Will be sending a patch to Greg shortly.
Couple of other things have to be fixed as well.
Just realized that temp scaling is wrong.
Should be scaling by 1000 not 100.
(Gee, and that after I had mailed Greg that a couple of other sensors
get it wrong)

Margit


^ permalink raw reply	[flat|nested] 13+ messages in thread
* [BK PATCH] More i2c driver changes for 2.5.70
@ 2003-06-11 20:35 Greg KH
  2003-06-11 20:36 ` [PATCH] " Greg KH
  0 siblings, 1 reply; 13+ messages in thread
From: Greg KH @ 2003-06-11 20:35 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, sensors

Hi,

Here are some more i2c driver changes for 2.5.70.  These consist of a new i2c
client driver, a new i2c bus driver, some coding style fixes for the new bus
driver, and a bunch of sparse warning removels.

Please pull from:  bk://kernel.bkbits.net/gregkh/linux/i2c-2.5

thanks,

greg k-h

-----

 drivers/i2c/Kconfig        |    4 
 drivers/i2c/Makefile       |    1 
 drivers/i2c/chips/Kconfig  |   19 
 drivers/i2c/chips/Makefile |    1 
 drivers/i2c/chips/lm85.c   | 1223 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/i2c-core.c     |   36 -
 drivers/i2c/i2c-dev.c      |   10 
 drivers/i2c/i2c-iop3xx.c   |  868 +++++++++++++++++++++++++------
 drivers/i2c/i2c-iop3xx.h   |  238 ++++++--
 include/linux/i2c-dev.h    |    6 
 include/linux/i2c.h        |    4 
 11 files changed, 2150 insertions(+), 260 deletions(-)
-----

<margitsw:t-online.de>:
  o I2C: add LM85 driver

<peterm:remware.demon.co.uk>:
  o I2C: add New bus driver: XSCALE iop3xx

Greg Kroah-Hartman:
  o I2C: fix up sparse warnings in the i2c-dev driver
  o I2C: fix up sparse warnings in drivers/i2c/i2c-core.c
  o I2C: fix some errors found by sparse in include/linux/i2c.h
  o I2C: coding style updates for i2c-iop3xx driver


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

end of thread, other threads:[~2003-06-18 15:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-12 10:22 [PATCH] More i2c driver changes for 2.5.70 Margit Schubert-While
2003-06-16 18:42 ` Greg KH
2003-06-18 12:18   ` Margit Schubert-While
2003-06-18 14:22     ` Greg KH
2003-06-18 15:53       ` Margit Schubert-While
  -- strict thread matches above, loose matches on Subject: below --
2003-06-12  9:16 Margit Schubert-While
2003-06-11 20:35 [BK PATCH] " Greg KH
2003-06-11 20:36 ` [PATCH] " Greg KH
2003-06-11 20:36   ` Greg KH
2003-06-11 20:36     ` Greg KH
2003-06-11 20:36       ` Greg KH
2003-06-11 20:36         ` Greg KH
2003-06-11 20:36           ` Greg KH
2003-06-12  2:40   ` Philip Pokorny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox