Changeset 2284
- Timestamp:
- 02/12/04 19:50:24 (9 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/kernel/chips/lm80.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/chips/lm80.c
r2069 r2284 22 22 #include <linux/module.h> 23 23 #include <linux/slab.h> 24 #include <linux/proc_fs.h>25 #include <linux/ioport.h>26 #include <linux/sysctl.h>27 #include <linux/types.h>28 24 #include <linux/i2c.h> 29 25 #include <linux/i2c-proc.h> 30 26 #include <linux/init.h> 31 #include <asm/errno.h>32 #include <asm/io.h>33 27 #include "version.h" 34 28 … … 76 70 Fixing this is just not worth it. */ 77 71 78 #define IN_TO_REG(val ,nr) (SENSORS_LIMIT((val),0,255))79 #define IN_FROM_REG(val ,nr) (val)72 #define IN_TO_REG(val) (SENSORS_LIMIT((val),0,255)) 73 #define IN_FROM_REG(val) (val) 80 74 81 75 static inline unsigned char FAN_TO_REG(unsigned rpm, unsigned div) … … 95 89 long res; 96 90 97 temp = temp >>4;98 if (temp < 0x0800) {99 res = (625 * (long) temp);100 } else {91 temp >>= 4; 92 if (temp < 0x0800) 93 res = 625 * (long) temp; 94 else 101 95 res = ((long) temp - 0x01000) * 625; 102 } 96 103 97 return res / 100; 104 98 } … … 115 109 #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) 116 110 117 /* For each registered LM80, we need to keep some data in memory. That118 data is pointed to by lm80_list[NR]->data. The structure itself is119 dynamically allocated, at the same time when a new lm80 client is120 allocated. */121 111 struct lm80_data { 122 112 int sysctl_id; … … 147 137 static int lm80_detach_client(struct i2c_client *client); 148 138 149 static int lm80_read_value(struct i2c_client *client, u8 register); 150 static int lm80_write_value(struct i2c_client *client, u8 register, 151 u8 value); 139 static int lm80_read_value(struct i2c_client *client, u8 reg); 140 static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value); 152 141 static void lm80_update_client(struct i2c_client *client); 153 142 static void lm80_init_client(struct i2c_client *client); … … 375 364 } 376 365 377 /* Called when we have found a new LM80. It should set limits, etc.*/366 /* Called when we have found a new LM80. */ 378 367 static void lm80_init_client(struct i2c_client *client) 379 368 { … … 465 454 else if (operation == SENSORS_PROC_REAL_READ) { 466 455 lm80_update_client(client); 467 results[0] = IN_FROM_REG(data->in_min[nr] , nr);468 results[1] = IN_FROM_REG(data->in_max[nr] , nr);469 results[2] = IN_FROM_REG(data->in[nr] , nr);456 results[0] = IN_FROM_REG(data->in_min[nr]); 457 results[1] = IN_FROM_REG(data->in_max[nr]); 458 results[2] = IN_FROM_REG(data->in[nr]); 470 459 *nrels_mag = 3; 471 460 } else if (operation == SENSORS_PROC_REAL_WRITE) { 472 461 if (*nrels_mag >= 1) { 473 data->in_min[nr] = IN_TO_REG(results[0] , nr);462 data->in_min[nr] = IN_TO_REG(results[0]); 474 463 lm80_write_value(client, LM80_REG_IN_MIN(nr), 475 464 data->in_min[nr]); 476 465 } 477 466 if (*nrels_mag >= 2) { 478 data->in_max[nr] = IN_TO_REG(results[1] , nr);467 data->in_max[nr] = IN_TO_REG(results[1]); 479 468 lm80_write_value(client, LM80_REG_IN_MAX(nr), 480 469 data->in_max[nr]);
