aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/coretemp.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/coretemp.c')
-rw-r--r--drivers/hwmon/coretemp.c56
1 files changed, 32 insertions, 24 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index de8111114f46..baa842a80b4b 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -423,9 +423,18 @@ static int __cpuinit coretemp_device_add(unsigned int cpu)
423 int err; 423 int err;
424 struct platform_device *pdev; 424 struct platform_device *pdev;
425 struct pdev_entry *pdev_entry; 425 struct pdev_entry *pdev_entry;
426#ifdef CONFIG_SMP
427 struct cpuinfo_x86 *c = &cpu_data(cpu); 426 struct cpuinfo_x86 *c = &cpu_data(cpu);
428#endif 427
428 /*
429 * CPUID.06H.EAX[0] indicates whether the CPU has thermal
430 * sensors. We check this bit only, all the early CPUs
431 * without thermal sensors will be filtered out.
432 */
433 if (!cpu_has(c, X86_FEATURE_DTS)) {
434 printk(KERN_INFO DRVNAME ": CPU (model=0x%x)"
435 " has no thermal sensor.\n", c->x86_model);
436 return 0;
437 }
429 438
430 mutex_lock(&pdev_list_mutex); 439 mutex_lock(&pdev_list_mutex);
431 440
@@ -482,14 +491,22 @@ exit:
482 491
483static void coretemp_device_remove(unsigned int cpu) 492static void coretemp_device_remove(unsigned int cpu)
484{ 493{
485 struct pdev_entry *p, *n; 494 struct pdev_entry *p;
495 unsigned int i;
496
486 mutex_lock(&pdev_list_mutex); 497 mutex_lock(&pdev_list_mutex);
487 list_for_each_entry_safe(p, n, &pdev_list, list) { 498 list_for_each_entry(p, &pdev_list, list) {
488 if (p->cpu == cpu) { 499 if (p->cpu != cpu)
489 platform_device_unregister(p->pdev); 500 continue;
490 list_del(&p->list); 501
491 kfree(p); 502 platform_device_unregister(p->pdev);
492 } 503 list_del(&p->list);
504 mutex_unlock(&pdev_list_mutex);
505 kfree(p);
506 for_each_cpu(i, cpu_sibling_mask(cpu))
507 if (i != cpu && !coretemp_device_add(i))
508 break;
509 return;
493 } 510 }
494 mutex_unlock(&pdev_list_mutex); 511 mutex_unlock(&pdev_list_mutex);
495} 512}
@@ -527,30 +544,21 @@ static int __init coretemp_init(void)
527 if (err) 544 if (err)
528 goto exit; 545 goto exit;
529 546
530 for_each_online_cpu(i) { 547 for_each_online_cpu(i)
531 struct cpuinfo_x86 *c = &cpu_data(i); 548 coretemp_device_add(i);
532 /* 549
533 * CPUID.06H.EAX[0] indicates whether the CPU has thermal 550#ifndef CONFIG_HOTPLUG_CPU
534 * sensors. We check this bit only, all the early CPUs
535 * without thermal sensors will be filtered out.
536 */
537 if (c->cpuid_level >= 6 && (cpuid_eax(0x06) & 0x01))
538 coretemp_device_add(i);
539 else {
540 printk(KERN_INFO DRVNAME ": CPU (model=0x%x)"
541 " has no thermal sensor.\n", c->x86_model);
542 }
543 }
544 if (list_empty(&pdev_list)) { 551 if (list_empty(&pdev_list)) {
545 err = -ENODEV; 552 err = -ENODEV;
546 goto exit_driver_unreg; 553 goto exit_driver_unreg;
547 } 554 }
555#endif
548 556
549 register_hotcpu_notifier(&coretemp_cpu_notifier); 557 register_hotcpu_notifier(&coretemp_cpu_notifier);
550 return 0; 558 return 0;
551 559
552exit_driver_unreg:
553#ifndef CONFIG_HOTPLUG_CPU 560#ifndef CONFIG_HOTPLUG_CPU
561exit_driver_unreg:
554 platform_driver_unregister(&coretemp_driver); 562 platform_driver_unregister(&coretemp_driver);
555#endif 563#endif
556exit: 564exit: