===================================================================
@@ -202,14 +202,16 @@
#ifdef CONFIG_SYSFS
/* Add/Remove thermal_throttle interface for CPU device: */
-static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev)
+static __cpuinit int thermal_throttle_add_dev(unsigned int cpu)
{
int err;
- struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());
+ struct sys_device *sys_dev;
+ struct cpuinfo_x86 *c = &cpu_data(cpu);
+ sys_dev=get_cpu_sysdev(cpu);
err = sysfs_create_group(&sys_dev->kobj, &thermal_attr_group);
if (err)
- return err;
+ goto end;
if (cpu_has(c, X86_FEATURE_PLN))
err = sysfs_add_file_to_group(&sys_dev->kobj,
@@ -224,11 +226,14 @@
&attr_package_power_limit_count.attr,
thermal_attr_group.name);
+end:
+ put_cpu();
return err;
}
-static __cpuinit void thermal_throttle_remove_dev(struct sys_device *sys_dev)
+static __cpuinit void thermal_throttle_remove_dev(unsigned int cpu)
{
+ struct sys_device *sys_dev=get_cpu_sysdev(cpu);
sysfs_remove_group(&sys_dev->kobj, &thermal_attr_group);
}
@@ -242,16 +247,13 @@
void *hcpu)
{
unsigned int cpu = (unsigned long)hcpu;
- struct sys_device *sys_dev;
int err = 0;
- sys_dev = get_cpu_sysdev(cpu);
-
switch (action) {
case CPU_UP_PREPARE:
case CPU_UP_PREPARE_FROZEN:
mutex_lock(&therm_cpu_lock);
- err = thermal_throttle_add_dev(sys_dev);
+ err = thermal_throttle_add_dev(cpu);
mutex_unlock(&therm_cpu_lock);
WARN_ON(err);
break;
@@ -260,7 +262,7 @@
case CPU_DEAD:
case CPU_DEAD_FROZEN:
mutex_lock(&therm_cpu_lock);
- thermal_throttle_remove_dev(sys_dev);
+ thermal_throttle_remove_dev(cpu);
mutex_unlock(&therm_cpu_lock);
break;
}
@@ -287,7 +289,7 @@
#endif
/* connect live CPUs to sysfs */
for_each_online_cpu(cpu) {
- err = thermal_throttle_add_dev(get_cpu_sysdev(cpu));
+ err = thermal_throttle_add_dev(cpu);
WARN_ON(err);
}
#ifdef CONFIG_HOTPLUG_CPU