Skip to content

Commit e40cc4b

Browse files
Jan BeulichGuenter Roeck
authored andcommitted
x86/hwmon: register alternate sibling upon CPU removal
Just like pkgtemp registers another core of the same package when one gets removed, coretemp should register another hyperthread (if available) in that situation. As pointed out in the patch fixing the respective code in pkgtemp, the list protectng mutex must be dropped before calling coretemp_device_add(), and due to the restructured loop (including an explicit return) the "safe" variant of the list iterator isn't needed anymore. Signed-off-by: Jan Beulich <jbeulich@novell.com> Cc: Rudolf Marek <r.marek@assembler.cz> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
1 parent f6aeccd commit e40cc4b

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

drivers/hwmon/coretemp.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -491,14 +491,22 @@ static int __cpuinit coretemp_device_add(unsigned int cpu)
491491

492492
static void coretemp_device_remove(unsigned int cpu)
493493
{
494-
struct pdev_entry *p, *n;
494+
struct pdev_entry *p;
495+
unsigned int i;
496+
495497
mutex_lock(&pdev_list_mutex);
496-
list_for_each_entry_safe(p, n, &pdev_list, list) {
497-
if (p->cpu == cpu) {
498-
platform_device_unregister(p->pdev);
499-
list_del(&p->list);
500-
kfree(p);
501-
}
498+
list_for_each_entry(p, &pdev_list, list) {
499+
if (p->cpu != cpu)
500+
continue;
501+
502+
platform_device_unregister(p->pdev);
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;
502510
}
503511
mutex_unlock(&pdev_list_mutex);
504512
}

0 commit comments

Comments
 (0)