aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-05-01 11:28:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-05-01 11:28:26 -0400
commitc92758ceda477b1333fde35327cfa867dcc47bd1 (patch)
tree9bdb7e6a5a25b746f175c4ebfb9028ec91115bb6 /drivers/hwmon
parent03fc922f4085a0139f313831fe2dc6fed467cd2d (diff)
parent4f02f8220562591322c118d07a32bebf705318b7 (diff)
Merge branch 'release' of git://lm-sensors.org/kernel/mhoffman/hwmon-2.6
* 'release' of git://lm-sensors.org/kernel/mhoffman/hwmon-2.6: hwmon: (adt7473) minor cleanup / refactoring hwmon: (asb100) Remove some dead code hwmon: (lm75) Fix an incorrect comment hwmon: (w83793) VID and VRM handling cleanups hwmon: (w83l785ts) Don't ask the user to report failures hwmon: (smsc47b397) add a new chip id (0x8c)
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/adt7473.c45
-rw-r--r--drivers/hwmon/asb100.c4
-rw-r--r--drivers/hwmon/lm75.c5
-rw-r--r--drivers/hwmon/smsc47b397.c17
-rw-r--r--drivers/hwmon/w83793.c26
-rw-r--r--drivers/hwmon/w83l785ts.c4
6 files changed, 54 insertions, 47 deletions
diff --git a/drivers/hwmon/adt7473.c b/drivers/hwmon/adt7473.c
index 9587869bdba0..c1009d6f9796 100644
--- a/drivers/hwmon/adt7473.c
+++ b/drivers/hwmon/adt7473.c
@@ -422,18 +422,14 @@ static ssize_t show_volt(struct device *dev, struct device_attribute *devattr,
422 * number in the range -128 to 127, or as an unsigned number that must 422 * number in the range -128 to 127, or as an unsigned number that must
423 * be offset by 64. 423 * be offset by 64.
424 */ 424 */
425static int decode_temp(struct adt7473_data *data, u8 raw) 425static int decode_temp(u8 twos_complement, u8 raw)
426{ 426{
427 if (data->temp_twos_complement) 427 return twos_complement ? (s8)raw : raw - 64;
428 return (s8)raw;
429 return raw - 64;
430} 428}
431 429
432static u8 encode_temp(struct adt7473_data *data, int cooked) 430static u8 encode_temp(u8 twos_complement, int cooked)
433{ 431{
434 if (data->temp_twos_complement) 432 return twos_complement ? cooked & 0xFF : cooked + 64;
435 return (cooked & 0xFF);
436 return cooked + 64;
437} 433}
438 434
439static ssize_t show_temp_min(struct device *dev, 435static ssize_t show_temp_min(struct device *dev,
@@ -442,8 +438,9 @@ static ssize_t show_temp_min(struct device *dev,
442{ 438{
443 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 439 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
444 struct adt7473_data *data = adt7473_update_device(dev); 440 struct adt7473_data *data = adt7473_update_device(dev);
445 return sprintf(buf, "%d\n", 441 return sprintf(buf, "%d\n", 1000 * decode_temp(
446 1000 * decode_temp(data, data->temp_min[attr->index])); 442 data->temp_twos_complement,
443 data->temp_min[attr->index]));
447} 444}
448 445
449static ssize_t set_temp_min(struct device *dev, 446static ssize_t set_temp_min(struct device *dev,
@@ -455,7 +452,7 @@ static ssize_t set_temp_min(struct device *dev,
455 struct i2c_client *client = to_i2c_client(dev); 452 struct i2c_client *client = to_i2c_client(dev);
456 struct adt7473_data *data = i2c_get_clientdata(client); 453 struct adt7473_data *data = i2c_get_clientdata(client);
457 int temp = simple_strtol(buf, NULL, 10) / 1000; 454 int temp = simple_strtol(buf, NULL, 10) / 1000;
458 temp = encode_temp(data, temp); 455 temp = encode_temp(data->temp_twos_complement, temp);
459 456
460 mutex_lock(&data->lock); 457 mutex_lock(&data->lock);
461 data->temp_min[attr->index] = temp; 458 data->temp_min[attr->index] = temp;
@@ -472,8 +469,9 @@ static ssize_t show_temp_max(struct device *dev,
472{ 469{
473 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 470 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
474 struct adt7473_data *data = adt7473_update_device(dev); 471 struct adt7473_data *data = adt7473_update_device(dev);
475 return sprintf(buf, "%d\n", 472 return sprintf(buf, "%d\n", 1000 * decode_temp(
476 1000 * decode_temp(data, data->temp_max[attr->index])); 473 data->temp_twos_complement,
474 data->temp_max[attr->index]));
477} 475}
478 476
479static ssize_t set_temp_max(struct device *dev, 477static ssize_t set_temp_max(struct device *dev,
@@ -485,7 +483,7 @@ static ssize_t set_temp_max(struct device *dev,
485 struct i2c_client *client = to_i2c_client(dev); 483 struct i2c_client *client = to_i2c_client(dev);
486 struct adt7473_data *data = i2c_get_clientdata(client); 484 struct adt7473_data *data = i2c_get_clientdata(client);
487 int temp = simple_strtol(buf, NULL, 10) / 1000; 485 int temp = simple_strtol(buf, NULL, 10) / 1000;
488 temp = encode_temp(data, temp); 486 temp = encode_temp(data->temp_twos_complement, temp);
489 487
490 mutex_lock(&data->lock); 488 mutex_lock(&data->lock);
491 data->temp_max[attr->index] = temp; 489 data->temp_max[attr->index] = temp;
@@ -501,8 +499,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
501{ 499{
502 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 500 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
503 struct adt7473_data *data = adt7473_update_device(dev); 501 struct adt7473_data *data = adt7473_update_device(dev);
504 return sprintf(buf, "%d\n", 502 return sprintf(buf, "%d\n", 1000 * decode_temp(
505 1000 * decode_temp(data, data->temp[attr->index])); 503 data->temp_twos_complement,
504 data->temp[attr->index]));
506} 505}
507 506
508static ssize_t show_fan_min(struct device *dev, 507static ssize_t show_fan_min(struct device *dev,
@@ -671,8 +670,9 @@ static ssize_t show_temp_tmax(struct device *dev,
671{ 670{
672 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 671 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
673 struct adt7473_data *data = adt7473_update_device(dev); 672 struct adt7473_data *data = adt7473_update_device(dev);
674 return sprintf(buf, "%d\n", 673 return sprintf(buf, "%d\n", 1000 * decode_temp(
675 1000 * decode_temp(data, data->temp_tmax[attr->index])); 674 data->temp_twos_complement,
675 data->temp_tmax[attr->index]));
676} 676}
677 677
678static ssize_t set_temp_tmax(struct device *dev, 678static ssize_t set_temp_tmax(struct device *dev,
@@ -684,7 +684,7 @@ static ssize_t set_temp_tmax(struct device *dev,
684 struct i2c_client *client = to_i2c_client(dev); 684 struct i2c_client *client = to_i2c_client(dev);
685 struct adt7473_data *data = i2c_get_clientdata(client); 685 struct adt7473_data *data = i2c_get_clientdata(client);
686 int temp = simple_strtol(buf, NULL, 10) / 1000; 686 int temp = simple_strtol(buf, NULL, 10) / 1000;
687 temp = encode_temp(data, temp); 687 temp = encode_temp(data->temp_twos_complement, temp);
688 688
689 mutex_lock(&data->lock); 689 mutex_lock(&data->lock);
690 data->temp_tmax[attr->index] = temp; 690 data->temp_tmax[attr->index] = temp;
@@ -701,8 +701,9 @@ static ssize_t show_temp_tmin(struct device *dev,
701{ 701{
702 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 702 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
703 struct adt7473_data *data = adt7473_update_device(dev); 703 struct adt7473_data *data = adt7473_update_device(dev);
704 return sprintf(buf, "%d\n", 704 return sprintf(buf, "%d\n", 1000 * decode_temp(
705 1000 * decode_temp(data, data->temp_tmin[attr->index])); 705 data->temp_twos_complement,
706 data->temp_tmin[attr->index]));
706} 707}
707 708
708static ssize_t set_temp_tmin(struct device *dev, 709static ssize_t set_temp_tmin(struct device *dev,
@@ -714,7 +715,7 @@ static ssize_t set_temp_tmin(struct device *dev,
714 struct i2c_client *client = to_i2c_client(dev); 715 struct i2c_client *client = to_i2c_client(dev);
715 struct adt7473_data *data = i2c_get_clientdata(client); 716 struct adt7473_data *data = i2c_get_clientdata(client);
716 int temp = simple_strtol(buf, NULL, 10) / 1000; 717 int temp = simple_strtol(buf, NULL, 10) / 1000;
717 temp = encode_temp(data, temp); 718 temp = encode_temp(data->temp_twos_complement, temp);
718 719
719 mutex_lock(&data->lock); 720 mutex_lock(&data->lock);
720 data->temp_tmin[attr->index] = temp; 721 data->temp_tmin[attr->index] = temp;
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index 84712a22acea..fe2eea4d799b 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -953,12 +953,8 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
953static void asb100_init_client(struct i2c_client *client) 953static void asb100_init_client(struct i2c_client *client)
954{ 954{
955 struct asb100_data *data = i2c_get_clientdata(client); 955 struct asb100_data *data = i2c_get_clientdata(client);
956 int vid = 0;
957 956
958 vid = asb100_read_value(client, ASB100_REG_VID_FANDIV) & 0x0f;
959 vid |= (asb100_read_value(client, ASB100_REG_CHIPID) & 0x01) << 4;
960 data->vrm = vid_which_vrm(); 957 data->vrm = vid_which_vrm();
961 vid = vid_from_reg(vid, data->vrm);
962 958
963 /* Start monitoring */ 959 /* Start monitoring */
964 asb100_write_value(client, ASB100_REG_CONFIG, 960 asb100_write_value(client, ASB100_REG_CONFIG,
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 115f4090b98e..fa7696905154 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -248,7 +248,7 @@ static int lm75_detach_client(struct i2c_client *client)
248 248
249/* All registers are word-sized, except for the configuration register. 249/* All registers are word-sized, except for the configuration register.
250 LM75 uses a high-byte first convention, which is exactly opposite to 250 LM75 uses a high-byte first convention, which is exactly opposite to
251 the usual practice. */ 251 the SMBus standard. */
252static int lm75_read_value(struct i2c_client *client, u8 reg) 252static int lm75_read_value(struct i2c_client *client, u8 reg)
253{ 253{
254 if (reg == LM75_REG_CONF) 254 if (reg == LM75_REG_CONF)
@@ -257,9 +257,6 @@ static int lm75_read_value(struct i2c_client *client, u8 reg)
257 return swab16(i2c_smbus_read_word_data(client, reg)); 257 return swab16(i2c_smbus_read_word_data(client, reg));
258} 258}
259 259
260/* All registers are word-sized, except for the configuration register.
261 LM75 uses a high-byte first convention, which is exactly opposite to
262 the usual practice. */
263static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) 260static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value)
264{ 261{
265 if (reg == LM75_REG_CONF) 262 if (reg == LM75_REG_CONF)
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index f61d8f4185b2..eb03544c731c 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -335,11 +335,23 @@ exit:
335static int __init smsc47b397_find(unsigned short *addr) 335static int __init smsc47b397_find(unsigned short *addr)
336{ 336{
337 u8 id, rev; 337 u8 id, rev;
338 char *name;
338 339
339 superio_enter(); 340 superio_enter();
340 id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID); 341 id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
341 342
342 if ((id != 0x6f) && (id != 0x81) && (id != 0x85)) { 343 switch(id) {
344 case 0x81:
345 name = "SCH5307-NS";
346 break;
347 case 0x6f:
348 name = "LPC47B397-NC";
349 break;
350 case 0x85:
351 case 0x8c:
352 name = "SCH5317";
353 break;
354 default:
343 superio_exit(); 355 superio_exit();
344 return -ENODEV; 356 return -ENODEV;
345 } 357 }
@@ -352,8 +364,7 @@ static int __init smsc47b397_find(unsigned short *addr)
352 364
353 printk(KERN_INFO DRVNAME ": found SMSC %s " 365 printk(KERN_INFO DRVNAME ": found SMSC %s "
354 "(base address 0x%04x, revision %u)\n", 366 "(base address 0x%04x, revision %u)\n",
355 id == 0x81 ? "SCH5307-NS" : id == 0x85 ? "SCH5317" : 367 name, *addr, rev);
356 "LPC47B397-NC", *addr, rev);
357 368
358 superio_exit(); 369 superio_exit();
359 return 0; 370 return 0;
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index ee35af93b574..ed3c019b78c7 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -1024,10 +1024,9 @@ static struct sensor_device_attribute_2 w83793_vid[] = {
1024 SENSOR_ATTR_2(cpu0_vid, S_IRUGO, show_vid, NULL, NOT_USED, 0), 1024 SENSOR_ATTR_2(cpu0_vid, S_IRUGO, show_vid, NULL, NOT_USED, 0),
1025 SENSOR_ATTR_2(cpu1_vid, S_IRUGO, show_vid, NULL, NOT_USED, 1), 1025 SENSOR_ATTR_2(cpu1_vid, S_IRUGO, show_vid, NULL, NOT_USED, 1),
1026}; 1026};
1027static DEVICE_ATTR(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm);
1027 1028
1028static struct sensor_device_attribute_2 sda_single_files[] = { 1029static struct sensor_device_attribute_2 sda_single_files[] = {
1029 SENSOR_ATTR_2(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm,
1030 NOT_USED, NOT_USED),
1031 SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep, 1030 SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep,
1032 store_chassis_clear, ALARM_STATUS, 30), 1031 store_chassis_clear, ALARM_STATUS, 30),
1033 SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable, 1032 SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable,
@@ -1080,6 +1079,7 @@ static int w83793_detach_client(struct i2c_client *client)
1080 1079
1081 for (i = 0; i < ARRAY_SIZE(w83793_vid); i++) 1080 for (i = 0; i < ARRAY_SIZE(w83793_vid); i++)
1082 device_remove_file(dev, &w83793_vid[i].dev_attr); 1081 device_remove_file(dev, &w83793_vid[i].dev_attr);
1082 device_remove_file(dev, &dev_attr_vrm);
1083 1083
1084 for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++) 1084 for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++)
1085 device_remove_file(dev, &w83793_left_fan[i].dev_attr); 1085 device_remove_file(dev, &w83793_left_fan[i].dev_attr);
@@ -1282,7 +1282,6 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1282 /* Initialize the chip */ 1282 /* Initialize the chip */
1283 w83793_init_client(client); 1283 w83793_init_client(client);
1284 1284
1285 data->vrm = vid_which_vrm();
1286 /* 1285 /*
1287 Only fan 1-5 has their own input pins, 1286 Only fan 1-5 has their own input pins,
1288 Pwm 1-3 has their own pins 1287 Pwm 1-3 has their own pins
@@ -1293,7 +1292,9 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1293 val = w83793_read_value(client, W83793_REG_FANIN_CTRL); 1292 val = w83793_read_value(client, W83793_REG_FANIN_CTRL);
1294 1293
1295 /* check the function of pins 49-56 */ 1294 /* check the function of pins 49-56 */
1296 if (!(tmp & 0x80)) { 1295 if (tmp & 0x80) {
1296 data->has_vid |= 0x2; /* has VIDB */
1297 } else {
1297 data->has_pwm |= 0x18; /* pwm 4,5 */ 1298 data->has_pwm |= 0x18; /* pwm 4,5 */
1298 if (val & 0x01) { /* fan 6 */ 1299 if (val & 0x01) { /* fan 6 */
1299 data->has_fan |= 0x20; 1300 data->has_fan |= 0x20;
@@ -1309,13 +1310,15 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1309 } 1310 }
1310 } 1311 }
1311 1312
1313 /* check the function of pins 37-40 */
1314 if (!(tmp & 0x29))
1315 data->has_vid |= 0x1; /* has VIDA */
1312 if (0x08 == (tmp & 0x0c)) { 1316 if (0x08 == (tmp & 0x0c)) {
1313 if (val & 0x08) /* fan 9 */ 1317 if (val & 0x08) /* fan 9 */
1314 data->has_fan |= 0x100; 1318 data->has_fan |= 0x100;
1315 if (val & 0x10) /* fan 10 */ 1319 if (val & 0x10) /* fan 10 */
1316 data->has_fan |= 0x200; 1320 data->has_fan |= 0x200;
1317 } 1321 }
1318
1319 if (0x20 == (tmp & 0x30)) { 1322 if (0x20 == (tmp & 0x30)) {
1320 if (val & 0x20) /* fan 11 */ 1323 if (val & 0x20) /* fan 11 */
1321 data->has_fan |= 0x400; 1324 data->has_fan |= 0x400;
@@ -1359,13 +1362,6 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1359 if (tmp & 0x02) 1362 if (tmp & 0x02)
1360 data->has_temp |= 0x20; 1363 data->has_temp |= 0x20;
1361 1364
1362 /* Detect the VID usage and ignore unused input */
1363 tmp = w83793_read_value(client, W83793_REG_MFC);
1364 if (!(tmp & 0x29))
1365 data->has_vid |= 0x1; /* has VIDA */
1366 if (tmp & 0x80)
1367 data->has_vid |= 0x2; /* has VIDB */
1368
1369 /* Register sysfs hooks */ 1365 /* Register sysfs hooks */
1370 for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) { 1366 for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) {
1371 err = device_create_file(dev, 1367 err = device_create_file(dev,
@@ -1381,6 +1377,12 @@ static int w83793_detect(struct i2c_adapter *adapter, int address, int kind)
1381 if (err) 1377 if (err)
1382 goto exit_remove; 1378 goto exit_remove;
1383 } 1379 }
1380 if (data->has_vid) {
1381 data->vrm = vid_which_vrm();
1382 err = device_create_file(dev, &dev_attr_vrm);
1383 if (err)
1384 goto exit_remove;
1385 }
1384 1386
1385 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) { 1387 for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) {
1386 err = device_create_file(dev, &sda_single_files[i].dev_attr); 1388 err = device_create_file(dev, &sda_single_files[i].dev_attr);
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index 77f2d482888b..52e268e25dab 100644
--- a/drivers/hwmon/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
@@ -301,8 +301,8 @@ static u8 w83l785ts_read_value(struct i2c_client *client, u8 reg, u8 defval)
301 msleep(i); 301 msleep(i);
302 } 302 }
303 303
304 dev_err(&client->dev, "Couldn't read value from register 0x%02x. " 304 dev_err(&client->dev, "Couldn't read value from register 0x%02x.\n",
305 "Please report.\n", reg); 305 reg);
306 return defval; 306 return defval;
307} 307}
308 308