diff options
Diffstat (limited to 'drivers/hwmon/coretemp.c')
-rw-r--r-- | drivers/hwmon/coretemp.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 2988da150ed6..05344af50734 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c | |||
@@ -53,6 +53,7 @@ struct coretemp_data { | |||
53 | struct mutex update_lock; | 53 | struct mutex update_lock; |
54 | const char *name; | 54 | const char *name; |
55 | u32 id; | 55 | u32 id; |
56 | u16 core_id; | ||
56 | char valid; /* zero until following fields are valid */ | 57 | char valid; /* zero until following fields are valid */ |
57 | unsigned long last_updated; /* in jiffies */ | 58 | unsigned long last_updated; /* in jiffies */ |
58 | int temp; | 59 | int temp; |
@@ -75,7 +76,7 @@ static ssize_t show_name(struct device *dev, struct device_attribute | |||
75 | if (attr->index == SHOW_NAME) | 76 | if (attr->index == SHOW_NAME) |
76 | ret = sprintf(buf, "%s\n", data->name); | 77 | ret = sprintf(buf, "%s\n", data->name); |
77 | else /* show label */ | 78 | else /* show label */ |
78 | ret = sprintf(buf, "Core %d\n", data->id); | 79 | ret = sprintf(buf, "Core %d\n", data->core_id); |
79 | return ret; | 80 | return ret; |
80 | } | 81 | } |
81 | 82 | ||
@@ -304,6 +305,9 @@ static int __devinit coretemp_probe(struct platform_device *pdev) | |||
304 | } | 305 | } |
305 | 306 | ||
306 | data->id = pdev->id; | 307 | data->id = pdev->id; |
308 | #ifdef CONFIG_SMP | ||
309 | data->core_id = c->cpu_core_id; | ||
310 | #endif | ||
307 | data->name = "coretemp"; | 311 | data->name = "coretemp"; |
308 | mutex_init(&data->update_lock); | 312 | mutex_init(&data->update_lock); |
309 | 313 | ||
@@ -405,6 +409,10 @@ struct pdev_entry { | |||
405 | struct list_head list; | 409 | struct list_head list; |
406 | struct platform_device *pdev; | 410 | struct platform_device *pdev; |
407 | unsigned int cpu; | 411 | unsigned int cpu; |
412 | #ifdef CONFIG_SMP | ||
413 | u16 phys_proc_id; | ||
414 | u16 cpu_core_id; | ||
415 | #endif | ||
408 | }; | 416 | }; |
409 | 417 | ||
410 | static LIST_HEAD(pdev_list); | 418 | static LIST_HEAD(pdev_list); |
@@ -415,6 +423,22 @@ static int __cpuinit coretemp_device_add(unsigned int cpu) | |||
415 | int err; | 423 | int err; |
416 | struct platform_device *pdev; | 424 | struct platform_device *pdev; |
417 | struct pdev_entry *pdev_entry; | 425 | struct pdev_entry *pdev_entry; |
426 | #ifdef CONFIG_SMP | ||
427 | struct cpuinfo_x86 *c = &cpu_data(cpu); | ||
428 | #endif | ||
429 | |||
430 | mutex_lock(&pdev_list_mutex); | ||
431 | |||
432 | #ifdef CONFIG_SMP | ||
433 | /* Skip second HT entry of each core */ | ||
434 | list_for_each_entry(pdev_entry, &pdev_list, list) { | ||
435 | if (c->phys_proc_id == pdev_entry->phys_proc_id && | ||
436 | c->cpu_core_id == pdev_entry->cpu_core_id) { | ||
437 | err = 0; /* Not an error */ | ||
438 | goto exit; | ||
439 | } | ||
440 | } | ||
441 | #endif | ||
418 | 442 | ||
419 | pdev = platform_device_alloc(DRVNAME, cpu); | 443 | pdev = platform_device_alloc(DRVNAME, cpu); |
420 | if (!pdev) { | 444 | if (!pdev) { |
@@ -438,7 +462,10 @@ static int __cpuinit coretemp_device_add(unsigned int cpu) | |||
438 | 462 | ||
439 | pdev_entry->pdev = pdev; | 463 | pdev_entry->pdev = pdev; |
440 | pdev_entry->cpu = cpu; | 464 | pdev_entry->cpu = cpu; |
441 | mutex_lock(&pdev_list_mutex); | 465 | #ifdef CONFIG_SMP |
466 | pdev_entry->phys_proc_id = c->phys_proc_id; | ||
467 | pdev_entry->cpu_core_id = c->cpu_core_id; | ||
468 | #endif | ||
442 | list_add_tail(&pdev_entry->list, &pdev_list); | 469 | list_add_tail(&pdev_entry->list, &pdev_list); |
443 | mutex_unlock(&pdev_list_mutex); | 470 | mutex_unlock(&pdev_list_mutex); |
444 | 471 | ||
@@ -449,6 +476,7 @@ exit_device_free: | |||
449 | exit_device_put: | 476 | exit_device_put: |
450 | platform_device_put(pdev); | 477 | platform_device_put(pdev); |
451 | exit: | 478 | exit: |
479 | mutex_unlock(&pdev_list_mutex); | ||
452 | return err; | 480 | return err; |
453 | } | 481 | } |
454 | 482 | ||