|
|
@@ -271,58 +271,29 @@ static void thermal_throttle_remove_dev(struct device *dev)
|
|
|
}
|
|
|
|
|
|
/* Get notified when a cpu comes on/off. Be hotplug friendly. */
|
|
|
-static int
|
|
|
-thermal_throttle_cpu_callback(struct notifier_block *nfb,
|
|
|
- unsigned long action,
|
|
|
- void *hcpu)
|
|
|
+static int thermal_throttle_prepare(unsigned int cpu)
|
|
|
{
|
|
|
- unsigned int cpu = (unsigned long)hcpu;
|
|
|
- struct device *dev;
|
|
|
- int err = 0;
|
|
|
-
|
|
|
- dev = get_cpu_device(cpu);
|
|
|
-
|
|
|
- switch (action) {
|
|
|
- case CPU_UP_PREPARE:
|
|
|
- case CPU_UP_PREPARE_FROZEN:
|
|
|
- err = thermal_throttle_add_dev(dev, cpu);
|
|
|
- WARN_ON(err);
|
|
|
- break;
|
|
|
- case CPU_UP_CANCELED:
|
|
|
- case CPU_UP_CANCELED_FROZEN:
|
|
|
- case CPU_DEAD:
|
|
|
- case CPU_DEAD_FROZEN:
|
|
|
- thermal_throttle_remove_dev(dev);
|
|
|
- break;
|
|
|
- }
|
|
|
- return notifier_from_errno(err);
|
|
|
+ struct device *dev = get_cpu_device(cpu);
|
|
|
+
|
|
|
+ return thermal_throttle_add_dev(dev, cpu);
|
|
|
}
|
|
|
|
|
|
-static struct notifier_block thermal_throttle_cpu_notifier =
|
|
|
+static int thermal_throttle_dead(unsigned int cpu)
|
|
|
{
|
|
|
- .notifier_call = thermal_throttle_cpu_callback,
|
|
|
-};
|
|
|
+ struct device *dev = get_cpu_device(cpu);
|
|
|
+
|
|
|
+ thermal_throttle_remove_dev(dev);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
|
|
|
static __init int thermal_throttle_init_device(void)
|
|
|
{
|
|
|
- unsigned int cpu = 0;
|
|
|
- int err;
|
|
|
-
|
|
|
if (!atomic_read(&therm_throt_en))
|
|
|
return 0;
|
|
|
|
|
|
- cpu_notifier_register_begin();
|
|
|
-
|
|
|
- /* connect live CPUs to sysfs */
|
|
|
- for_each_online_cpu(cpu) {
|
|
|
- err = thermal_throttle_add_dev(get_cpu_device(cpu), cpu);
|
|
|
- WARN_ON(err);
|
|
|
- }
|
|
|
-
|
|
|
- __register_hotcpu_notifier(&thermal_throttle_cpu_notifier);
|
|
|
- cpu_notifier_register_done();
|
|
|
-
|
|
|
- return 0;
|
|
|
+ return cpuhp_setup_state(CPUHP_X86_THERM_PREPARE, "x86/therm:prepare",
|
|
|
+ thermal_throttle_prepare,
|
|
|
+ thermal_throttle_dead);
|
|
|
}
|
|
|
device_initcall(thermal_throttle_init_device);
|
|
|
|