aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index b90eda8b3440..fd69086d08d5 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -858,6 +858,8 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
858 858
859 /* Check for existing affected CPUs. 859 /* Check for existing affected CPUs.
860 * They may not be aware of it due to CPU Hotplug. 860 * They may not be aware of it due to CPU Hotplug.
861 * cpufreq_cpu_put is called when the device is removed
862 * in __cpufreq_remove_dev()
861 */ 863 */
862 managed_policy = cpufreq_cpu_get(j); 864 managed_policy = cpufreq_cpu_get(j);
863 if (unlikely(managed_policy)) { 865 if (unlikely(managed_policy)) {
@@ -884,7 +886,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
884 ret = sysfs_create_link(&sys_dev->kobj, 886 ret = sysfs_create_link(&sys_dev->kobj,
885 &managed_policy->kobj, 887 &managed_policy->kobj,
886 "cpufreq"); 888 "cpufreq");
887 if (!ret) 889 if (ret)
888 cpufreq_cpu_put(managed_policy); 890 cpufreq_cpu_put(managed_policy);
889 /* 891 /*
890 * Success. We only needed to be added to the mask. 892 * Success. We only needed to be added to the mask.
@@ -924,6 +926,8 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
924 926
925 spin_lock_irqsave(&cpufreq_driver_lock, flags); 927 spin_lock_irqsave(&cpufreq_driver_lock, flags);
926 for_each_cpu(j, policy->cpus) { 928 for_each_cpu(j, policy->cpus) {
929 if (!cpu_online(j))
930 continue;
927 per_cpu(cpufreq_cpu_data, j) = policy; 931 per_cpu(cpufreq_cpu_data, j) = policy;
928 per_cpu(policy_cpu, j) = policy->cpu; 932 per_cpu(policy_cpu, j) = policy->cpu;
929 } 933 }
@@ -1244,13 +1248,22 @@ EXPORT_SYMBOL(cpufreq_get);
1244 1248
1245static int cpufreq_suspend(struct sys_device *sysdev, pm_message_t pmsg) 1249static int cpufreq_suspend(struct sys_device *sysdev, pm_message_t pmsg)
1246{ 1250{
1247 int cpu = sysdev->id;
1248 int ret = 0; 1251 int ret = 0;
1252
1253#ifdef __powerpc__
1254 int cpu = sysdev->id;
1249 unsigned int cur_freq = 0; 1255 unsigned int cur_freq = 0;
1250 struct cpufreq_policy *cpu_policy; 1256 struct cpufreq_policy *cpu_policy;
1251 1257
1252 dprintk("suspending cpu %u\n", cpu); 1258 dprintk("suspending cpu %u\n", cpu);
1253 1259
1260 /*
1261 * This whole bogosity is here because Powerbooks are made of fail.
1262 * No sane platform should need any of the code below to be run.
1263 * (it's entirely the wrong thing to do, as driver->get may
1264 * reenable interrupts on some architectures).
1265 */
1266
1254 if (!cpu_online(cpu)) 1267 if (!cpu_online(cpu))
1255 return 0; 1268 return 0;
1256 1269
@@ -1309,6 +1322,7 @@ static int cpufreq_suspend(struct sys_device *sysdev, pm_message_t pmsg)
1309 1322
1310out: 1323out:
1311 cpufreq_cpu_put(cpu_policy); 1324 cpufreq_cpu_put(cpu_policy);
1325#endif /* __powerpc__ */
1312 return ret; 1326 return ret;
1313} 1327}
1314 1328
@@ -1322,12 +1336,18 @@ out:
1322 */ 1336 */
1323static int cpufreq_resume(struct sys_device *sysdev) 1337static int cpufreq_resume(struct sys_device *sysdev)
1324{ 1338{
1325 int cpu = sysdev->id;
1326 int ret = 0; 1339 int ret = 0;
1340
1341#ifdef __powerpc__
1342 int cpu = sysdev->id;
1327 struct cpufreq_policy *cpu_policy; 1343 struct cpufreq_policy *cpu_policy;
1328 1344
1329 dprintk("resuming cpu %u\n", cpu); 1345 dprintk("resuming cpu %u\n", cpu);
1330 1346
1347 /* As with the ->suspend method, all the code below is
1348 * only necessary because Powerbooks suck.
1349 * See commit 42d4dc3f4e1e for jokes. */
1350
1331 if (!cpu_online(cpu)) 1351 if (!cpu_online(cpu))
1332 return 0; 1352 return 0;
1333 1353
@@ -1391,6 +1411,7 @@ out:
1391 schedule_work(&cpu_policy->update); 1411 schedule_work(&cpu_policy->update);
1392fail: 1412fail:
1393 cpufreq_cpu_put(cpu_policy); 1413 cpufreq_cpu_put(cpu_policy);
1414#endif /* __powerpc__ */
1394 return ret; 1415 return ret;
1395} 1416}
1396 1417