aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2011-10-20 12:30:25 -0400
committerArnd Bergmann <arnd@arndb.de>2011-10-20 12:30:25 -0400
commit995a0605a6665858d73f9e80053414909be33f27 (patch)
treefcc66a6a77acdaae492f77c0c58c0233db74a2b4 /drivers/hwmon
parenta32750c2ca6f697903b19063fc86f4272865e3a1 (diff)
parent677d3e2f07d1b3d6d2f76fd5552d16a53b9236a0 (diff)
Merge branch 'at91/trng' into next/driver
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/coretemp.c216
-rw-r--r--drivers/hwmon/ds620.c2
-rw-r--r--drivers/hwmon/i5k_amb.c42
-rw-r--r--drivers/hwmon/max16065.c2
-rw-r--r--drivers/hwmon/ntc_thermistor.c3
-rw-r--r--drivers/hwmon/pmbus/pmbus_core.c9
-rw-r--r--drivers/hwmon/pmbus/ucd9000.c6
-rw-r--r--drivers/hwmon/pmbus/ucd9200.c6
-rw-r--r--drivers/hwmon/w83791d.c4
9 files changed, 84 insertions, 206 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 59d83e83da7f..932383786642 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -36,17 +36,25 @@
36#include <linux/cpu.h> 36#include <linux/cpu.h>
37#include <linux/pci.h> 37#include <linux/pci.h>
38#include <linux/smp.h> 38#include <linux/smp.h>
39#include <linux/moduleparam.h>
39#include <asm/msr.h> 40#include <asm/msr.h>
40#include <asm/processor.h> 41#include <asm/processor.h>
41 42
42#define DRVNAME "coretemp" 43#define DRVNAME "coretemp"
43 44
45/*
46 * force_tjmax only matters when TjMax can't be read from the CPU itself.
47 * When set, it replaces the driver's suboptimal heuristic.
48 */
49static int force_tjmax;
50module_param_named(tjmax, force_tjmax, int, 0444);
51MODULE_PARM_DESC(tjmax, "TjMax value in degrees Celsius");
52
44#define BASE_SYSFS_ATTR_NO 2 /* Sysfs Base attr no for coretemp */ 53#define BASE_SYSFS_ATTR_NO 2 /* Sysfs Base attr no for coretemp */
45#define NUM_REAL_CORES 16 /* Number of Real cores per cpu */ 54#define NUM_REAL_CORES 16 /* Number of Real cores per cpu */
46#define CORETEMP_NAME_LENGTH 17 /* String Length of attrs */ 55#define CORETEMP_NAME_LENGTH 17 /* String Length of attrs */
47#define MAX_CORE_ATTRS 4 /* Maximum no of basic attrs */ 56#define MAX_CORE_ATTRS 4 /* Maximum no of basic attrs */
48#define MAX_THRESH_ATTRS 3 /* Maximum no of Threshold attrs */ 57#define TOTAL_ATTRS (MAX_CORE_ATTRS + 1)
49#define TOTAL_ATTRS (MAX_CORE_ATTRS + MAX_THRESH_ATTRS)
50#define MAX_CORE_DATA (NUM_REAL_CORES + BASE_SYSFS_ATTR_NO) 58#define MAX_CORE_DATA (NUM_REAL_CORES + BASE_SYSFS_ATTR_NO)
51 59
52#ifdef CONFIG_SMP 60#ifdef CONFIG_SMP
@@ -69,8 +77,6 @@
69 * This value is passed as "id" field to rdmsr/wrmsr functions. 77 * This value is passed as "id" field to rdmsr/wrmsr functions.
70 * @status_reg: One of IA32_THERM_STATUS or IA32_PACKAGE_THERM_STATUS, 78 * @status_reg: One of IA32_THERM_STATUS or IA32_PACKAGE_THERM_STATUS,
71 * from where the temperature values should be read. 79 * from where the temperature values should be read.
72 * @intrpt_reg: One of IA32_THERM_INTERRUPT or IA32_PACKAGE_THERM_INTERRUPT,
73 * from where the thresholds are read.
74 * @attr_size: Total number of pre-core attrs displayed in the sysfs. 80 * @attr_size: Total number of pre-core attrs displayed in the sysfs.
75 * @is_pkg_data: If this is 1, the temp_data holds pkgtemp data. 81 * @is_pkg_data: If this is 1, the temp_data holds pkgtemp data.
76 * Otherwise, temp_data holds coretemp data. 82 * Otherwise, temp_data holds coretemp data.
@@ -79,13 +85,11 @@
79struct temp_data { 85struct temp_data {
80 int temp; 86 int temp;
81 int ttarget; 87 int ttarget;
82 int tmin;
83 int tjmax; 88 int tjmax;
84 unsigned long last_updated; 89 unsigned long last_updated;
85 unsigned int cpu; 90 unsigned int cpu;
86 u32 cpu_core_id; 91 u32 cpu_core_id;
87 u32 status_reg; 92 u32 status_reg;
88 u32 intrpt_reg;
89 int attr_size; 93 int attr_size;
90 bool is_pkg_data; 94 bool is_pkg_data;
91 bool valid; 95 bool valid;
@@ -143,19 +147,6 @@ static ssize_t show_crit_alarm(struct device *dev,
143 return sprintf(buf, "%d\n", (eax >> 5) & 1); 147 return sprintf(buf, "%d\n", (eax >> 5) & 1);
144} 148}
145 149
146static ssize_t show_max_alarm(struct device *dev,
147 struct device_attribute *devattr, char *buf)
148{
149 u32 eax, edx;
150 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
151 struct platform_data *pdata = dev_get_drvdata(dev);
152 struct temp_data *tdata = pdata->core_data[attr->index];
153
154 rdmsr_on_cpu(tdata->cpu, tdata->status_reg, &eax, &edx);
155
156 return sprintf(buf, "%d\n", !!(eax & THERM_STATUS_THRESHOLD1));
157}
158
159static ssize_t show_tjmax(struct device *dev, 150static ssize_t show_tjmax(struct device *dev,
160 struct device_attribute *devattr, char *buf) 151 struct device_attribute *devattr, char *buf)
161{ 152{
@@ -174,83 +165,6 @@ static ssize_t show_ttarget(struct device *dev,
174 return sprintf(buf, "%d\n", pdata->core_data[attr->index]->ttarget); 165 return sprintf(buf, "%d\n", pdata->core_data[attr->index]->ttarget);
175} 166}
176 167
177static ssize_t store_ttarget(struct device *dev,
178 struct device_attribute *devattr,
179 const char *buf, size_t count)
180{
181 struct platform_data *pdata = dev_get_drvdata(dev);
182 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
183 struct temp_data *tdata = pdata->core_data[attr->index];
184 u32 eax, edx;
185 unsigned long val;
186 int diff;
187
188 if (strict_strtoul(buf, 10, &val))
189 return -EINVAL;
190
191 /*
192 * THERM_MASK_THRESHOLD1 is 7 bits wide. Values are entered in terms
193 * of milli degree celsius. Hence don't accept val > (127 * 1000)
194 */
195 if (val > tdata->tjmax || val > 127000)
196 return -EINVAL;
197
198 diff = (tdata->tjmax - val) / 1000;
199
200 mutex_lock(&tdata->update_lock);
201 rdmsr_on_cpu(tdata->cpu, tdata->intrpt_reg, &eax, &edx);
202 eax = (eax & ~THERM_MASK_THRESHOLD1) |
203 (diff << THERM_SHIFT_THRESHOLD1);
204 wrmsr_on_cpu(tdata->cpu, tdata->intrpt_reg, eax, edx);
205 tdata->ttarget = val;
206 mutex_unlock(&tdata->update_lock);
207
208 return count;
209}
210
211static ssize_t show_tmin(struct device *dev,
212 struct device_attribute *devattr, char *buf)
213{
214 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
215 struct platform_data *pdata = dev_get_drvdata(dev);
216
217 return sprintf(buf, "%d\n", pdata->core_data[attr->index]->tmin);
218}
219
220static ssize_t store_tmin(struct device *dev,
221 struct device_attribute *devattr,
222 const char *buf, size_t count)
223{
224 struct platform_data *pdata = dev_get_drvdata(dev);
225 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
226 struct temp_data *tdata = pdata->core_data[attr->index];
227 u32 eax, edx;
228 unsigned long val;
229 int diff;
230
231 if (strict_strtoul(buf, 10, &val))
232 return -EINVAL;
233
234 /*
235 * THERM_MASK_THRESHOLD0 is 7 bits wide. Values are entered in terms
236 * of milli degree celsius. Hence don't accept val > (127 * 1000)
237 */
238 if (val > tdata->tjmax || val > 127000)
239 return -EINVAL;
240
241 diff = (tdata->tjmax - val) / 1000;
242
243 mutex_lock(&tdata->update_lock);
244 rdmsr_on_cpu(tdata->cpu, tdata->intrpt_reg, &eax, &edx);
245 eax = (eax & ~THERM_MASK_THRESHOLD0) |
246 (diff << THERM_SHIFT_THRESHOLD0);
247 wrmsr_on_cpu(tdata->cpu, tdata->intrpt_reg, eax, edx);
248 tdata->tmin = val;
249 mutex_unlock(&tdata->update_lock);
250
251 return count;
252}
253
254static ssize_t show_temp(struct device *dev, 168static ssize_t show_temp(struct device *dev,
255 struct device_attribute *devattr, char *buf) 169 struct device_attribute *devattr, char *buf)
256{ 170{
@@ -374,7 +288,6 @@ static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
374 288
375static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev) 289static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
376{ 290{
377 /* The 100C is default for both mobile and non mobile CPUs */
378 int err; 291 int err;
379 u32 eax, edx; 292 u32 eax, edx;
380 u32 val; 293 u32 val;
@@ -385,7 +298,8 @@ static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
385 */ 298 */
386 err = rdmsr_safe_on_cpu(id, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx); 299 err = rdmsr_safe_on_cpu(id, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx);
387 if (err) { 300 if (err) {
388 dev_warn(dev, "Unable to read TjMax from CPU.\n"); 301 if (c->x86_model > 0xe && c->x86_model != 0x1c)
302 dev_warn(dev, "Unable to read TjMax from CPU %u\n", id);
389 } else { 303 } else {
390 val = (eax >> 16) & 0xff; 304 val = (eax >> 16) & 0xff;
391 /* 305 /*
@@ -393,11 +307,17 @@ static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
393 * will be used 307 * will be used
394 */ 308 */
395 if (val) { 309 if (val) {
396 dev_info(dev, "TjMax is %d C.\n", val); 310 dev_dbg(dev, "TjMax is %d degrees C\n", val);
397 return val * 1000; 311 return val * 1000;
398 } 312 }
399 } 313 }
400 314
315 if (force_tjmax) {
316 dev_notice(dev, "TjMax forced to %d degrees C by user\n",
317 force_tjmax);
318 return force_tjmax * 1000;
319 }
320
401 /* 321 /*
402 * An assumption is made for early CPUs and unreadable MSR. 322 * An assumption is made for early CPUs and unreadable MSR.
403 * NOTE: the calculated value may not be correct. 323 * NOTE: the calculated value may not be correct.
@@ -414,21 +334,6 @@ static void __devinit get_ucode_rev_on_cpu(void *edx)
414 rdmsr(MSR_IA32_UCODE_REV, eax, *(u32 *)edx); 334 rdmsr(MSR_IA32_UCODE_REV, eax, *(u32 *)edx);
415} 335}
416 336
417static int get_pkg_tjmax(unsigned int cpu, struct device *dev)
418{
419 int err;
420 u32 eax, edx, val;
421
422 err = rdmsr_safe_on_cpu(cpu, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx);
423 if (!err) {
424 val = (eax >> 16) & 0xff;
425 if (val)
426 return val * 1000;
427 }
428 dev_warn(dev, "Unable to read Pkg-TjMax from CPU:%u\n", cpu);
429 return 100000; /* Default TjMax: 100 degree celsius */
430}
431
432static int create_name_attr(struct platform_data *pdata, struct device *dev) 337static int create_name_attr(struct platform_data *pdata, struct device *dev)
433{ 338{
434 sysfs_attr_init(&pdata->name_attr.attr); 339 sysfs_attr_init(&pdata->name_attr.attr);
@@ -442,19 +347,14 @@ static int create_core_attrs(struct temp_data *tdata, struct device *dev,
442 int attr_no) 347 int attr_no)
443{ 348{
444 int err, i; 349 int err, i;
445 static ssize_t (*rd_ptr[TOTAL_ATTRS]) (struct device *dev, 350 static ssize_t (*const rd_ptr[TOTAL_ATTRS]) (struct device *dev,
446 struct device_attribute *devattr, char *buf) = { 351 struct device_attribute *devattr, char *buf) = {
447 show_label, show_crit_alarm, show_temp, show_tjmax, 352 show_label, show_crit_alarm, show_temp, show_tjmax,
448 show_max_alarm, show_ttarget, show_tmin }; 353 show_ttarget };
449 static ssize_t (*rw_ptr[TOTAL_ATTRS]) (struct device *dev, 354 static const char *const names[TOTAL_ATTRS] = {
450 struct device_attribute *devattr, const char *buf,
451 size_t count) = { NULL, NULL, NULL, NULL, NULL,
452 store_ttarget, store_tmin };
453 static const char *names[TOTAL_ATTRS] = {
454 "temp%d_label", "temp%d_crit_alarm", 355 "temp%d_label", "temp%d_crit_alarm",
455 "temp%d_input", "temp%d_crit", 356 "temp%d_input", "temp%d_crit",
456 "temp%d_max_alarm", "temp%d_max", 357 "temp%d_max" };
457 "temp%d_max_hyst" };
458 358
459 for (i = 0; i < tdata->attr_size; i++) { 359 for (i = 0; i < tdata->attr_size; i++) {
460 snprintf(tdata->attr_name[i], CORETEMP_NAME_LENGTH, names[i], 360 snprintf(tdata->attr_name[i], CORETEMP_NAME_LENGTH, names[i],
@@ -462,10 +362,6 @@ static int create_core_attrs(struct temp_data *tdata, struct device *dev,
462 sysfs_attr_init(&tdata->sd_attrs[i].dev_attr.attr); 362 sysfs_attr_init(&tdata->sd_attrs[i].dev_attr.attr);
463 tdata->sd_attrs[i].dev_attr.attr.name = tdata->attr_name[i]; 363 tdata->sd_attrs[i].dev_attr.attr.name = tdata->attr_name[i];
464 tdata->sd_attrs[i].dev_attr.attr.mode = S_IRUGO; 364 tdata->sd_attrs[i].dev_attr.attr.mode = S_IRUGO;
465 if (rw_ptr[i]) {
466 tdata->sd_attrs[i].dev_attr.attr.mode |= S_IWUSR;
467 tdata->sd_attrs[i].dev_attr.store = rw_ptr[i];
468 }
469 tdata->sd_attrs[i].dev_attr.show = rd_ptr[i]; 365 tdata->sd_attrs[i].dev_attr.show = rd_ptr[i];
470 tdata->sd_attrs[i].index = attr_no; 366 tdata->sd_attrs[i].index = attr_no;
471 err = device_create_file(dev, &tdata->sd_attrs[i].dev_attr); 367 err = device_create_file(dev, &tdata->sd_attrs[i].dev_attr);
@@ -481,9 +377,9 @@ exit_free:
481} 377}
482 378
483 379
484static int __devinit chk_ucode_version(struct platform_device *pdev) 380static int __cpuinit chk_ucode_version(unsigned int cpu)
485{ 381{
486 struct cpuinfo_x86 *c = &cpu_data(pdev->id); 382 struct cpuinfo_x86 *c = &cpu_data(cpu);
487 int err; 383 int err;
488 u32 edx; 384 u32 edx;
489 385
@@ -494,17 +390,15 @@ static int __devinit chk_ucode_version(struct platform_device *pdev)
494 */ 390 */
495 if (c->x86_model == 0xe && c->x86_mask < 0xc) { 391 if (c->x86_model == 0xe && c->x86_mask < 0xc) {
496 /* check for microcode update */ 392 /* check for microcode update */
497 err = smp_call_function_single(pdev->id, get_ucode_rev_on_cpu, 393 err = smp_call_function_single(cpu, get_ucode_rev_on_cpu,
498 &edx, 1); 394 &edx, 1);
499 if (err) { 395 if (err) {
500 dev_err(&pdev->dev, 396 pr_err("Cannot determine microcode revision of "
501 "Cannot determine microcode revision of " 397 "CPU#%u (%d)!\n", cpu, err);
502 "CPU#%u (%d)!\n", pdev->id, err);
503 return -ENODEV; 398 return -ENODEV;
504 } else if (edx < 0x39) { 399 } else if (edx < 0x39) {
505 dev_err(&pdev->dev, 400 pr_err("Errata AE18 not fixed, update BIOS or "
506 "Errata AE18 not fixed, update BIOS or " 401 "microcode of the CPU!\n");
507 "microcode of the CPU!\n");
508 return -ENODEV; 402 return -ENODEV;
509 } 403 }
510 } 404 }
@@ -538,8 +432,6 @@ static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag)
538 432
539 tdata->status_reg = pkg_flag ? MSR_IA32_PACKAGE_THERM_STATUS : 433 tdata->status_reg = pkg_flag ? MSR_IA32_PACKAGE_THERM_STATUS :
540 MSR_IA32_THERM_STATUS; 434 MSR_IA32_THERM_STATUS;
541 tdata->intrpt_reg = pkg_flag ? MSR_IA32_PACKAGE_THERM_INTERRUPT :
542 MSR_IA32_THERM_INTERRUPT;
543 tdata->is_pkg_data = pkg_flag; 435 tdata->is_pkg_data = pkg_flag;
544 tdata->cpu = cpu; 436 tdata->cpu = cpu;
545 tdata->cpu_core_id = TO_CORE_ID(cpu); 437 tdata->cpu_core_id = TO_CORE_ID(cpu);
@@ -548,11 +440,11 @@ static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag)
548 return tdata; 440 return tdata;
549} 441}
550 442
551static int create_core_data(struct platform_data *pdata, 443static int create_core_data(struct platform_device *pdev,
552 struct platform_device *pdev,
553 unsigned int cpu, int pkg_flag) 444 unsigned int cpu, int pkg_flag)
554{ 445{
555 struct temp_data *tdata; 446 struct temp_data *tdata;
447 struct platform_data *pdata = platform_get_drvdata(pdev);
556 struct cpuinfo_x86 *c = &cpu_data(cpu); 448 struct cpuinfo_x86 *c = &cpu_data(cpu);
557 u32 eax, edx; 449 u32 eax, edx;
558 int err, attr_no; 450 int err, attr_no;
@@ -588,20 +480,21 @@ static int create_core_data(struct platform_data *pdata,
588 goto exit_free; 480 goto exit_free;
589 481
590 /* We can access status register. Get Critical Temperature */ 482 /* We can access status register. Get Critical Temperature */
591 if (pkg_flag) 483 tdata->tjmax = get_tjmax(c, cpu, &pdev->dev);
592 tdata->tjmax = get_pkg_tjmax(pdev->id, &pdev->dev);
593 else
594 tdata->tjmax = get_tjmax(c, cpu, &pdev->dev);
595 484
596 /* 485 /*
597 * Test if we can access the intrpt register. If so, increase the 486 * Read the still undocumented bits 8:15 of IA32_TEMPERATURE_TARGET.
598 * 'size' enough to have ttarget/tmin/max_alarm interfaces. 487 * The target temperature is available on older CPUs but not in this
599 * Initialize ttarget with bits 16:22 of MSR_IA32_THERM_INTERRUPT 488 * register. Atoms don't have the register at all.
600 */ 489 */
601 err = rdmsr_safe_on_cpu(cpu, tdata->intrpt_reg, &eax, &edx); 490 if (c->x86_model > 0xe && c->x86_model != 0x1c) {
602 if (!err) { 491 err = rdmsr_safe_on_cpu(cpu, MSR_IA32_TEMPERATURE_TARGET,
603 tdata->attr_size += MAX_THRESH_ATTRS; 492 &eax, &edx);
604 tdata->ttarget = tdata->tjmax - ((eax >> 16) & 0x7f) * 1000; 493 if (!err) {
494 tdata->ttarget
495 = tdata->tjmax - ((eax >> 8) & 0xff) * 1000;
496 tdata->attr_size++;
497 }
605 } 498 }
606 499
607 pdata->core_data[attr_no] = tdata; 500 pdata->core_data[attr_no] = tdata;
@@ -613,22 +506,20 @@ static int create_core_data(struct platform_data *pdata,
613 506
614 return 0; 507 return 0;
615exit_free: 508exit_free:
509 pdata->core_data[attr_no] = NULL;
616 kfree(tdata); 510 kfree(tdata);
617 return err; 511 return err;
618} 512}
619 513
620static void coretemp_add_core(unsigned int cpu, int pkg_flag) 514static void coretemp_add_core(unsigned int cpu, int pkg_flag)
621{ 515{
622 struct platform_data *pdata;
623 struct platform_device *pdev = coretemp_get_pdev(cpu); 516 struct platform_device *pdev = coretemp_get_pdev(cpu);
624 int err; 517 int err;
625 518
626 if (!pdev) 519 if (!pdev)
627 return; 520 return;
628 521
629 pdata = platform_get_drvdata(pdev); 522 err = create_core_data(pdev, cpu, pkg_flag);
630
631 err = create_core_data(pdata, pdev, cpu, pkg_flag);
632 if (err) 523 if (err)
633 dev_err(&pdev->dev, "Adding Core %u failed\n", cpu); 524 dev_err(&pdev->dev, "Adding Core %u failed\n", cpu);
634} 525}
@@ -652,11 +543,6 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
652 struct platform_data *pdata; 543 struct platform_data *pdata;
653 int err; 544 int err;
654 545
655 /* Check the microcode version of the CPU */
656 err = chk_ucode_version(pdev);
657 if (err)
658 return err;
659
660 /* Initialize the per-package data structures */ 546 /* Initialize the per-package data structures */
661 pdata = kzalloc(sizeof(struct platform_data), GFP_KERNEL); 547 pdata = kzalloc(sizeof(struct platform_data), GFP_KERNEL);
662 if (!pdata) 548 if (!pdata)
@@ -666,7 +552,7 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
666 if (err) 552 if (err)
667 goto exit_free; 553 goto exit_free;
668 554
669 pdata->phys_proc_id = TO_PHYS_ID(pdev->id); 555 pdata->phys_proc_id = pdev->id;
670 platform_set_drvdata(pdev, pdata); 556 platform_set_drvdata(pdev, pdata);
671 557
672 pdata->hwmon_dev = hwmon_device_register(&pdev->dev); 558 pdata->hwmon_dev = hwmon_device_register(&pdev->dev);
@@ -718,7 +604,7 @@ static int __cpuinit coretemp_device_add(unsigned int cpu)
718 604
719 mutex_lock(&pdev_list_mutex); 605 mutex_lock(&pdev_list_mutex);
720 606
721 pdev = platform_device_alloc(DRVNAME, cpu); 607 pdev = platform_device_alloc(DRVNAME, TO_PHYS_ID(cpu));
722 if (!pdev) { 608 if (!pdev) {
723 err = -ENOMEM; 609 err = -ENOMEM;
724 pr_err("Device allocation failed\n"); 610 pr_err("Device allocation failed\n");
@@ -738,7 +624,7 @@ static int __cpuinit coretemp_device_add(unsigned int cpu)
738 } 624 }
739 625
740 pdev_entry->pdev = pdev; 626 pdev_entry->pdev = pdev;
741 pdev_entry->phys_proc_id = TO_PHYS_ID(cpu); 627 pdev_entry->phys_proc_id = pdev->id;
742 628
743 list_add_tail(&pdev_entry->list, &pdev_list); 629 list_add_tail(&pdev_entry->list, &pdev_list);
744 mutex_unlock(&pdev_list_mutex); 630 mutex_unlock(&pdev_list_mutex);
@@ -799,6 +685,10 @@ static void __cpuinit get_core_online(unsigned int cpu)
799 return; 685 return;
800 686
801 if (!pdev) { 687 if (!pdev) {
688 /* Check the microcode version of the CPU */
689 if (chk_ucode_version(cpu))
690 return;
691
802 /* 692 /*
803 * Alright, we have DTS support. 693 * Alright, we have DTS support.
804 * We are bringing the _first_ core in this pkg 694 * We are bringing the _first_ core in this pkg
diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
index 257957c69d92..4f7c3fc40a89 100644
--- a/drivers/hwmon/ds620.c
+++ b/drivers/hwmon/ds620.c
@@ -72,7 +72,7 @@ struct ds620_data {
72 char valid; /* !=0 if following fields are valid */ 72 char valid; /* !=0 if following fields are valid */
73 unsigned long last_updated; /* In jiffies */ 73 unsigned long last_updated; /* In jiffies */
74 74
75 u16 temp[3]; /* Register values, word */ 75 s16 temp[3]; /* Register values, word */
76}; 76};
77 77
78/* 78/*
diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c
index c4c40be0edbf..d22f241b6a67 100644
--- a/drivers/hwmon/i5k_amb.c
+++ b/drivers/hwmon/i5k_amb.c
@@ -114,7 +114,6 @@ struct i5k_amb_data {
114 void __iomem *amb_mmio; 114 void __iomem *amb_mmio;
115 struct i5k_device_attribute *attrs; 115 struct i5k_device_attribute *attrs;
116 unsigned int num_attrs; 116 unsigned int num_attrs;
117 unsigned long chipset_id;
118}; 117};
119 118
120static ssize_t show_name(struct device *dev, struct device_attribute *devattr, 119static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
@@ -444,8 +443,6 @@ static int __devinit i5k_find_amb_registers(struct i5k_amb_data *data,
444 goto out; 443 goto out;
445 } 444 }
446 445
447 data->chipset_id = devid;
448
449 res = 0; 446 res = 0;
450out: 447out:
451 pci_dev_put(pcidev); 448 pci_dev_put(pcidev);
@@ -478,23 +475,13 @@ out:
478 return res; 475 return res;
479} 476}
480 477
481static unsigned long i5k_channel_pci_id(struct i5k_amb_data *data, 478static struct {
482 unsigned long channel) 479 unsigned long err;
483{ 480 unsigned long fbd0;
484 switch (data->chipset_id) { 481} chipset_ids[] __devinitdata = {
485 case PCI_DEVICE_ID_INTEL_5000_ERR: 482 { PCI_DEVICE_ID_INTEL_5000_ERR, PCI_DEVICE_ID_INTEL_5000_FBD0 },
486 return PCI_DEVICE_ID_INTEL_5000_FBD0 + channel; 483 { PCI_DEVICE_ID_INTEL_5400_ERR, PCI_DEVICE_ID_INTEL_5400_FBD0 },
487 case PCI_DEVICE_ID_INTEL_5400_ERR: 484 { 0, 0 }
488 return PCI_DEVICE_ID_INTEL_5400_FBD0 + channel;
489 default:
490 BUG();
491 }
492}
493
494static unsigned long chipset_ids[] = {
495 PCI_DEVICE_ID_INTEL_5000_ERR,
496 PCI_DEVICE_ID_INTEL_5400_ERR,
497 0
498}; 485};
499 486
500#ifdef MODULE 487#ifdef MODULE
@@ -510,8 +497,7 @@ static int __devinit i5k_amb_probe(struct platform_device *pdev)
510{ 497{
511 struct i5k_amb_data *data; 498 struct i5k_amb_data *data;
512 struct resource *reso; 499 struct resource *reso;
513 int i; 500 int i, res;
514 int res = -ENODEV;
515 501
516 data = kzalloc(sizeof(*data), GFP_KERNEL); 502 data = kzalloc(sizeof(*data), GFP_KERNEL);
517 if (!data) 503 if (!data)
@@ -520,22 +506,22 @@ static int __devinit i5k_amb_probe(struct platform_device *pdev)
520 /* Figure out where the AMB registers live */ 506 /* Figure out where the AMB registers live */
521 i = 0; 507 i = 0;
522 do { 508 do {
523 res = i5k_find_amb_registers(data, chipset_ids[i]); 509 res = i5k_find_amb_registers(data, chipset_ids[i].err);
510 if (res == 0)
511 break;
524 i++; 512 i++;
525 } while (res && chipset_ids[i]); 513 } while (chipset_ids[i].err);
526 514
527 if (res) 515 if (res)
528 goto err; 516 goto err;
529 517
530 /* Copy the DIMM presence map for the first two channels */ 518 /* Copy the DIMM presence map for the first two channels */
531 res = i5k_channel_probe(&data->amb_present[0], 519 res = i5k_channel_probe(&data->amb_present[0], chipset_ids[i].fbd0);
532 i5k_channel_pci_id(data, 0));
533 if (res) 520 if (res)
534 goto err; 521 goto err;
535 522
536 /* Copy the DIMM presence map for the optional second two channels */ 523 /* Copy the DIMM presence map for the optional second two channels */
537 i5k_channel_probe(&data->amb_present[2], 524 i5k_channel_probe(&data->amb_present[2], chipset_ids[i].fbd0 + 1);
538 i5k_channel_pci_id(data, 1));
539 525
540 /* Set up resource regions */ 526 /* Set up resource regions */
541 reso = request_mem_region(data->amb_base, data->amb_len, DRVNAME); 527 reso = request_mem_region(data->amb_base, data->amb_len, DRVNAME);
diff --git a/drivers/hwmon/max16065.c b/drivers/hwmon/max16065.c
index d94a24fdf4ba..dd2d7b9620c2 100644
--- a/drivers/hwmon/max16065.c
+++ b/drivers/hwmon/max16065.c
@@ -124,7 +124,7 @@ static inline int MV_TO_LIMIT(int mv, int range)
124 124
125static inline int ADC_TO_CURR(int adc, int gain) 125static inline int ADC_TO_CURR(int adc, int gain)
126{ 126{
127 return adc * 1400000 / gain * 255; 127 return adc * 1400000 / (gain * 255);
128} 128}
129 129
130/* 130/*
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
index d7926f4336b5..eab11615dced 100644
--- a/drivers/hwmon/ntc_thermistor.c
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -211,8 +211,7 @@ static int lookup_comp(struct ntc_data *data,
211 if (data->comp[mid].ohm <= ohm) { 211 if (data->comp[mid].ohm <= ohm) {
212 *i_low = mid; 212 *i_low = mid;
213 *i_high = mid - 1; 213 *i_high = mid - 1;
214 } 214 } else {
215 if (data->comp[mid].ohm > ohm) {
216 *i_low = mid + 1; 215 *i_low = mid + 1;
217 *i_high = mid; 216 *i_high = mid;
218 } 217 }
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index a561c3a0e916..397fc59b5682 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -978,6 +978,8 @@ static void pmbus_find_max_attr(struct i2c_client *client,
978struct pmbus_limit_attr { 978struct pmbus_limit_attr {
979 u16 reg; /* Limit register */ 979 u16 reg; /* Limit register */
980 bool update; /* True if register needs updates */ 980 bool update; /* True if register needs updates */
981 bool low; /* True if low limit; for limits with compare
982 functions only */
981 const char *attr; /* Attribute name */ 983 const char *attr; /* Attribute name */
982 const char *alarm; /* Alarm attribute name */ 984 const char *alarm; /* Alarm attribute name */
983 u32 sbit; /* Alarm attribute status bit */ 985 u32 sbit; /* Alarm attribute status bit */
@@ -1029,7 +1031,8 @@ static bool pmbus_add_limit_attrs(struct i2c_client *client,
1029 if (attr->compare) { 1031 if (attr->compare) {
1030 pmbus_add_boolean_cmp(data, name, 1032 pmbus_add_boolean_cmp(data, name,
1031 l->alarm, index, 1033 l->alarm, index,
1032 cbase, cindex, 1034 l->low ? cindex : cbase,
1035 l->low ? cbase : cindex,
1033 attr->sbase + page, l->sbit); 1036 attr->sbase + page, l->sbit);
1034 } else { 1037 } else {
1035 pmbus_add_boolean_reg(data, name, 1038 pmbus_add_boolean_reg(data, name,
@@ -1366,11 +1369,13 @@ static const struct pmbus_sensor_attr power_attributes[] = {
1366static const struct pmbus_limit_attr temp_limit_attrs[] = { 1369static const struct pmbus_limit_attr temp_limit_attrs[] = {
1367 { 1370 {
1368 .reg = PMBUS_UT_WARN_LIMIT, 1371 .reg = PMBUS_UT_WARN_LIMIT,
1372 .low = true,
1369 .attr = "min", 1373 .attr = "min",
1370 .alarm = "min_alarm", 1374 .alarm = "min_alarm",
1371 .sbit = PB_TEMP_UT_WARNING, 1375 .sbit = PB_TEMP_UT_WARNING,
1372 }, { 1376 }, {
1373 .reg = PMBUS_UT_FAULT_LIMIT, 1377 .reg = PMBUS_UT_FAULT_LIMIT,
1378 .low = true,
1374 .attr = "lcrit", 1379 .attr = "lcrit",
1375 .alarm = "lcrit_alarm", 1380 .alarm = "lcrit_alarm",
1376 .sbit = PB_TEMP_UT_FAULT, 1381 .sbit = PB_TEMP_UT_FAULT,
@@ -1399,11 +1404,13 @@ static const struct pmbus_limit_attr temp_limit_attrs[] = {
1399static const struct pmbus_limit_attr temp_limit_attrs23[] = { 1404static const struct pmbus_limit_attr temp_limit_attrs23[] = {
1400 { 1405 {
1401 .reg = PMBUS_UT_WARN_LIMIT, 1406 .reg = PMBUS_UT_WARN_LIMIT,
1407 .low = true,
1402 .attr = "min", 1408 .attr = "min",
1403 .alarm = "min_alarm", 1409 .alarm = "min_alarm",
1404 .sbit = PB_TEMP_UT_WARNING, 1410 .sbit = PB_TEMP_UT_WARNING,
1405 }, { 1411 }, {
1406 .reg = PMBUS_UT_FAULT_LIMIT, 1412 .reg = PMBUS_UT_FAULT_LIMIT,
1413 .low = true,
1407 .attr = "lcrit", 1414 .attr = "lcrit",
1408 .alarm = "lcrit_alarm", 1415 .alarm = "lcrit_alarm",
1409 .sbit = PB_TEMP_UT_FAULT, 1416 .sbit = PB_TEMP_UT_FAULT,
diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c
index ace1c7319734..d0ddb60155c9 100644
--- a/drivers/hwmon/pmbus/ucd9000.c
+++ b/drivers/hwmon/pmbus/ucd9000.c
@@ -141,13 +141,11 @@ static int ucd9000_probe(struct i2c_client *client,
141 block_buffer[ret] = '\0'; 141 block_buffer[ret] = '\0';
142 dev_info(&client->dev, "Device ID %s\n", block_buffer); 142 dev_info(&client->dev, "Device ID %s\n", block_buffer);
143 143
144 mid = NULL; 144 for (mid = ucd9000_id; mid->name[0]; mid++) {
145 for (i = 0; i < ARRAY_SIZE(ucd9000_id); i++) {
146 mid = &ucd9000_id[i];
147 if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) 145 if (!strncasecmp(mid->name, block_buffer, strlen(mid->name)))
148 break; 146 break;
149 } 147 }
150 if (!mid || !strlen(mid->name)) { 148 if (!mid->name[0]) {
151 dev_err(&client->dev, "Unsupported device\n"); 149 dev_err(&client->dev, "Unsupported device\n");
152 return -ENODEV; 150 return -ENODEV;
153 } 151 }
diff --git a/drivers/hwmon/pmbus/ucd9200.c b/drivers/hwmon/pmbus/ucd9200.c
index ffcc1cf3609d..c65e9da707cc 100644
--- a/drivers/hwmon/pmbus/ucd9200.c
+++ b/drivers/hwmon/pmbus/ucd9200.c
@@ -68,13 +68,11 @@ static int ucd9200_probe(struct i2c_client *client,
68 block_buffer[ret] = '\0'; 68 block_buffer[ret] = '\0';
69 dev_info(&client->dev, "Device ID %s\n", block_buffer); 69 dev_info(&client->dev, "Device ID %s\n", block_buffer);
70 70
71 mid = NULL; 71 for (mid = ucd9200_id; mid->name[0]; mid++) {
72 for (i = 0; i < ARRAY_SIZE(ucd9200_id); i++) {
73 mid = &ucd9200_id[i];
74 if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) 72 if (!strncasecmp(mid->name, block_buffer, strlen(mid->name)))
75 break; 73 break;
76 } 74 }
77 if (!mid || !strlen(mid->name)) { 75 if (!mid->name[0]) {
78 dev_err(&client->dev, "Unsupported device\n"); 76 dev_err(&client->dev, "Unsupported device\n");
79 return -ENODEV; 77 return -ENODEV;
80 } 78 }
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c
index 17cf1ab95521..8c2844e5691c 100644
--- a/drivers/hwmon/w83791d.c
+++ b/drivers/hwmon/w83791d.c
@@ -329,8 +329,8 @@ static int w83791d_detect(struct i2c_client *client,
329 struct i2c_board_info *info); 329 struct i2c_board_info *info);
330static int w83791d_remove(struct i2c_client *client); 330static int w83791d_remove(struct i2c_client *client);
331 331
332static int w83791d_read(struct i2c_client *client, u8 register); 332static int w83791d_read(struct i2c_client *client, u8 reg);
333static int w83791d_write(struct i2c_client *client, u8 register, u8 value); 333static int w83791d_write(struct i2c_client *client, u8 reg, u8 value);
334static struct w83791d_data *w83791d_update_device(struct device *dev); 334static struct w83791d_data *w83791d_update_device(struct device *dev);
335 335
336#ifdef DEBUG 336#ifdef DEBUG