mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-28 12:40:42 +00:00
Some small rounding and initializing bugs solved.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@53 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
000b95cce0
commit
01e8dc6d7c
5 files changed
+24
-18
No files matched your search
@@ -1,5 +1,9 @@
|
||||
Many, many things. Most notably:
|
||||
|
||||
* Check whether the FAN count divisors in the lm78 module are correct
|
||||
(probably not!)
|
||||
* Wouldn't it be better to display all natural voltages for the LM78 chip,
|
||||
and do *all* conversions through a user program?
|
||||
* kmalloc with GFP_KERNEL can cause a context switch! Check whether this is
|
||||
safe everywhere it is used.
|
||||
* Support 10-bit addresses. At this moment, they are supported nowhere, except
|
||||
|
||||
+6
-4
@@ -37,8 +37,8 @@
|
||||
#define TEMP_TO_REG(val) (((((val) + 2) / 5) << 7) & 0xff80)
|
||||
|
||||
/* Initial values */
|
||||
#define LM75_INIT_TEMP_OS 60
|
||||
#define LM75_INIT_TEMP_HYST 50
|
||||
#define LM75_INIT_TEMP_OS 600
|
||||
#define LM75_INIT_TEMP_HYST 500
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct lm75_data {
|
||||
@@ -170,8 +170,10 @@ int lm75_attach_adapter(struct i2c_adapter *adapter)
|
||||
err = 0;
|
||||
|
||||
/* Initialize the LM75 chip */
|
||||
lm75_write_value(new_client,LM75_REG_TEMP_OS,LM75_INIT_TEMP_OS);
|
||||
lm75_write_value(new_client,LM75_REG_TEMP_HYST,LM75_INIT_TEMP_HYST);
|
||||
lm75_write_value(new_client,LM75_REG_TEMP_OS,
|
||||
TEMP_TO_REG(LM75_INIT_TEMP_OS));
|
||||
lm75_write_value(new_client,LM75_REG_TEMP_HYST,
|
||||
TEMP_TO_REG(LM75_INIT_TEMP_HYST));
|
||||
lm75_write_value(new_client,LM75_REG_CONF,0);
|
||||
|
||||
continue;
|
||||
|
||||
+4
-5
@@ -63,18 +63,17 @@
|
||||
#define LM78_REG_CHIPID 0x49
|
||||
|
||||
|
||||
/* Conversions */
|
||||
/* Conversions. Rounding is only done on the TO_REG variants. */
|
||||
static int lm78_in_conv[7] = {10000, 10000, 10000, 16892, 38000,
|
||||
-34768, -15050 };
|
||||
#define IN_TO_REG(val,nr) (((((val) * 100000 / lm78_in_conv[nr]) + 8) / 16) \
|
||||
& 0xff)
|
||||
#define IN_FROM_REG(val,nr) (((val) * 16 * lm78_in_conv[nr]) / 100000)
|
||||
|
||||
#define FAN_TO_REG(val) ((((val)==0)?255:((1350000+(val))/((val)*2))) & 0xff)
|
||||
#define FAN_FROM_REG(val) (((val)==0)?-1:\
|
||||
((val)==255)?0:(1350000 + (val))/((val)*2))
|
||||
#define FAN_TO_REG(val) ((val)==0?255:((1350000+(val))/((val)*2)) & 0xff)
|
||||
#define FAN_FROM_REG(val) ((val)==0?-1:(val)==255?0:1350000/((val)*2))
|
||||
|
||||
#define TEMP_TO_REG(val) (((val)<0?(val/10)&0xff:(val/10)) & 0xff)
|
||||
#define TEMP_TO_REG(val) (((val)<0?(((val)-5)/10)&0xff:((val)+5)/10) & 0xff)
|
||||
#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10)
|
||||
|
||||
#define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\
|
||||
|
||||
+6
-4
@@ -37,8 +37,8 @@
|
||||
#define TEMP_TO_REG(val) (((((val) + 2) / 5) << 7) & 0xff80)
|
||||
|
||||
/* Initial values */
|
||||
#define LM75_INIT_TEMP_OS 60
|
||||
#define LM75_INIT_TEMP_HYST 50
|
||||
#define LM75_INIT_TEMP_OS 600
|
||||
#define LM75_INIT_TEMP_HYST 500
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct lm75_data {
|
||||
@@ -170,8 +170,10 @@ int lm75_attach_adapter(struct i2c_adapter *adapter)
|
||||
err = 0;
|
||||
|
||||
/* Initialize the LM75 chip */
|
||||
lm75_write_value(new_client,LM75_REG_TEMP_OS,LM75_INIT_TEMP_OS);
|
||||
lm75_write_value(new_client,LM75_REG_TEMP_HYST,LM75_INIT_TEMP_HYST);
|
||||
lm75_write_value(new_client,LM75_REG_TEMP_OS,
|
||||
TEMP_TO_REG(LM75_INIT_TEMP_OS));
|
||||
lm75_write_value(new_client,LM75_REG_TEMP_HYST,
|
||||
TEMP_TO_REG(LM75_INIT_TEMP_HYST));
|
||||
lm75_write_value(new_client,LM75_REG_CONF,0);
|
||||
|
||||
continue;
|
||||
|
||||
+4
-5
@@ -63,18 +63,17 @@
|
||||
#define LM78_REG_CHIPID 0x49
|
||||
|
||||
|
||||
/* Conversions */
|
||||
/* Conversions. Rounding is only done on the TO_REG variants. */
|
||||
static int lm78_in_conv[7] = {10000, 10000, 10000, 16892, 38000,
|
||||
-34768, -15050 };
|
||||
#define IN_TO_REG(val,nr) (((((val) * 100000 / lm78_in_conv[nr]) + 8) / 16) \
|
||||
& 0xff)
|
||||
#define IN_FROM_REG(val,nr) (((val) * 16 * lm78_in_conv[nr]) / 100000)
|
||||
|
||||
#define FAN_TO_REG(val) ((((val)==0)?255:((1350000+(val))/((val)*2))) & 0xff)
|
||||
#define FAN_FROM_REG(val) (((val)==0)?-1:\
|
||||
((val)==255)?0:(1350000 + (val))/((val)*2))
|
||||
#define FAN_TO_REG(val) ((val)==0?255:((1350000+(val))/((val)*2)) & 0xff)
|
||||
#define FAN_FROM_REG(val) ((val)==0?-1:(val)==255?0:1350000/((val)*2))
|
||||
|
||||
#define TEMP_TO_REG(val) (((val)<0?(val/10)&0xff:(val/10)) & 0xff)
|
||||
#define TEMP_TO_REG(val) (((val)<0?(((val)-5)/10)&0xff:((val)+5)/10) & 0xff)
|
||||
#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10)
|
||||
|
||||
#define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\
|
||||
|
||||
Reference in new issue
Block a user