aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-07-09 10:22:49 -0400
committerJean Delvare <khali@linux-fr.org>2010-07-09 10:22:49 -0400
commitd883b9f0977269d519469da72faec6a7f72cb489 (patch)
tree75f5764d4272e8aef005ecb5e7667773afa1b7e7 /drivers
parent436cad2a41a40c6c32bd9152b63d17eeb1f7c99b (diff)
hwmon: (coretemp) Skip duplicate CPU entries
On hyper-threaded CPUs, each core appears twice in the CPU list. Skip the second entry to avoid duplicate sensors. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Huaxu Wan <huaxu.wan@intel.com> Cc: stable@kernel.org
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/coretemp.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 2988da150ed6..3b168faee794 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -405,6 +405,10 @@ struct pdev_entry {
405 struct list_head list; 405 struct list_head list;
406 struct platform_device *pdev; 406 struct platform_device *pdev;
407 unsigned int cpu; 407 unsigned int cpu;
408#ifdef CONFIG_SMP
409 u16 phys_proc_id;
410 u16 cpu_core_id;
411#endif
408}; 412};
409 413
410static LIST_HEAD(pdev_list); 414static LIST_HEAD(pdev_list);
@@ -415,6 +419,22 @@ static int __cpuinit coretemp_device_add(unsigned int cpu)
415 int err; 419 int err;
416 struct platform_device *pdev; 420 struct platform_device *pdev;
417 struct pdev_entry *pdev_entry; 421 struct pdev_entry *pdev_entry;
422#ifdef CONFIG_SMP
423 struct cpuinfo_x86 *c = &cpu_data(cpu);
424#endif
425
426 mutex_lock(&pdev_list_mutex);
427
428#ifdef CONFIG_SMP
429 /* Skip second HT entry of each core */
430 list_for_each_entry(pdev_entry, &pdev_list, list) {
431 if (c->phys_proc_id == pdev_entry->phys_proc_id &&
432 c->cpu_core_id == pdev_entry->cpu_core_id) {
433 err = 0; /* Not an error */
434 goto exit;
435 }
436 }
437#endif
418 438
419 pdev = platform_device_alloc(DRVNAME, cpu); 439 pdev = platform_device_alloc(DRVNAME, cpu);
420 if (!pdev) { 440 if (!pdev) {
@@ -438,7 +458,10 @@ static int __cpuinit coretemp_device_add(unsigned int cpu)
438 458
439 pdev_entry->pdev = pdev; 459 pdev_entry->pdev = pdev;
440 pdev_entry->cpu = cpu; 460 pdev_entry->cpu = cpu;
441 mutex_lock(&pdev_list_mutex); 461#ifdef CONFIG_SMP
462 pdev_entry->phys_proc_id = c->phys_proc_id;
463 pdev_entry->cpu_core_id = c->cpu_core_id;
464#endif
442 list_add_tail(&pdev_entry->list, &pdev_list); 465 list_add_tail(&pdev_entry->list, &pdev_list);
443 mutex_unlock(&pdev_list_mutex); 466 mutex_unlock(&pdev_list_mutex);
444 467
@@ -449,6 +472,7 @@ exit_device_free:
449exit_device_put: 472exit_device_put:
450 platform_device_put(pdev); 473 platform_device_put(pdev);
451exit: 474exit:
475 mutex_unlock(&pdev_list_mutex);
452 return err; 476 return err;
453} 477}
454 478