diff options
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 200 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_governor.h | 2 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 10 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 12 | ||||
-rw-r--r-- | include/linux/cpufreq.h | 2 |
5 files changed, 113 insertions, 113 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 845837174878..1793fe82595d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -179,7 +179,7 @@ EXPORT_SYMBOL_GPL(get_cpu_idle_time); | |||
179 | 179 | ||
180 | static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) | 180 | static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) |
181 | { | 181 | { |
182 | struct cpufreq_policy *data; | 182 | struct cpufreq_policy *policy; |
183 | unsigned long flags; | 183 | unsigned long flags; |
184 | 184 | ||
185 | if (cpu >= nr_cpu_ids) | 185 | if (cpu >= nr_cpu_ids) |
@@ -195,16 +195,16 @@ static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) | |||
195 | goto err_out_unlock; | 195 | goto err_out_unlock; |
196 | 196 | ||
197 | /* get the CPU */ | 197 | /* get the CPU */ |
198 | data = per_cpu(cpufreq_cpu_data, cpu); | 198 | policy = per_cpu(cpufreq_cpu_data, cpu); |
199 | 199 | ||
200 | if (!data) | 200 | if (!policy) |
201 | goto err_out_put_module; | 201 | goto err_out_put_module; |
202 | 202 | ||
203 | if (!sysfs && !kobject_get(&data->kobj)) | 203 | if (!sysfs && !kobject_get(&policy->kobj)) |
204 | goto err_out_put_module; | 204 | goto err_out_put_module; |
205 | 205 | ||
206 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); | 206 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); |
207 | return data; | 207 | return policy; |
208 | 208 | ||
209 | err_out_put_module: | 209 | err_out_put_module: |
210 | module_put(cpufreq_driver->owner); | 210 | module_put(cpufreq_driver->owner); |
@@ -228,25 +228,25 @@ static struct cpufreq_policy *cpufreq_cpu_get_sysfs(unsigned int cpu) | |||
228 | return __cpufreq_cpu_get(cpu, true); | 228 | return __cpufreq_cpu_get(cpu, true); |
229 | } | 229 | } |
230 | 230 | ||
231 | static void __cpufreq_cpu_put(struct cpufreq_policy *data, bool sysfs) | 231 | static void __cpufreq_cpu_put(struct cpufreq_policy *policy, bool sysfs) |
232 | { | 232 | { |
233 | if (!sysfs) | 233 | if (!sysfs) |
234 | kobject_put(&data->kobj); | 234 | kobject_put(&policy->kobj); |
235 | module_put(cpufreq_driver->owner); | 235 | module_put(cpufreq_driver->owner); |
236 | } | 236 | } |
237 | 237 | ||
238 | void cpufreq_cpu_put(struct cpufreq_policy *data) | 238 | void cpufreq_cpu_put(struct cpufreq_policy *policy) |
239 | { | 239 | { |
240 | if (cpufreq_disabled()) | 240 | if (cpufreq_disabled()) |
241 | return; | 241 | return; |
242 | 242 | ||
243 | __cpufreq_cpu_put(data, false); | 243 | __cpufreq_cpu_put(policy, false); |
244 | } | 244 | } |
245 | EXPORT_SYMBOL_GPL(cpufreq_cpu_put); | 245 | EXPORT_SYMBOL_GPL(cpufreq_cpu_put); |
246 | 246 | ||
247 | static void cpufreq_cpu_put_sysfs(struct cpufreq_policy *data) | 247 | static void cpufreq_cpu_put_sysfs(struct cpufreq_policy *policy) |
248 | { | 248 | { |
249 | __cpufreq_cpu_put(data, true); | 249 | __cpufreq_cpu_put(policy, true); |
250 | } | 250 | } |
251 | 251 | ||
252 | /********************************************************************* | 252 | /********************************************************************* |
@@ -453,8 +453,8 @@ show_one(scaling_min_freq, min); | |||
453 | show_one(scaling_max_freq, max); | 453 | show_one(scaling_max_freq, max); |
454 | show_one(scaling_cur_freq, cur); | 454 | show_one(scaling_cur_freq, cur); |
455 | 455 | ||
456 | static int __cpufreq_set_policy(struct cpufreq_policy *data, | 456 | static int __cpufreq_set_policy(struct cpufreq_policy *policy, |
457 | struct cpufreq_policy *policy); | 457 | struct cpufreq_policy *new_policy); |
458 | 458 | ||
459 | /** | 459 | /** |
460 | * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access | 460 | * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access |
@@ -1136,7 +1136,7 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) | |||
1136 | CPUFREQ_UPDATE_POLICY_CPU, policy); | 1136 | CPUFREQ_UPDATE_POLICY_CPU, policy); |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *data, | 1139 | static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, |
1140 | unsigned int old_cpu, bool frozen) | 1140 | unsigned int old_cpu, bool frozen) |
1141 | { | 1141 | { |
1142 | struct device *cpu_dev; | 1142 | struct device *cpu_dev; |
@@ -1144,27 +1144,27 @@ static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *data, | |||
1144 | int ret; | 1144 | int ret; |
1145 | 1145 | ||
1146 | /* first sibling now owns the new sysfs dir */ | 1146 | /* first sibling now owns the new sysfs dir */ |
1147 | cpu_dev = get_cpu_device(cpumask_first(data->cpus)); | 1147 | cpu_dev = get_cpu_device(cpumask_first(policy->cpus)); |
1148 | 1148 | ||
1149 | /* Don't touch sysfs files during light-weight tear-down */ | 1149 | /* Don't touch sysfs files during light-weight tear-down */ |
1150 | if (frozen) | 1150 | if (frozen) |
1151 | return cpu_dev->id; | 1151 | return cpu_dev->id; |
1152 | 1152 | ||
1153 | sysfs_remove_link(&cpu_dev->kobj, "cpufreq"); | 1153 | sysfs_remove_link(&cpu_dev->kobj, "cpufreq"); |
1154 | ret = kobject_move(&data->kobj, &cpu_dev->kobj); | 1154 | ret = kobject_move(&policy->kobj, &cpu_dev->kobj); |
1155 | if (ret) { | 1155 | if (ret) { |
1156 | pr_err("%s: Failed to move kobj: %d", __func__, ret); | 1156 | pr_err("%s: Failed to move kobj: %d", __func__, ret); |
1157 | 1157 | ||
1158 | WARN_ON(lock_policy_rwsem_write(old_cpu)); | 1158 | WARN_ON(lock_policy_rwsem_write(old_cpu)); |
1159 | cpumask_set_cpu(old_cpu, data->cpus); | 1159 | cpumask_set_cpu(old_cpu, policy->cpus); |
1160 | 1160 | ||
1161 | write_lock_irqsave(&cpufreq_driver_lock, flags); | 1161 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
1162 | per_cpu(cpufreq_cpu_data, old_cpu) = data; | 1162 | per_cpu(cpufreq_cpu_data, old_cpu) = policy; |
1163 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1163 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1164 | 1164 | ||
1165 | unlock_policy_rwsem_write(old_cpu); | 1165 | unlock_policy_rwsem_write(old_cpu); |
1166 | 1166 | ||
1167 | ret = sysfs_create_link(&cpu_dev->kobj, &data->kobj, | 1167 | ret = sysfs_create_link(&cpu_dev->kobj, &policy->kobj, |
1168 | "cpufreq"); | 1168 | "cpufreq"); |
1169 | 1169 | ||
1170 | return -EINVAL; | 1170 | return -EINVAL; |
@@ -1186,7 +1186,7 @@ static int __cpufreq_remove_dev(struct device *dev, | |||
1186 | unsigned int cpu = dev->id, cpus; | 1186 | unsigned int cpu = dev->id, cpus; |
1187 | int new_cpu; | 1187 | int new_cpu; |
1188 | unsigned long flags; | 1188 | unsigned long flags; |
1189 | struct cpufreq_policy *data; | 1189 | struct cpufreq_policy *policy; |
1190 | struct kobject *kobj; | 1190 | struct kobject *kobj; |
1191 | struct completion *cmp; | 1191 | struct completion *cmp; |
1192 | 1192 | ||
@@ -1194,44 +1194,44 @@ static int __cpufreq_remove_dev(struct device *dev, | |||
1194 | 1194 | ||
1195 | write_lock_irqsave(&cpufreq_driver_lock, flags); | 1195 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
1196 | 1196 | ||
1197 | data = per_cpu(cpufreq_cpu_data, cpu); | 1197 | policy = per_cpu(cpufreq_cpu_data, cpu); |
1198 | per_cpu(cpufreq_cpu_data, cpu) = NULL; | 1198 | per_cpu(cpufreq_cpu_data, cpu) = NULL; |
1199 | 1199 | ||
1200 | /* Save the policy somewhere when doing a light-weight tear-down */ | 1200 | /* Save the policy somewhere when doing a light-weight tear-down */ |
1201 | if (frozen) | 1201 | if (frozen) |
1202 | per_cpu(cpufreq_cpu_data_fallback, cpu) = data; | 1202 | per_cpu(cpufreq_cpu_data_fallback, cpu) = policy; |
1203 | 1203 | ||
1204 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1204 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1205 | 1205 | ||
1206 | if (!data) { | 1206 | if (!policy) { |
1207 | pr_debug("%s: No cpu_data found\n", __func__); | 1207 | pr_debug("%s: No cpu_data found\n", __func__); |
1208 | return -EINVAL; | 1208 | return -EINVAL; |
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | if (cpufreq_driver->target) | 1211 | if (cpufreq_driver->target) |
1212 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); | 1212 | __cpufreq_governor(policy, CPUFREQ_GOV_STOP); |
1213 | 1213 | ||
1214 | #ifdef CONFIG_HOTPLUG_CPU | 1214 | #ifdef CONFIG_HOTPLUG_CPU |
1215 | if (!cpufreq_driver->setpolicy) | 1215 | if (!cpufreq_driver->setpolicy) |
1216 | strncpy(per_cpu(cpufreq_cpu_governor, cpu), | 1216 | strncpy(per_cpu(cpufreq_cpu_governor, cpu), |
1217 | data->governor->name, CPUFREQ_NAME_LEN); | 1217 | policy->governor->name, CPUFREQ_NAME_LEN); |
1218 | #endif | 1218 | #endif |
1219 | 1219 | ||
1220 | WARN_ON(lock_policy_rwsem_write(cpu)); | 1220 | WARN_ON(lock_policy_rwsem_write(cpu)); |
1221 | cpus = cpumask_weight(data->cpus); | 1221 | cpus = cpumask_weight(policy->cpus); |
1222 | 1222 | ||
1223 | if (cpus > 1) | 1223 | if (cpus > 1) |
1224 | cpumask_clear_cpu(cpu, data->cpus); | 1224 | cpumask_clear_cpu(cpu, policy->cpus); |
1225 | unlock_policy_rwsem_write(cpu); | 1225 | unlock_policy_rwsem_write(cpu); |
1226 | 1226 | ||
1227 | if (cpu != data->cpu && !frozen) { | 1227 | if (cpu != policy->cpu && !frozen) { |
1228 | sysfs_remove_link(&dev->kobj, "cpufreq"); | 1228 | sysfs_remove_link(&dev->kobj, "cpufreq"); |
1229 | } else if (cpus > 1) { | 1229 | } else if (cpus > 1) { |
1230 | 1230 | ||
1231 | new_cpu = cpufreq_nominate_new_policy_cpu(data, cpu, frozen); | 1231 | new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu, frozen); |
1232 | if (new_cpu >= 0) { | 1232 | if (new_cpu >= 0) { |
1233 | WARN_ON(lock_policy_rwsem_write(cpu)); | 1233 | WARN_ON(lock_policy_rwsem_write(cpu)); |
1234 | update_policy_cpu(data, new_cpu); | 1234 | update_policy_cpu(policy, new_cpu); |
1235 | unlock_policy_rwsem_write(cpu); | 1235 | unlock_policy_rwsem_write(cpu); |
1236 | 1236 | ||
1237 | if (!frozen) { | 1237 | if (!frozen) { |
@@ -1244,12 +1244,12 @@ static int __cpufreq_remove_dev(struct device *dev, | |||
1244 | /* If cpu is last user of policy, free policy */ | 1244 | /* If cpu is last user of policy, free policy */ |
1245 | if (cpus == 1) { | 1245 | if (cpus == 1) { |
1246 | if (cpufreq_driver->target) | 1246 | if (cpufreq_driver->target) |
1247 | __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT); | 1247 | __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); |
1248 | 1248 | ||
1249 | if (!frozen) { | 1249 | if (!frozen) { |
1250 | lock_policy_rwsem_read(cpu); | 1250 | lock_policy_rwsem_read(cpu); |
1251 | kobj = &data->kobj; | 1251 | kobj = &policy->kobj; |
1252 | cmp = &data->kobj_unregister; | 1252 | cmp = &policy->kobj_unregister; |
1253 | unlock_policy_rwsem_read(cpu); | 1253 | unlock_policy_rwsem_read(cpu); |
1254 | kobject_put(kobj); | 1254 | kobject_put(kobj); |
1255 | 1255 | ||
@@ -1269,14 +1269,14 @@ static int __cpufreq_remove_dev(struct device *dev, | |||
1269 | * subsequent light-weight ->init() to succeed. | 1269 | * subsequent light-weight ->init() to succeed. |
1270 | */ | 1270 | */ |
1271 | if (cpufreq_driver->exit) | 1271 | if (cpufreq_driver->exit) |
1272 | cpufreq_driver->exit(data); | 1272 | cpufreq_driver->exit(policy); |
1273 | 1273 | ||
1274 | if (!frozen) | 1274 | if (!frozen) |
1275 | cpufreq_policy_free(data); | 1275 | cpufreq_policy_free(policy); |
1276 | } else { | 1276 | } else { |
1277 | if (cpufreq_driver->target) { | 1277 | if (cpufreq_driver->target) { |
1278 | __cpufreq_governor(data, CPUFREQ_GOV_START); | 1278 | __cpufreq_governor(policy, CPUFREQ_GOV_START); |
1279 | __cpufreq_governor(data, CPUFREQ_GOV_LIMITS); | 1279 | __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); |
1280 | } | 1280 | } |
1281 | } | 1281 | } |
1282 | 1282 | ||
@@ -1450,23 +1450,23 @@ static int cpufreq_bp_suspend(void) | |||
1450 | int ret = 0; | 1450 | int ret = 0; |
1451 | 1451 | ||
1452 | int cpu = smp_processor_id(); | 1452 | int cpu = smp_processor_id(); |
1453 | struct cpufreq_policy *cpu_policy; | 1453 | struct cpufreq_policy *policy; |
1454 | 1454 | ||
1455 | pr_debug("suspending cpu %u\n", cpu); | 1455 | pr_debug("suspending cpu %u\n", cpu); |
1456 | 1456 | ||
1457 | /* If there's no policy for the boot CPU, we have nothing to do. */ | 1457 | /* If there's no policy for the boot CPU, we have nothing to do. */ |
1458 | cpu_policy = cpufreq_cpu_get(cpu); | 1458 | policy = cpufreq_cpu_get(cpu); |
1459 | if (!cpu_policy) | 1459 | if (!policy) |
1460 | return 0; | 1460 | return 0; |
1461 | 1461 | ||
1462 | if (cpufreq_driver->suspend) { | 1462 | if (cpufreq_driver->suspend) { |
1463 | ret = cpufreq_driver->suspend(cpu_policy); | 1463 | ret = cpufreq_driver->suspend(policy); |
1464 | if (ret) | 1464 | if (ret) |
1465 | printk(KERN_ERR "cpufreq: suspend failed in ->suspend " | 1465 | printk(KERN_ERR "cpufreq: suspend failed in ->suspend " |
1466 | "step on CPU %u\n", cpu_policy->cpu); | 1466 | "step on CPU %u\n", policy->cpu); |
1467 | } | 1467 | } |
1468 | 1468 | ||
1469 | cpufreq_cpu_put(cpu_policy); | 1469 | cpufreq_cpu_put(policy); |
1470 | return ret; | 1470 | return ret; |
1471 | } | 1471 | } |
1472 | 1472 | ||
@@ -1488,28 +1488,28 @@ static void cpufreq_bp_resume(void) | |||
1488 | int ret = 0; | 1488 | int ret = 0; |
1489 | 1489 | ||
1490 | int cpu = smp_processor_id(); | 1490 | int cpu = smp_processor_id(); |
1491 | struct cpufreq_policy *cpu_policy; | 1491 | struct cpufreq_policy *policy; |
1492 | 1492 | ||
1493 | pr_debug("resuming cpu %u\n", cpu); | 1493 | pr_debug("resuming cpu %u\n", cpu); |
1494 | 1494 | ||
1495 | /* If there's no policy for the boot CPU, we have nothing to do. */ | 1495 | /* If there's no policy for the boot CPU, we have nothing to do. */ |
1496 | cpu_policy = cpufreq_cpu_get(cpu); | 1496 | policy = cpufreq_cpu_get(cpu); |
1497 | if (!cpu_policy) | 1497 | if (!policy) |
1498 | return; | 1498 | return; |
1499 | 1499 | ||
1500 | if (cpufreq_driver->resume) { | 1500 | if (cpufreq_driver->resume) { |
1501 | ret = cpufreq_driver->resume(cpu_policy); | 1501 | ret = cpufreq_driver->resume(policy); |
1502 | if (ret) { | 1502 | if (ret) { |
1503 | printk(KERN_ERR "cpufreq: resume failed in ->resume " | 1503 | printk(KERN_ERR "cpufreq: resume failed in ->resume " |
1504 | "step on CPU %u\n", cpu_policy->cpu); | 1504 | "step on CPU %u\n", policy->cpu); |
1505 | goto fail; | 1505 | goto fail; |
1506 | } | 1506 | } |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | schedule_work(&cpu_policy->update); | 1509 | schedule_work(&policy->update); |
1510 | 1510 | ||
1511 | fail: | 1511 | fail: |
1512 | cpufreq_cpu_put(cpu_policy); | 1512 | cpufreq_cpu_put(policy); |
1513 | } | 1513 | } |
1514 | 1514 | ||
1515 | static struct syscore_ops cpufreq_syscore_ops = { | 1515 | static struct syscore_ops cpufreq_syscore_ops = { |
@@ -1829,95 +1829,95 @@ EXPORT_SYMBOL(cpufreq_get_policy); | |||
1829 | * data : current policy. | 1829 | * data : current policy. |
1830 | * policy : policy to be set. | 1830 | * policy : policy to be set. |
1831 | */ | 1831 | */ |
1832 | static int __cpufreq_set_policy(struct cpufreq_policy *data, | 1832 | static int __cpufreq_set_policy(struct cpufreq_policy *policy, |
1833 | struct cpufreq_policy *policy) | 1833 | struct cpufreq_policy *new_policy) |
1834 | { | 1834 | { |
1835 | int ret = 0, failed = 1; | 1835 | int ret = 0, failed = 1; |
1836 | 1836 | ||
1837 | pr_debug("setting new policy for CPU %u: %u - %u kHz\n", policy->cpu, | 1837 | pr_debug("setting new policy for CPU %u: %u - %u kHz\n", new_policy->cpu, |
1838 | policy->min, policy->max); | 1838 | new_policy->min, new_policy->max); |
1839 | 1839 | ||
1840 | memcpy(&policy->cpuinfo, &data->cpuinfo, | 1840 | memcpy(&new_policy->cpuinfo, &policy->cpuinfo, |
1841 | sizeof(struct cpufreq_cpuinfo)); | 1841 | sizeof(struct cpufreq_cpuinfo)); |
1842 | 1842 | ||
1843 | if (policy->min > data->max || policy->max < data->min) { | 1843 | if (new_policy->min > policy->max || new_policy->max < policy->min) { |
1844 | ret = -EINVAL; | 1844 | ret = -EINVAL; |
1845 | goto error_out; | 1845 | goto error_out; |
1846 | } | 1846 | } |
1847 | 1847 | ||
1848 | /* verify the cpu speed can be set within this limit */ | 1848 | /* verify the cpu speed can be set within this limit */ |
1849 | ret = cpufreq_driver->verify(policy); | 1849 | ret = cpufreq_driver->verify(new_policy); |
1850 | if (ret) | 1850 | if (ret) |
1851 | goto error_out; | 1851 | goto error_out; |
1852 | 1852 | ||
1853 | /* adjust if necessary - all reasons */ | 1853 | /* adjust if necessary - all reasons */ |
1854 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 1854 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1855 | CPUFREQ_ADJUST, policy); | 1855 | CPUFREQ_ADJUST, new_policy); |
1856 | 1856 | ||
1857 | /* adjust if necessary - hardware incompatibility*/ | 1857 | /* adjust if necessary - hardware incompatibility*/ |
1858 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 1858 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1859 | CPUFREQ_INCOMPATIBLE, policy); | 1859 | CPUFREQ_INCOMPATIBLE, new_policy); |
1860 | 1860 | ||
1861 | /* | 1861 | /* |
1862 | * verify the cpu speed can be set within this limit, which might be | 1862 | * verify the cpu speed can be set within this limit, which might be |
1863 | * different to the first one | 1863 | * different to the first one |
1864 | */ | 1864 | */ |
1865 | ret = cpufreq_driver->verify(policy); | 1865 | ret = cpufreq_driver->verify(new_policy); |
1866 | if (ret) | 1866 | if (ret) |
1867 | goto error_out; | 1867 | goto error_out; |
1868 | 1868 | ||
1869 | /* notification of the new policy */ | 1869 | /* notification of the new policy */ |
1870 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 1870 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1871 | CPUFREQ_NOTIFY, policy); | 1871 | CPUFREQ_NOTIFY, new_policy); |
1872 | 1872 | ||
1873 | data->min = policy->min; | 1873 | policy->min = new_policy->min; |
1874 | data->max = policy->max; | 1874 | policy->max = new_policy->max; |
1875 | 1875 | ||
1876 | pr_debug("new min and max freqs are %u - %u kHz\n", | 1876 | pr_debug("new min and max freqs are %u - %u kHz\n", |
1877 | data->min, data->max); | 1877 | policy->min, policy->max); |
1878 | 1878 | ||
1879 | if (cpufreq_driver->setpolicy) { | 1879 | if (cpufreq_driver->setpolicy) { |
1880 | data->policy = policy->policy; | 1880 | policy->policy = new_policy->policy; |
1881 | pr_debug("setting range\n"); | 1881 | pr_debug("setting range\n"); |
1882 | ret = cpufreq_driver->setpolicy(policy); | 1882 | ret = cpufreq_driver->setpolicy(new_policy); |
1883 | } else { | 1883 | } else { |
1884 | if (policy->governor != data->governor) { | 1884 | if (new_policy->governor != policy->governor) { |
1885 | /* save old, working values */ | 1885 | /* save old, working values */ |
1886 | struct cpufreq_governor *old_gov = data->governor; | 1886 | struct cpufreq_governor *old_gov = policy->governor; |
1887 | 1887 | ||
1888 | pr_debug("governor switch\n"); | 1888 | pr_debug("governor switch\n"); |
1889 | 1889 | ||
1890 | /* end old governor */ | 1890 | /* end old governor */ |
1891 | if (data->governor) { | 1891 | if (policy->governor) { |
1892 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); | 1892 | __cpufreq_governor(policy, CPUFREQ_GOV_STOP); |
1893 | unlock_policy_rwsem_write(policy->cpu); | 1893 | unlock_policy_rwsem_write(new_policy->cpu); |
1894 | __cpufreq_governor(data, | 1894 | __cpufreq_governor(policy, |
1895 | CPUFREQ_GOV_POLICY_EXIT); | 1895 | CPUFREQ_GOV_POLICY_EXIT); |
1896 | lock_policy_rwsem_write(policy->cpu); | 1896 | lock_policy_rwsem_write(new_policy->cpu); |
1897 | } | 1897 | } |
1898 | 1898 | ||
1899 | /* start new governor */ | 1899 | /* start new governor */ |
1900 | data->governor = policy->governor; | 1900 | policy->governor = new_policy->governor; |
1901 | if (!__cpufreq_governor(data, CPUFREQ_GOV_POLICY_INIT)) { | 1901 | if (!__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT)) { |
1902 | if (!__cpufreq_governor(data, CPUFREQ_GOV_START)) { | 1902 | if (!__cpufreq_governor(policy, CPUFREQ_GOV_START)) { |
1903 | failed = 0; | 1903 | failed = 0; |
1904 | } else { | 1904 | } else { |
1905 | unlock_policy_rwsem_write(policy->cpu); | 1905 | unlock_policy_rwsem_write(new_policy->cpu); |
1906 | __cpufreq_governor(data, | 1906 | __cpufreq_governor(policy, |
1907 | CPUFREQ_GOV_POLICY_EXIT); | 1907 | CPUFREQ_GOV_POLICY_EXIT); |
1908 | lock_policy_rwsem_write(policy->cpu); | 1908 | lock_policy_rwsem_write(new_policy->cpu); |
1909 | } | 1909 | } |
1910 | } | 1910 | } |
1911 | 1911 | ||
1912 | if (failed) { | 1912 | if (failed) { |
1913 | /* new governor failed, so re-start old one */ | 1913 | /* new governor failed, so re-start old one */ |
1914 | pr_debug("starting governor %s failed\n", | 1914 | pr_debug("starting governor %s failed\n", |
1915 | data->governor->name); | 1915 | policy->governor->name); |
1916 | if (old_gov) { | 1916 | if (old_gov) { |
1917 | data->governor = old_gov; | 1917 | policy->governor = old_gov; |
1918 | __cpufreq_governor(data, | 1918 | __cpufreq_governor(policy, |
1919 | CPUFREQ_GOV_POLICY_INIT); | 1919 | CPUFREQ_GOV_POLICY_INIT); |
1920 | __cpufreq_governor(data, | 1920 | __cpufreq_governor(policy, |
1921 | CPUFREQ_GOV_START); | 1921 | CPUFREQ_GOV_START); |
1922 | } | 1922 | } |
1923 | ret = -EINVAL; | 1923 | ret = -EINVAL; |
@@ -1926,7 +1926,7 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, | |||
1926 | /* might be a policy change, too, so fall through */ | 1926 | /* might be a policy change, too, so fall through */ |
1927 | } | 1927 | } |
1928 | pr_debug("governor: change or update limits\n"); | 1928 | pr_debug("governor: change or update limits\n"); |
1929 | __cpufreq_governor(data, CPUFREQ_GOV_LIMITS); | 1929 | __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); |
1930 | } | 1930 | } |
1931 | 1931 | ||
1932 | error_out: | 1932 | error_out: |
@@ -1942,11 +1942,11 @@ error_out: | |||
1942 | */ | 1942 | */ |
1943 | int cpufreq_update_policy(unsigned int cpu) | 1943 | int cpufreq_update_policy(unsigned int cpu) |
1944 | { | 1944 | { |
1945 | struct cpufreq_policy *data = cpufreq_cpu_get(cpu); | 1945 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); |
1946 | struct cpufreq_policy policy; | 1946 | struct cpufreq_policy new_policy; |
1947 | int ret; | 1947 | int ret; |
1948 | 1948 | ||
1949 | if (!data) { | 1949 | if (!policy) { |
1950 | ret = -ENODEV; | 1950 | ret = -ENODEV; |
1951 | goto no_policy; | 1951 | goto no_policy; |
1952 | } | 1952 | } |
@@ -1957,34 +1957,34 @@ int cpufreq_update_policy(unsigned int cpu) | |||
1957 | } | 1957 | } |
1958 | 1958 | ||
1959 | pr_debug("updating policy for CPU %u\n", cpu); | 1959 | pr_debug("updating policy for CPU %u\n", cpu); |
1960 | memcpy(&policy, data, sizeof(struct cpufreq_policy)); | 1960 | memcpy(&new_policy, policy, sizeof(struct cpufreq_policy)); |
1961 | policy.min = data->user_policy.min; | 1961 | new_policy.min = policy->user_policy.min; |
1962 | policy.max = data->user_policy.max; | 1962 | new_policy.max = policy->user_policy.max; |
1963 | policy.policy = data->user_policy.policy; | 1963 | new_policy.policy = policy->user_policy.policy; |
1964 | policy.governor = data->user_policy.governor; | 1964 | new_policy.governor = policy->user_policy.governor; |
1965 | 1965 | ||
1966 | /* | 1966 | /* |
1967 | * BIOS might change freq behind our back | 1967 | * BIOS might change freq behind our back |
1968 | * -> ask driver for current freq and notify governors about a change | 1968 | * -> ask driver for current freq and notify governors about a change |
1969 | */ | 1969 | */ |
1970 | if (cpufreq_driver->get) { | 1970 | if (cpufreq_driver->get) { |
1971 | policy.cur = cpufreq_driver->get(cpu); | 1971 | new_policy.cur = cpufreq_driver->get(cpu); |
1972 | if (!data->cur) { | 1972 | if (!policy->cur) { |
1973 | pr_debug("Driver did not initialize current freq"); | 1973 | pr_debug("Driver did not initialize current freq"); |
1974 | data->cur = policy.cur; | 1974 | policy->cur = new_policy.cur; |
1975 | } else { | 1975 | } else { |
1976 | if (data->cur != policy.cur && cpufreq_driver->target) | 1976 | if (policy->cur != new_policy.cur && cpufreq_driver->target) |
1977 | cpufreq_out_of_sync(cpu, data->cur, | 1977 | cpufreq_out_of_sync(cpu, policy->cur, |
1978 | policy.cur); | 1978 | new_policy.cur); |
1979 | } | 1979 | } |
1980 | } | 1980 | } |
1981 | 1981 | ||
1982 | ret = __cpufreq_set_policy(data, &policy); | 1982 | ret = __cpufreq_set_policy(policy, &new_policy); |
1983 | 1983 | ||
1984 | unlock_policy_rwsem_write(cpu); | 1984 | unlock_policy_rwsem_write(cpu); |
1985 | 1985 | ||
1986 | fail: | 1986 | fail: |
1987 | cpufreq_cpu_put(data); | 1987 | cpufreq_cpu_put(policy); |
1988 | no_policy: | 1988 | no_policy: |
1989 | return ret; | 1989 | return ret; |
1990 | } | 1990 | } |
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index cf0b7a4425b0..264e509a9149 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h | |||
@@ -221,7 +221,7 @@ struct od_ops { | |||
221 | void (*powersave_bias_init_cpu)(int cpu); | 221 | void (*powersave_bias_init_cpu)(int cpu); |
222 | unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy, | 222 | unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy, |
223 | unsigned int freq_next, unsigned int relation); | 223 | unsigned int freq_next, unsigned int relation); |
224 | void (*freq_increase)(struct cpufreq_policy *p, unsigned int freq); | 224 | void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq); |
225 | }; | 225 | }; |
226 | 226 | ||
227 | struct cs_ops { | 227 | struct cs_ops { |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 27c732eee431..47d4b69be7c6 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -132,18 +132,18 @@ static void ondemand_powersave_bias_init(void) | |||
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
135 | static void dbs_freq_increase(struct cpufreq_policy *p, unsigned int freq) | 135 | static void dbs_freq_increase(struct cpufreq_policy *policy, unsigned int freq) |
136 | { | 136 | { |
137 | struct dbs_data *dbs_data = p->governor_data; | 137 | struct dbs_data *dbs_data = policy->governor_data; |
138 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | 138 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; |
139 | 139 | ||
140 | if (od_tuners->powersave_bias) | 140 | if (od_tuners->powersave_bias) |
141 | freq = od_ops.powersave_bias_target(p, freq, | 141 | freq = od_ops.powersave_bias_target(policy, freq, |
142 | CPUFREQ_RELATION_H); | 142 | CPUFREQ_RELATION_H); |
143 | else if (p->cur == p->max) | 143 | else if (policy->cur == policy->max) |
144 | return; | 144 | return; |
145 | 145 | ||
146 | __cpufreq_driver_target(p, freq, od_tuners->powersave_bias ? | 146 | __cpufreq_driver_target(policy, freq, od_tuners->powersave_bias ? |
147 | CPUFREQ_RELATION_L : CPUFREQ_RELATION_H); | 147 | CPUFREQ_RELATION_L : CPUFREQ_RELATION_H); |
148 | } | 148 | } |
149 | 149 | ||
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index a7143b0597af..a17b14ee37d8 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -193,7 +193,7 @@ static int cpufreq_stats_create_table(struct cpufreq_policy *policy, | |||
193 | { | 193 | { |
194 | unsigned int i, j, count = 0, ret = 0; | 194 | unsigned int i, j, count = 0, ret = 0; |
195 | struct cpufreq_stats *stat; | 195 | struct cpufreq_stats *stat; |
196 | struct cpufreq_policy *data; | 196 | struct cpufreq_policy *current_policy; |
197 | unsigned int alloc_size; | 197 | unsigned int alloc_size; |
198 | unsigned int cpu = policy->cpu; | 198 | unsigned int cpu = policy->cpu; |
199 | if (per_cpu(cpufreq_stats_table, cpu)) | 199 | if (per_cpu(cpufreq_stats_table, cpu)) |
@@ -202,13 +202,13 @@ static int cpufreq_stats_create_table(struct cpufreq_policy *policy, | |||
202 | if ((stat) == NULL) | 202 | if ((stat) == NULL) |
203 | return -ENOMEM; | 203 | return -ENOMEM; |
204 | 204 | ||
205 | data = cpufreq_cpu_get(cpu); | 205 | current_policy = cpufreq_cpu_get(cpu); |
206 | if (data == NULL) { | 206 | if (current_policy == NULL) { |
207 | ret = -EINVAL; | 207 | ret = -EINVAL; |
208 | goto error_get_fail; | 208 | goto error_get_fail; |
209 | } | 209 | } |
210 | 210 | ||
211 | ret = sysfs_create_group(&data->kobj, &stats_attr_group); | 211 | ret = sysfs_create_group(¤t_policy->kobj, &stats_attr_group); |
212 | if (ret) | 212 | if (ret) |
213 | goto error_out; | 213 | goto error_out; |
214 | 214 | ||
@@ -251,10 +251,10 @@ static int cpufreq_stats_create_table(struct cpufreq_policy *policy, | |||
251 | stat->last_time = get_jiffies_64(); | 251 | stat->last_time = get_jiffies_64(); |
252 | stat->last_index = freq_table_get_index(stat, policy->cur); | 252 | stat->last_index = freq_table_get_index(stat, policy->cur); |
253 | spin_unlock(&cpufreq_stats_lock); | 253 | spin_unlock(&cpufreq_stats_lock); |
254 | cpufreq_cpu_put(data); | 254 | cpufreq_cpu_put(current_policy); |
255 | return 0; | 255 | return 0; |
256 | error_out: | 256 | error_out: |
257 | cpufreq_cpu_put(data); | 257 | cpufreq_cpu_put(current_policy); |
258 | error_get_fail: | 258 | error_get_fail: |
259 | kfree(stat); | 259 | kfree(stat); |
260 | per_cpu(cpufreq_stats_table, cpu) = NULL; | 260 | per_cpu(cpufreq_stats_table, cpu) = NULL; |
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 0d3b0266bc98..29208923c9d3 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -94,7 +94,7 @@ struct cpufreq_policy { | |||
94 | #define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/ | 94 | #define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/ |
95 | 95 | ||
96 | struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu); | 96 | struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu); |
97 | void cpufreq_cpu_put(struct cpufreq_policy *data); | 97 | void cpufreq_cpu_put(struct cpufreq_policy *policy); |
98 | 98 | ||
99 | static inline bool policy_is_shared(struct cpufreq_policy *policy) | 99 | static inline bool policy_is_shared(struct cpufreq_policy *policy) |
100 | { | 100 | { |