Commit adfeb6e9f46ded31b46fe406ad0dd6a9b4e0f7fe

Authored by Linus Torvalds

Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging

* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
  hwmon: (sysfs-interface) Update tempX_type attribute to be more generic
  hwmon: (adm1031) Fix coding style issues
  hwmon: (it87) Add IT8728F support
  hwmon: (coretemp) Add missing section annotations
  hwmon: (lm90) Add range check to set_update_interval
  hwmon: (lm63) Support extended lookup table of LM96163
  hwmon: (lm63) Expose automatic fan speed control lookup table
  hwmon: (lm63) Fix incorrect comment about I2C address
  hwmon: (lm63) LM64 has a dedicated pin for tachometer
  hwmon: (lm63) Add sensor type attribute for external sensor on LM96163
  hwmon: (lm63) Add support for update_interval sysfs attribute
  hwmon: (lm63) Add support for writing the external critical temperature
  hwmon: (lm63) Add support for unsigned upper temperature limits
  hwmon: (lm63) Add support for LM96163
  hwmon: (lm63) Add support for external temperature offset register
  hwmon: (lm63) Fix checkpatch errors
  hwmon: (max1111) Change sysfs interface to in[0-3]_input in millivolts

Showing 10 changed files Side-by-side Diff

Documentation/hwmon/it87
... ... @@ -26,6 +26,10 @@
26 26 Prefix: 'it8721'
27 27 Addresses scanned: from Super I/O config space (8 I/O ports)
28 28 Datasheet: Not publicly available
  29 + * IT8728F
  30 + Prefix: 'it8728'
  31 + Addresses scanned: from Super I/O config space (8 I/O ports)
  32 + Datasheet: Not publicly available
29 33 * SiS950 [clone of IT8705F]
30 34 Prefix: 'it87'
31 35 Addresses scanned: from Super I/O config space (8 I/O ports)
... ... @@ -71,7 +75,7 @@
71 75 -----------
72 76  
73 77 This driver implements support for the IT8705F, IT8712F, IT8716F,
74   -IT8718F, IT8720F, IT8721F, IT8726F, IT8758E and SiS950 chips.
  78 +IT8718F, IT8720F, IT8721F, IT8726F, IT8728F, IT8758E and SiS950 chips.
75 79  
76 80 These chips are 'Super I/O chips', supporting floppy disks, infrared ports,
77 81 joysticks and other miscellaneous stuff. For hardware monitoring, they
... ... @@ -105,6 +109,9 @@
105 109 for AMD power sequencing. Therefore the chip will appear as IT8716F
106 110 to userspace applications.
107 111  
  112 +The IT8728F is considered compatible with the IT8721F, until a datasheet
  113 +becomes available (hopefully.)
  114 +
108 115 Temperatures are measured in degrees Celsius. An alarm is triggered once
109 116 when the Overtemperature Shutdown limit is crossed.
110 117  
... ... @@ -121,8 +128,8 @@
121 128 maximum limit. Note that minimum in this case always means 'closest to
122 129 zero'; this is important for negative voltage measurements. All voltage
123 130 inputs can measure voltages between 0 and 4.08 volts, with a resolution of
124   -0.016 volt (except IT8721F/IT8758E: 0.012 volt.) The battery voltage in8 does
125   -not have limit registers.
  131 +0.016 volt (except IT8721F/IT8758E and IT8728F: 0.012 volt.) The battery
  132 +voltage in8 does not have limit registers.
126 133  
127 134 On the IT8721F/IT8758E, some voltage inputs are internal and scaled inside
128 135 the chip (in7, in8 and optionally in3). The driver handles this transparently
Documentation/hwmon/lm63
... ... @@ -12,6 +12,11 @@
12 12 Addresses scanned: I2C 0x18 and 0x4e
13 13 Datasheet: Publicly available at the National Semiconductor website
14 14 http://www.national.com/pf/LM/LM64.html
  15 + * National Semiconductor LM96163
  16 + Prefix: 'lm96163'
  17 + Addresses scanned: I2C 0x4c
  18 + Datasheet: Publicly available at the National Semiconductor website
  19 + http://www.national.com/pf/LM/LM96163.html
15 20  
16 21 Author: Jean Delvare <khali@linux-fr.org>
17 22  
18 23  
19 24  
... ... @@ -49,17 +54,25 @@
49 54 Note that the pin used for fan monitoring is shared with an alert out
50 55 function. Depending on how the board designer wanted to use the chip, fan
51 56 speed monitoring will or will not be possible. The proper chip configuration
52   -is left to the BIOS, and the driver will blindly trust it.
  57 +is left to the BIOS, and the driver will blindly trust it. Only the original
  58 +LM63 suffers from this limitation, the LM64 and LM96163 have separate pins
  59 +for fan monitoring and alert out. On the LM64, monitoring is always enabled;
  60 +on the LM96163 it can be disabled.
53 61  
54 62 A PWM output can be used to control the speed of the fan. The LM63 has two
55 63 PWM modes: manual and automatic. Automatic mode is not fully implemented yet
56 64 (you cannot define your custom PWM/temperature curve), and mode change isn't
57 65 supported either.
58 66  
59   -The lm63 driver will not update its values more frequently than every
60   -second; reading them more often will do no harm, but will return 'old'
61   -values.
  67 +The lm63 driver will not update its values more frequently than configured with
  68 +the update_interval sysfs attribute; reading them more often will do no harm,
  69 +but will return 'old' values. Values in the automatic fan control lookup table
  70 +(attributes pwm1_auto_*) have their own independent lifetime of 5 seconds.
62 71  
63 72 The LM64 is effectively an LM63 with GPIO lines. The driver does not
64 73 support these GPIO lines at present.
  74 +
  75 +The LM96163 is an enhanced version of LM63 with improved temperature accuracy
  76 +and better PWM resolution. For LM96163, the external temperature sensor type is
  77 +configurable as CPU embedded diode(1) or 3904 transistor(2).
Documentation/hwmon/sysfs-interface
... ... @@ -304,7 +304,7 @@
304 304 temp[1-*]_type Sensor type selection.
305 305 Integers 1 to 6
306 306 RW
307   - 1: PII/Celeron Diode
  307 + 1: CPU embedded diode
308 308 2: 3904 transistor
309 309 3: thermal diode
310 310 4: thermistor
drivers/hwmon/Kconfig
... ... @@ -474,8 +474,8 @@
474 474 select HWMON_VID
475 475 help
476 476 If you say yes here you get support for ITE IT8705F, IT8712F,
477   - IT8716F, IT8718F, IT8720F, IT8721F, IT8726F and IT8758E sensor
478   - chips, and the SiS960 clone.
  477 + IT8716F, IT8718F, IT8720F, IT8721F, IT8726F, IT8728F and IT8758E
  478 + sensor chips, and the SiS960 clone.
479 479  
480 480 This driver can also be built as a module. If so, the module
481 481 will be called it87.
482 482  
... ... @@ -515,11 +515,11 @@
515 515 will be called lineage-pem.
516 516  
517 517 config SENSORS_LM63
518   - tristate "National Semiconductor LM63 and LM64"
  518 + tristate "National Semiconductor LM63 and compatibles"
519 519 depends on I2C
520 520 help
521 521 If you say yes here you get support for the National
522   - Semiconductor LM63 and LM64 remote diode digital temperature
  522 + Semiconductor LM63, LM64, and LM96163 remote diode digital temperature
523 523 sensors with integrated fan control. Such chips are found
524 524 on the Tyan S4882 (Thunder K8QS Pro) motherboard, among
525 525 others.
drivers/hwmon/adm1031.c
... ... @@ -155,7 +155,8 @@
155 155 #define TEMP_OFFSET_FROM_REG(val) TEMP_FROM_REG((val) < 0 ? \
156 156 (val) | 0x70 : (val))
157 157  
158   -#define FAN_FROM_REG(reg, div) ((reg) ? (11250 * 60) / ((reg) * (div)) : 0)
  158 +#define FAN_FROM_REG(reg, div) ((reg) ? \
  159 + (11250 * 60) / ((reg) * (div)) : 0)
159 160  
160 161 static int FAN_TO_REG(int reg, int div)
161 162 {
... ... @@ -174,8 +175,8 @@
174 175 (((reg) & 0x1F) | (((val) << 5) & 0xe0))
175 176  
176 177 #define AUTO_TEMP_MIN_TO_REG(val, reg) \
177   - ((((val)/500) & 0xf8)|((reg) & 0x7))
178   -#define AUTO_TEMP_RANGE_FROM_REG(reg) (5000 * (1<< ((reg)&0x7)))
  178 + ((((val) / 500) & 0xf8) | ((reg) & 0x7))
  179 +#define AUTO_TEMP_RANGE_FROM_REG(reg) (5000 * (1 << ((reg) & 0x7)))
179 180 #define AUTO_TEMP_MIN_FROM_REG(reg) (1000 * ((((reg) >> 3) & 0x1f) << 2))
180 181  
181 182 #define AUTO_TEMP_MIN_FROM_REG_DEG(reg) ((((reg) >> 3) & 0x1f) << 2)
... ... @@ -202,7 +203,7 @@
202 203  
203 204 /* FAN auto control */
204 205 #define GET_FAN_AUTO_BITFIELD(data, idx) \
205   - (*(data)->chan_select_table)[FAN_CHAN_FROM_REG((data)->conf1)][idx%2]
  206 + (*(data)->chan_select_table)[FAN_CHAN_FROM_REG((data)->conf1)][idx % 2]
206 207  
207 208 /* The tables below contains the possible values for the auto fan
208 209 * control bitfields. the index in the table is the register value.
... ... @@ -230,7 +231,7 @@
230 231 */
231 232 static int
232 233 get_fan_auto_nearest(struct adm1031_data *data,
233   - int chan, u8 val, u8 reg, u8 * new_reg)
  234 + int chan, u8 val, u8 reg, u8 *new_reg)
234 235 {
235 236 int i;
236 237 int first_match = -1, exact_match = -1;
237 238  
238 239  
239 240  
... ... @@ -258,13 +259,13 @@
258 259 }
259 260 }
260 261  
261   - if (exact_match >= 0) {
  262 + if (exact_match >= 0)
262 263 *new_reg = exact_match;
263   - } else if (first_match >= 0) {
  264 + else if (first_match >= 0)
264 265 *new_reg = first_match;
265   - } else {
  266 + else
266 267 return -EINVAL;
267   - }
  268 +
268 269 return 0;
269 270 }
270 271  
271 272  
272 273  
273 274  
... ... @@ -283,23 +284,28 @@
283 284 struct i2c_client *client = to_i2c_client(dev);
284 285 struct adm1031_data *data = i2c_get_clientdata(client);
285 286 int nr = to_sensor_dev_attr(attr)->index;
286   - int val = simple_strtol(buf, NULL, 10);
  287 + long val;
287 288 u8 reg;
288 289 int ret;
289 290 u8 old_fan_mode;
290 291  
  292 + ret = kstrtol(buf, 10, &val);
  293 + if (ret)
  294 + return ret;
  295 +
291 296 old_fan_mode = data->conf1;
292 297  
293 298 mutex_lock(&data->update_lock);
294 299  
295   - if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, &reg))) {
  300 + ret = get_fan_auto_nearest(data, nr, val, data->conf1, &reg);
  301 + if (ret) {
296 302 mutex_unlock(&data->update_lock);
297 303 return ret;
298 304 }
299 305 data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1);
300 306 if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) ^
301 307 (old_fan_mode & ADM1031_CONF1_AUTO_MODE)) {
302   - if (data->conf1 & ADM1031_CONF1_AUTO_MODE){
  308 + if (data->conf1 & ADM1031_CONF1_AUTO_MODE) {
303 309 /* Switch to Auto Fan Mode
304 310 * Save PWM registers
305 311 * Set PWM registers to 33% Both */
306 312  
... ... @@ -350,8 +356,13 @@
350 356 struct i2c_client *client = to_i2c_client(dev);
351 357 struct adm1031_data *data = i2c_get_clientdata(client);
352 358 int nr = to_sensor_dev_attr(attr)->index;
353   - int val = simple_strtol(buf, NULL, 10);
  359 + long val;
  360 + int ret;
354 361  
  362 + ret = kstrtol(buf, 10, &val);
  363 + if (ret)
  364 + return ret;
  365 +
355 366 mutex_lock(&data->update_lock);
356 367 data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]);
357 368 adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr),
358 369  
359 370  
... ... @@ -374,10 +385,16 @@
374 385 struct i2c_client *client = to_i2c_client(dev);
375 386 struct adm1031_data *data = i2c_get_clientdata(client);
376 387 int nr = to_sensor_dev_attr(attr)->index;
377   - int val = simple_strtol(buf, NULL, 10);
  388 + long val;
  389 + int ret;
378 390  
  391 + ret = kstrtol(buf, 10, &val);
  392 + if (ret)
  393 + return ret;
  394 +
379 395 mutex_lock(&data->update_lock);
380   - data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]);
  396 + data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr],
  397 + data->pwm[nr]);
381 398 adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr),
382 399 data->temp_max[nr]);
383 400 mutex_unlock(&data->update_lock);
384 401  
... ... @@ -410,9 +427,13 @@
410 427 struct i2c_client *client = to_i2c_client(dev);
411 428 struct adm1031_data *data = i2c_get_clientdata(client);
412 429 int nr = to_sensor_dev_attr(attr)->index;
413   - int val = simple_strtol(buf, NULL, 10);
414   - int reg;
  430 + long val;
  431 + int ret, reg;
415 432  
  433 + ret = kstrtol(buf, 10, &val);
  434 + if (ret)
  435 + return ret;
  436 +
416 437 mutex_lock(&data->update_lock);
417 438 if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) &&
418 439 (((val>>4) & 0xf) != 5)) {
419 440  
... ... @@ -449,9 +470,13 @@
449 470  
450 471 if (data->conf1 & ADM1031_CONF1_AUTO_MODE) {
451 472 switch (data->conf1 & 0x60) {
452   - case 0x00: /* remote temp1 controls fan1 remote temp2 controls fan2 */
  473 + case 0x00:
  474 + /*
  475 + * remote temp1 controls fan1,
  476 + * remote temp2 controls fan2
  477 + */
453 478 res = data->temp[chan+1] >=
454   - AUTO_TEMP_MIN_FROM_REG_DEG(data->auto_temp[chan+1]);
  479 + AUTO_TEMP_MIN_FROM_REG_DEG(data->auto_temp[chan+1]);
455 480 break;
456 481 case 0x20: /* remote temp1 controls both fans */
457 482 res =
458 483  
... ... @@ -515,8 +540,13 @@
515 540 struct i2c_client *client = to_i2c_client(dev);
516 541 struct adm1031_data *data = i2c_get_clientdata(client);
517 542 int nr = to_sensor_dev_attr(attr)->index;
518   - int val = simple_strtol(buf, NULL, 10);
  543 + long val;
  544 + int ret;
519 545  
  546 + ret = kstrtol(buf, 10, &val);
  547 + if (ret)
  548 + return ret;
  549 +
520 550 mutex_lock(&data->update_lock);
521 551 if (val) {
522 552 data->fan_min[nr] =
523 553  
524 554  
... ... @@ -534,11 +564,16 @@
534 564 struct i2c_client *client = to_i2c_client(dev);
535 565 struct adm1031_data *data = i2c_get_clientdata(client);
536 566 int nr = to_sensor_dev_attr(attr)->index;
537   - int val = simple_strtol(buf, NULL, 10);
  567 + long val;
538 568 u8 tmp;
539 569 int old_div;
540 570 int new_min;
  571 + int ret;
541 572  
  573 + ret = kstrtol(buf, 10, &val);
  574 + if (ret)
  575 + return ret;
  576 +
542 577 tmp = val == 8 ? 0xc0 :
543 578 val == 4 ? 0x80 :
544 579 val == 2 ? 0x40 :
545 580  
... ... @@ -631,9 +666,13 @@
631 666 struct i2c_client *client = to_i2c_client(dev);
632 667 struct adm1031_data *data = i2c_get_clientdata(client);
633 668 int nr = to_sensor_dev_attr(attr)->index;
634   - int val;
  669 + long val;
  670 + int ret;
635 671  
636   - val = simple_strtol(buf, NULL, 10);
  672 + ret = kstrtol(buf, 10, &val);
  673 + if (ret)
  674 + return ret;
  675 +
637 676 val = SENSORS_LIMIT(val, -15000, 15000);
638 677 mutex_lock(&data->update_lock);
639 678 data->temp_offset[nr] = TEMP_OFFSET_TO_REG(val);
640 679  
... ... @@ -648,9 +687,13 @@
648 687 struct i2c_client *client = to_i2c_client(dev);
649 688 struct adm1031_data *data = i2c_get_clientdata(client);
650 689 int nr = to_sensor_dev_attr(attr)->index;
651   - int val;
  690 + long val;
  691 + int ret;
652 692  
653   - val = simple_strtol(buf, NULL, 10);
  693 + ret = kstrtol(buf, 10, &val);
  694 + if (ret)
  695 + return ret;
  696 +
654 697 val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
655 698 mutex_lock(&data->update_lock);
656 699 data->temp_min[nr] = TEMP_TO_REG(val);
657 700  
... ... @@ -665,9 +708,13 @@
665 708 struct i2c_client *client = to_i2c_client(dev);
666 709 struct adm1031_data *data = i2c_get_clientdata(client);
667 710 int nr = to_sensor_dev_attr(attr)->index;
668   - int val;
  711 + long val;
  712 + int ret;
669 713  
670   - val = simple_strtol(buf, NULL, 10);
  714 + ret = kstrtol(buf, 10, &val);
  715 + if (ret)
  716 + return ret;
  717 +
671 718 val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
672 719 mutex_lock(&data->update_lock);
673 720 data->temp_max[nr] = TEMP_TO_REG(val);
674 721  
... ... @@ -682,9 +729,13 @@
682 729 struct i2c_client *client = to_i2c_client(dev);
683 730 struct adm1031_data *data = i2c_get_clientdata(client);
684 731 int nr = to_sensor_dev_attr(attr)->index;
685   - int val;
  732 + long val;
  733 + int ret;
686 734  
687   - val = simple_strtol(buf, NULL, 10);
  735 + ret = kstrtol(buf, 10, &val);
  736 + if (ret)
  737 + return ret;
  738 +
688 739 val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
689 740 mutex_lock(&data->update_lock);
690 741 data->temp_crit[nr] = TEMP_TO_REG(val);
... ... @@ -711,7 +762,8 @@
711 762 temp_reg(3);
712 763  
713 764 /* Alarms */
714   -static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
  765 +static ssize_t show_alarms(struct device *dev, struct device_attribute *attr,
  766 + char *buf)
715 767 {
716 768 struct adm1031_data *data = adm1031_update_device(dev);
717 769 return sprintf(buf, "%d\n", data->alarm);
718 770  
... ... @@ -919,12 +971,13 @@
919 971 adm1031_init_client(client);
920 972  
921 973 /* Register sysfs hooks */
922   - if ((err = sysfs_create_group(&client->dev.kobj, &adm1031_group)))
  974 + err = sysfs_create_group(&client->dev.kobj, &adm1031_group);
  975 + if (err)
923 976 goto exit_free;
924 977  
925 978 if (data->chip_type == adm1031) {
926   - if ((err = sysfs_create_group(&client->dev.kobj,
927   - &adm1031_group_opt)))
  979 + err = sysfs_create_group(&client->dev.kobj, &adm1031_group_opt);
  980 + if (err)
928 981 goto exit_remove;
929 982 }
930 983  
931 984  
... ... @@ -970,14 +1023,13 @@
970 1023 }
971 1024 /* Initialize the ADM1031 chip (enables fan speed reading ) */
972 1025 read_val = adm1031_read_value(client, ADM1031_REG_CONF2);
973   - if ((read_val | mask) != read_val) {
974   - adm1031_write_value(client, ADM1031_REG_CONF2, read_val | mask);
975   - }
  1026 + if ((read_val | mask) != read_val)
  1027 + adm1031_write_value(client, ADM1031_REG_CONF2, read_val | mask);
976 1028  
977 1029 read_val = adm1031_read_value(client, ADM1031_REG_CONF1);
978 1030 if ((read_val | ADM1031_CONF1_MONITOR_ENABLE) != read_val) {
979   - adm1031_write_value(client, ADM1031_REG_CONF1, read_val |
980   - ADM1031_CONF1_MONITOR_ENABLE);
  1031 + adm1031_write_value(client, ADM1031_REG_CONF1,
  1032 + read_val | ADM1031_CONF1_MONITOR_ENABLE);
981 1033 }
982 1034  
983 1035 /* Read the chip's update rate */
... ... @@ -1024,8 +1076,7 @@
1024 1076 /* oldh is actually newer */
1025 1077 if (newh != oldh)
1026 1078 dev_warn(&client->dev,
1027   - "Remote temperature may be "
1028   - "wrong.\n");
  1079 + "Remote temperature may be wrong.\n");
1029 1080 #endif
1030 1081 }
1031 1082 data->temp[chan] = newh;
1032 1083  
1033 1084  
1034 1085  
1035 1086  
1036 1087  
1037 1088  
... ... @@ -1052,22 +1103,24 @@
1052 1103 data->conf2 = adm1031_read_value(client, ADM1031_REG_CONF2);
1053 1104  
1054 1105 data->alarm = adm1031_read_value(client, ADM1031_REG_STATUS(0))
1055   - | (adm1031_read_value(client, ADM1031_REG_STATUS(1))
1056   - << 8);
1057   - if (data->chip_type == adm1030) {
  1106 + | (adm1031_read_value(client, ADM1031_REG_STATUS(1)) << 8);
  1107 + if (data->chip_type == adm1030)
1058 1108 data->alarm &= 0xc0ff;
1059   - }
1060 1109  
1061   - for (chan=0; chan<(data->chip_type == adm1030 ? 1 : 2); chan++) {
  1110 + for (chan = 0; chan < (data->chip_type == adm1030 ? 1 : 2);
  1111 + chan++) {
1062 1112 data->fan_div[chan] =
1063   - adm1031_read_value(client, ADM1031_REG_FAN_DIV(chan));
  1113 + adm1031_read_value(client,
  1114 + ADM1031_REG_FAN_DIV(chan));
1064 1115 data->fan_min[chan] =
1065   - adm1031_read_value(client, ADM1031_REG_FAN_MIN(chan));
  1116 + adm1031_read_value(client,
  1117 + ADM1031_REG_FAN_MIN(chan));
1066 1118 data->fan[chan] =
1067   - adm1031_read_value(client, ADM1031_REG_FAN_SPEED(chan));
  1119 + adm1031_read_value(client,
  1120 + ADM1031_REG_FAN_SPEED(chan));
1068 1121 data->pwm[chan] =
1069   - 0xf & (adm1031_read_value(client, ADM1031_REG_PWM) >>
1070   - (4*chan));
  1122 + (adm1031_read_value(client,
  1123 + ADM1031_REG_PWM) >> (4 * chan)) & 0x0f;
1071 1124 }
1072 1125 data->last_updated = jiffies;
1073 1126 data->valid = 1;
drivers/hwmon/coretemp.c
... ... @@ -190,7 +190,8 @@
190 190 return tdata->valid ? sprintf(buf, "%d\n", tdata->temp) : -EAGAIN;
191 191 }
192 192  
193   -static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
  193 +static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id,
  194 + struct device *dev)
194 195 {
195 196 /* The 100C is default for both mobile and non mobile CPUs */
196 197  
... ... @@ -284,7 +285,8 @@
284 285 return tjmax;
285 286 }
286 287  
287   -static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
  288 +static int __cpuinit get_tjmax(struct cpuinfo_x86 *c, u32 id,
  289 + struct device *dev)
288 290 {
289 291 int err;
290 292 u32 eax, edx;
... ... @@ -323,7 +325,8 @@
323 325 return adjust_tjmax(c, id, dev);
324 326 }
325 327  
326   -static int create_name_attr(struct platform_data *pdata, struct device *dev)
  328 +static int __devinit create_name_attr(struct platform_data *pdata,
  329 + struct device *dev)
327 330 {
328 331 sysfs_attr_init(&pdata->name_attr.attr);
329 332 pdata->name_attr.attr.name = "name";
... ... @@ -332,8 +335,8 @@
332 335 return device_create_file(dev, &pdata->name_attr);
333 336 }
334 337  
335   -static int create_core_attrs(struct temp_data *tdata, struct device *dev,
336   - int attr_no)
  338 +static int __cpuinit create_core_attrs(struct temp_data *tdata,
  339 + struct device *dev, int attr_no)
337 340 {
338 341 int err, i;
339 342 static ssize_t (*const rd_ptr[TOTAL_ATTRS]) (struct device *dev,
... ... @@ -383,7 +386,7 @@
383 386 return 0;
384 387 }
385 388  
386   -static struct platform_device *coretemp_get_pdev(unsigned int cpu)
  389 +static struct platform_device __cpuinit *coretemp_get_pdev(unsigned int cpu)
387 390 {
388 391 u16 phys_proc_id = TO_PHYS_ID(cpu);
389 392 struct pdev_entry *p;
... ... @@ -400,7 +403,8 @@
400 403 return NULL;
401 404 }
402 405  
403   -static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag)
  406 +static struct temp_data __cpuinit *init_temp_data(unsigned int cpu,
  407 + int pkg_flag)
404 408 {
405 409 struct temp_data *tdata;
406 410  
... ... @@ -418,7 +422,7 @@
418 422 return tdata;
419 423 }
420 424  
421   -static int create_core_data(struct platform_device *pdev,
  425 +static int __cpuinit create_core_data(struct platform_device *pdev,
422 426 unsigned int cpu, int pkg_flag)
423 427 {
424 428 struct temp_data *tdata;
... ... @@ -489,7 +493,7 @@
489 493 return err;
490 494 }
491 495  
492   -static void coretemp_add_core(unsigned int cpu, int pkg_flag)
  496 +static void __cpuinit coretemp_add_core(unsigned int cpu, int pkg_flag)
493 497 {
494 498 struct platform_device *pdev = coretemp_get_pdev(cpu);
495 499 int err;
... ... @@ -618,7 +622,7 @@
618 622 return err;
619 623 }
620 624  
621   -static void coretemp_device_remove(unsigned int cpu)
  625 +static void __cpuinit coretemp_device_remove(unsigned int cpu)
622 626 {
623 627 struct pdev_entry *p, *n;
624 628 u16 phys_proc_id = TO_PHYS_ID(cpu);
... ... @@ -634,7 +638,7 @@
634 638 mutex_unlock(&pdev_list_mutex);
635 639 }
636 640  
637   -static bool is_any_core_online(struct platform_data *pdata)
  641 +static bool __cpuinit is_any_core_online(struct platform_data *pdata)
638 642 {
639 643 int i;
640 644  
drivers/hwmon/it87.c
... ... @@ -17,6 +17,7 @@
17 17 * IT8720F Super I/O chip w/LPC interface
18 18 * IT8721F Super I/O chip w/LPC interface
19 19 * IT8726F Super I/O chip w/LPC interface
  20 + * IT8728F Super I/O chip w/LPC interface
20 21 * IT8758E Super I/O chip w/LPC interface
21 22 * Sis950 A clone of the IT8705F
22 23 *
... ... @@ -58,7 +59,7 @@
58 59  
59 60 #define DRVNAME "it87"
60 61  
61   -enum chips { it87, it8712, it8716, it8718, it8720, it8721 };
  62 +enum chips { it87, it8712, it8716, it8718, it8720, it8721, it8728 };
62 63  
63 64 static unsigned short force_id;
64 65 module_param(force_id, ushort, 0);
... ... @@ -135,6 +136,7 @@
135 136 #define IT8720F_DEVID 0x8720
136 137 #define IT8721F_DEVID 0x8721
137 138 #define IT8726F_DEVID 0x8726
  139 +#define IT8728F_DEVID 0x8728
138 140 #define IT87_ACT_REG 0x30
139 141 #define IT87_BASE_REG 0x60
140 142  
141 143  
... ... @@ -274,11 +276,31 @@
274 276 s8 auto_temp[3][5]; /* [nr][0] is point1_temp_hyst */
275 277 };
276 278  
  279 +static inline int has_12mv_adc(const struct it87_data *data)
  280 +{
  281 + /*
  282 + * IT8721F and later have a 12 mV ADC, also with internal scaling
  283 + * on selected inputs.
  284 + */
  285 + return data->type == it8721
  286 + || data->type == it8728;
  287 +}
  288 +
  289 +static inline int has_newer_autopwm(const struct it87_data *data)
  290 +{
  291 + /*
  292 + * IT8721F and later have separate registers for the temperature
  293 + * mapping and the manual duty cycle.
  294 + */
  295 + return data->type == it8721
  296 + || data->type == it8728;
  297 +}
  298 +
277 299 static u8 in_to_reg(const struct it87_data *data, int nr, long val)
278 300 {
279 301 long lsb;
280 302  
281   - if (data->type == it8721) {
  303 + if (has_12mv_adc(data)) {
282 304 if (data->in_scaled & (1 << nr))
283 305 lsb = 24;
284 306 else
... ... @@ -292,7 +314,7 @@
292 314  
293 315 static int in_from_reg(const struct it87_data *data, int nr, int val)
294 316 {
295   - if (data->type == it8721) {
  317 + if (has_12mv_adc(data)) {
296 318 if (data->in_scaled & (1 << nr))
297 319 return val * 24;
298 320 else
... ... @@ -329,7 +351,7 @@
329 351  
330 352 static u8 pwm_to_reg(const struct it87_data *data, long val)
331 353 {
332   - if (data->type == it8721)
  354 + if (has_newer_autopwm(data))
333 355 return val;
334 356 else
335 357 return val >> 1;
... ... @@ -337,7 +359,7 @@
337 359  
338 360 static int pwm_from_reg(const struct it87_data *data, u8 reg)
339 361 {
340   - if (data->type == it8721)
  362 + if (has_newer_autopwm(data))
341 363 return reg;
342 364 else
343 365 return (reg & 0x7f) << 1;
... ... @@ -374,7 +396,8 @@
374 396 || data->type == it8716
375 397 || data->type == it8718
376 398 || data->type == it8720
377   - || data->type == it8721;
  399 + || data->type == it8721
  400 + || data->type == it8728;
378 401 }
379 402  
380 403 static inline int has_old_autopwm(const struct it87_data *data)
... ... @@ -842,7 +865,7 @@
842 865 data->fan_main_ctrl);
843 866 } else {
844 867 if (val == 1) /* Manual mode */
845   - data->pwm_ctrl[nr] = data->type == it8721 ?
  868 + data->pwm_ctrl[nr] = has_newer_autopwm(data) ?
846 869 data->pwm_temp_map[nr] :
847 870 data->pwm_duty[nr];
848 871 else /* Automatic mode */
... ... @@ -870,7 +893,7 @@
870 893 return -EINVAL;
871 894  
872 895 mutex_lock(&data->update_lock);
873   - if (data->type == it8721) {
  896 + if (has_newer_autopwm(data)) {
874 897 /* If we are in automatic mode, the PWM duty cycle register
875 898 * is read-only so we can't write the value */
876 899 if (data->pwm_ctrl[nr] & 0x80) {
... ... @@ -1311,8 +1334,8 @@
1311 1334 struct it87_data *data = dev_get_drvdata(dev);
1312 1335 int nr = to_sensor_dev_attr(attr)->index;
1313 1336  
1314   - return sprintf(buf, "%s\n", data->type == it8721 ? labels_it8721[nr]
1315   - : labels[nr]);
  1337 + return sprintf(buf, "%s\n", has_12mv_adc(data) ? labels_it8721[nr]
  1338 + : labels[nr]);
1316 1339 }
1317 1340 static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 0);
1318 1341 static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 1);
... ... @@ -1605,6 +1628,9 @@
1605 1628 case IT8721F_DEVID:
1606 1629 sio_data->type = it8721;
1607 1630 break;
  1631 + case IT8728F_DEVID:
  1632 + sio_data->type = it8728;
  1633 + break;
1608 1634 case 0xffff: /* No device at all */
1609 1635 goto exit;
1610 1636 default:
... ... @@ -1646,8 +1672,11 @@
1646 1672 superio_select(GPIO);
1647 1673  
1648 1674 reg = superio_inb(IT87_SIO_GPIO3_REG);
1649   - if (sio_data->type == it8721) {
1650   - /* The IT8721F/IT8758E doesn't have VID pins at all */
  1675 + if (sio_data->type == it8721 || sio_data->type == it8728) {
  1676 + /*
  1677 + * The IT8721F/IT8758E doesn't have VID pins at all,
  1678 + * not sure about the IT8728F.
  1679 + */
1651 1680 sio_data->skip_vid = 1;
1652 1681 } else {
1653 1682 /* We need at least 4 VID pins */
... ... @@ -1692,7 +1721,8 @@
1692 1721 }
1693 1722 if (reg & (1 << 0))
1694 1723 sio_data->internal |= (1 << 0);
1695   - if ((reg & (1 << 1)) || sio_data->type == it8721)
  1724 + if ((reg & (1 << 1)) || sio_data->type == it8721 ||
  1725 + sio_data->type == it8728)
1696 1726 sio_data->internal |= (1 << 1);
1697 1727  
1698 1728 sio_data->beep_pin = superio_inb(IT87_SIO_BEEP_PIN_REG) & 0x3f;
... ... @@ -1770,6 +1800,7 @@
1770 1800 "it8718",
1771 1801 "it8720",
1772 1802 "it8721",
  1803 + "it8728",
1773 1804 };
1774 1805  
1775 1806 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
... ... @@ -1807,7 +1838,7 @@
1807 1838 enable_pwm_interface = it87_check_pwm(dev);
1808 1839  
1809 1840 /* Starting with IT8721F, we handle scaling of internal voltages */
1810   - if (data->type == it8721) {
  1841 + if (has_12mv_adc(data)) {
1811 1842 if (sio_data->internal & (1 << 0))
1812 1843 data->in_scaled |= (1 << 3); /* in3 is AVCC */
1813 1844 if (sio_data->internal & (1 << 1))
... ... @@ -2093,7 +2124,7 @@
2093 2124 static void it87_update_pwm_ctrl(struct it87_data *data, int nr)
2094 2125 {
2095 2126 data->pwm_ctrl[nr] = it87_read_value(data, IT87_REG_PWM(nr));
2096   - if (data->type == it8721) {
  2127 + if (has_newer_autopwm(data)) {
2097 2128 data->pwm_temp_map[nr] = data->pwm_ctrl[nr] & 0x03;
2098 2129 data->pwm_duty[nr] = it87_read_value(data,
2099 2130 IT87_REG_PWM_DUTY(nr));
drivers/hwmon/lm63.c
... ... @@ -47,10 +47,14 @@
47 47 #include <linux/err.h>
48 48 #include <linux/mutex.h>
49 49 #include <linux/sysfs.h>
  50 +#include <linux/types.h>
50 51  
51 52 /*
52 53 * Addresses to scan
53   - * Address is fully defined internally and cannot be changed.
  54 + * Address is fully defined internally and cannot be changed except for
  55 + * LM64 which has one pin dedicated to address selection.
  56 + * LM63 and LM96163 have address 0x4c.
  57 + * LM64 can have address 0x18 or 0x4e.
54 58 */
55 59  
56 60 static const unsigned short normal_i2c[] = { 0x18, 0x4c, 0x4e, I2C_CLIENT_END };
... ... @@ -60,6 +64,7 @@
60 64 */
61 65  
62 66 #define LM63_REG_CONFIG1 0x03
  67 +#define LM63_REG_CONVRATE 0x04
63 68 #define LM63_REG_CONFIG2 0xBF
64 69 #define LM63_REG_CONFIG_FAN 0x4A
65 70  
... ... @@ -70,6 +75,9 @@
70 75  
71 76 #define LM63_REG_PWM_VALUE 0x4C
72 77 #define LM63_REG_PWM_FREQ 0x4D
  78 +#define LM63_REG_LUT_TEMP_HYST 0x4F
  79 +#define LM63_REG_LUT_TEMP(nr) (0x50 + 2 * (nr))
  80 +#define LM63_REG_LUT_PWM(nr) (0x51 + 2 * (nr))
73 81  
74 82 #define LM63_REG_LOCAL_TEMP 0x00
75 83 #define LM63_REG_LOCAL_HIGH 0x05
... ... @@ -91,6 +99,16 @@
91 99 #define LM63_REG_MAN_ID 0xFE
92 100 #define LM63_REG_CHIP_ID 0xFF
93 101  
  102 +#define LM96163_REG_TRUTHERM 0x30
  103 +#define LM96163_REG_REMOTE_TEMP_U_MSB 0x31
  104 +#define LM96163_REG_REMOTE_TEMP_U_LSB 0x32
  105 +#define LM96163_REG_CONFIG_ENHANCED 0x45
  106 +
  107 +#define LM63_MAX_CONVRATE 9
  108 +
  109 +#define LM63_MAX_CONVRATE_HZ 32
  110 +#define LM96163_MAX_CONVRATE_HZ 26
  111 +
94 112 /*
95 113 * Conversions and various macros
96 114 * For tachometer counts, the LM63 uses 16-bit values.
97 115  
98 116  
... ... @@ -112,15 +130,24 @@
112 130 (val) >= 127000 ? 127 : \
113 131 (val) < 0 ? ((val) - 500) / 1000 : \
114 132 ((val) + 500) / 1000)
  133 +#define TEMP8U_TO_REG(val) ((val) <= 0 ? 0 : \
  134 + (val) >= 255000 ? 255 : \
  135 + ((val) + 500) / 1000)
115 136 #define TEMP11_FROM_REG(reg) ((reg) / 32 * 125)
116 137 #define TEMP11_TO_REG(val) ((val) <= -128000 ? 0x8000 : \
117 138 (val) >= 127875 ? 0x7FE0 : \
118 139 (val) < 0 ? ((val) - 62) / 125 * 32 : \
119 140 ((val) + 62) / 125 * 32)
  141 +#define TEMP11U_TO_REG(val) ((val) <= 0 ? 0 : \
  142 + (val) >= 255875 ? 0xFFE0 : \
  143 + ((val) + 62) / 125 * 32)
120 144 #define HYST_TO_REG(val) ((val) <= 0 ? 0 : \
121 145 (val) >= 127000 ? 127 : \
122 146 ((val) + 500) / 1000)
123 147  
  148 +#define UPDATE_INTERVAL(max, rate) \
  149 + ((1000 << (LM63_MAX_CONVRATE - (rate))) / (max))
  150 +
124 151 /*
125 152 * Functions declaration
126 153 */
... ... @@ -134,7 +161,7 @@
134 161 static int lm63_detect(struct i2c_client *client, struct i2c_board_info *info);
135 162 static void lm63_init_client(struct i2c_client *client);
136 163  
137   -enum chips { lm63, lm64 };
  164 +enum chips { lm63, lm64, lm96163 };
138 165  
139 166 /*
140 167 * Driver data (common to all clients)
... ... @@ -143,6 +170,7 @@
143 170 static const struct i2c_device_id lm63_id[] = {
144 171 { "lm63", lm63 },
145 172 { "lm64", lm64 },
  173 + { "lm96163", lm96163 },
146 174 { }
147 175 };
148 176 MODULE_DEVICE_TABLE(i2c, lm63_id);
149 177  
150 178  
151 179  
152 180  
153 181  
154 182  
155 183  
156 184  
... ... @@ -167,26 +195,53 @@
167 195 struct device *hwmon_dev;
168 196 struct mutex update_lock;
169 197 char valid; /* zero until following fields are valid */
  198 + char lut_valid; /* zero until lut fields are valid */
170 199 unsigned long last_updated; /* in jiffies */
171   - int kind;
  200 + unsigned long lut_last_updated; /* in jiffies */
  201 + enum chips kind;
172 202 int temp2_offset;
173 203  
  204 + int update_interval; /* in milliseconds */
  205 + int max_convrate_hz;
  206 + int lut_size; /* 8 or 12 */
  207 +
174 208 /* registers values */
175 209 u8 config, config_fan;
176 210 u16 fan[2]; /* 0: input
177 211 1: low limit */
178 212 u8 pwm1_freq;
179   - u8 pwm1_value;
180   - s8 temp8[3]; /* 0: local input
  213 + u8 pwm1[13]; /* 0: current output
  214 + 1-12: lookup table */
  215 + s8 temp8[15]; /* 0: local input
181 216 1: local high limit
182   - 2: remote critical limit */
183   - s16 temp11[3]; /* 0: remote input
  217 + 2: remote critical limit
  218 + 3-14: lookup table */
  219 + s16 temp11[4]; /* 0: remote input
184 220 1: remote low limit
185   - 2: remote high limit */
  221 + 2: remote high limit
  222 + 3: remote offset */
  223 + u16 temp11u; /* remote input (unsigned) */
186 224 u8 temp2_crit_hyst;
  225 + u8 lut_temp_hyst;
187 226 u8 alarms;
  227 + bool pwm_highres;
  228 + bool lut_temp_highres;
  229 + bool remote_unsigned; /* true if unsigned remote upper limits */
  230 + bool trutherm;
188 231 };
189 232  
  233 +static inline int temp8_from_reg(struct lm63_data *data, int nr)
  234 +{
  235 + if (data->remote_unsigned)
  236 + return TEMP8_FROM_REG((u8)data->temp8[nr]);
  237 + return TEMP8_FROM_REG(data->temp8[nr]);
  238 +}
  239 +
  240 +static inline int lut_temp_from_reg(struct lm63_data *data, int nr)
  241 +{
  242 + return data->temp8[nr] * (data->lut_temp_highres ? 500 : 1000);
  243 +}
  244 +
190 245 /*
191 246 * Sysfs callback functions and files
192 247 */
193 248  
... ... @@ -204,8 +259,13 @@
204 259 {
205 260 struct i2c_client *client = to_i2c_client(dev);
206 261 struct lm63_data *data = i2c_get_clientdata(client);
207   - unsigned long val = simple_strtoul(buf, NULL, 10);
  262 + unsigned long val;
  263 + int err;
208 264  
  265 + err = kstrtoul(buf, 10, &val);
  266 + if (err)
  267 + return err;
  268 +
209 269 mutex_lock(&data->update_lock);
210 270 data->fan[1] = FAN_TO_REG(val);
211 271 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB,
212 272  
213 273  
... ... @@ -216,13 +276,22 @@
216 276 return count;
217 277 }
218 278  
219   -static ssize_t show_pwm1(struct device *dev, struct device_attribute *dummy,
  279 +static ssize_t show_pwm1(struct device *dev, struct device_attribute *devattr,
220 280 char *buf)
221 281 {
  282 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
222 283 struct lm63_data *data = lm63_update_device(dev);
223   - return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ?
224   - 255 : (data->pwm1_value * 255 + data->pwm1_freq) /
225   - (2 * data->pwm1_freq));
  284 + int nr = attr->index;
  285 + int pwm;
  286 +
  287 + if (data->pwm_highres)
  288 + pwm = data->pwm1[nr];
  289 + else
  290 + pwm = data->pwm1[nr] >= 2 * data->pwm1_freq ?
  291 + 255 : (data->pwm1[nr] * 255 + data->pwm1_freq) /
  292 + (2 * data->pwm1_freq);
  293 +
  294 + return sprintf(buf, "%d\n", pwm);
226 295 }
227 296  
228 297 static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy,
229 298  
230 299  
231 300  
... ... @@ -231,22 +300,26 @@
231 300 struct i2c_client *client = to_i2c_client(dev);
232 301 struct lm63_data *data = i2c_get_clientdata(client);
233 302 unsigned long val;
234   -
  303 + int err;
  304 +
235 305 if (!(data->config_fan & 0x20)) /* register is read-only */
236 306 return -EPERM;
237 307  
238   - val = simple_strtoul(buf, NULL, 10);
  308 + err = kstrtoul(buf, 10, &val);
  309 + if (err)
  310 + return err;
  311 +
  312 + val = SENSORS_LIMIT(val, 0, 255);
239 313 mutex_lock(&data->update_lock);
240   - data->pwm1_value = val <= 0 ? 0 :
241   - val >= 255 ? 2 * data->pwm1_freq :
242   - (val * data->pwm1_freq * 2 + 127) / 255;
243   - i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value);
  314 + data->pwm1[0] = data->pwm_highres ? val :
  315 + (val * data->pwm1_freq * 2 + 127) / 255;
  316 + i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1[0]);
244 317 mutex_unlock(&data->update_lock);
245 318 return count;
246 319 }
247 320  
248   -static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *dummy,
249   - char *buf)
  321 +static ssize_t show_pwm1_enable(struct device *dev,
  322 + struct device_attribute *dummy, char *buf)
250 323 {
251 324 struct lm63_data *data = lm63_update_device(dev);
252 325 return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2);
253 326  
254 327  
255 328  
256 329  
257 330  
... ... @@ -273,21 +346,47 @@
273 346 {
274 347 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
275 348 struct lm63_data *data = lm63_update_device(dev);
276   - return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[attr->index])
  349 + return sprintf(buf, "%d\n", temp8_from_reg(data, attr->index)
277 350 + data->temp2_offset);
278 351 }
279 352  
280   -static ssize_t set_local_temp8(struct device *dev,
281   - struct device_attribute *dummy,
282   - const char *buf, size_t count)
  353 +static ssize_t show_lut_temp(struct device *dev,
  354 + struct device_attribute *devattr,
  355 + char *buf)
283 356 {
  357 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
  358 + struct lm63_data *data = lm63_update_device(dev);
  359 + return sprintf(buf, "%d\n", lut_temp_from_reg(data, attr->index)
  360 + + data->temp2_offset);
  361 +}
  362 +
  363 +static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
  364 + const char *buf, size_t count)
  365 +{
  366 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
284 367 struct i2c_client *client = to_i2c_client(dev);
285 368 struct lm63_data *data = i2c_get_clientdata(client);
286   - long val = simple_strtol(buf, NULL, 10);
  369 + int nr = attr->index;
  370 + int reg = nr == 2 ? LM63_REG_REMOTE_TCRIT : LM63_REG_LOCAL_HIGH;
  371 + long val;
  372 + int err;
  373 + int temp;
287 374  
  375 + err = kstrtol(buf, 10, &val);
  376 + if (err)
  377 + return err;
  378 +
288 379 mutex_lock(&data->update_lock);
289   - data->temp8[1] = TEMP8_TO_REG(val);
290   - i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]);
  380 + if (nr == 2) {
  381 + if (data->remote_unsigned)
  382 + temp = TEMP8U_TO_REG(val - data->temp2_offset);
  383 + else
  384 + temp = TEMP8_TO_REG(val - data->temp2_offset);
  385 + } else {
  386 + temp = TEMP8_TO_REG(val);
  387 + }
  388 + data->temp8[nr] = temp;
  389 + i2c_smbus_write_byte_data(client, reg, temp);
291 390 mutex_unlock(&data->update_lock);
292 391 return count;
293 392 }
294 393  
295 394  
296 395  
297 396  
298 397  
... ... @@ -297,28 +396,56 @@
297 396 {
298 397 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
299 398 struct lm63_data *data = lm63_update_device(dev);
300   - return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->temp11[attr->index])
301   - + data->temp2_offset);
  399 + int nr = attr->index;
  400 + int temp;
  401 +
  402 + if (!nr) {
  403 + /*
  404 + * Use unsigned temperature unless its value is zero.
  405 + * If it is zero, use signed temperature.
  406 + */
  407 + if (data->temp11u)
  408 + temp = TEMP11_FROM_REG(data->temp11u);
  409 + else
  410 + temp = TEMP11_FROM_REG(data->temp11[nr]);
  411 + } else {
  412 + if (data->remote_unsigned && nr == 2)
  413