diff options
Diffstat (limited to 'drivers/cpufreq/freq_table.c')
-rw-r--r-- | drivers/cpufreq/freq_table.c | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index 8e54f97899ba..65a477075b3f 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c | |||
@@ -91,8 +91,8 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, | |||
91 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify); | 91 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify); |
92 | 92 | ||
93 | /* | 93 | /* |
94 | * Generic routine to verify policy & frequency table, requires driver to call | 94 | * Generic routine to verify policy & frequency table, requires driver to set |
95 | * cpufreq_frequency_table_get_attr() prior to it. | 95 | * policy->freq_table prior to it. |
96 | */ | 96 | */ |
97 | int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy) | 97 | int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy) |
98 | { | 98 | { |
@@ -203,8 +203,6 @@ int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy, | |||
203 | } | 203 | } |
204 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_index); | 204 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_index); |
205 | 205 | ||
206 | static DEFINE_PER_CPU(struct cpufreq_frequency_table *, cpufreq_show_table); | ||
207 | |||
208 | /** | 206 | /** |
209 | * show_available_freqs - show available frequencies for the specified CPU | 207 | * show_available_freqs - show available frequencies for the specified CPU |
210 | */ | 208 | */ |
@@ -212,15 +210,12 @@ static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf, | |||
212 | bool show_boost) | 210 | bool show_boost) |
213 | { | 211 | { |
214 | unsigned int i = 0; | 212 | unsigned int i = 0; |
215 | unsigned int cpu = policy->cpu; | ||
216 | ssize_t count = 0; | 213 | ssize_t count = 0; |
217 | struct cpufreq_frequency_table *table; | 214 | struct cpufreq_frequency_table *table = policy->freq_table; |
218 | 215 | ||
219 | if (!per_cpu(cpufreq_show_table, cpu)) | 216 | if (!table) |
220 | return -ENODEV; | 217 | return -ENODEV; |
221 | 218 | ||
222 | table = per_cpu(cpufreq_show_table, cpu); | ||
223 | |||
224 | for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { | 219 | for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { |
225 | if (table[i].frequency == CPUFREQ_ENTRY_INVALID) | 220 | if (table[i].frequency == CPUFREQ_ENTRY_INVALID) |
226 | continue; | 221 | continue; |
@@ -283,49 +278,24 @@ struct freq_attr *cpufreq_generic_attr[] = { | |||
283 | }; | 278 | }; |
284 | EXPORT_SYMBOL_GPL(cpufreq_generic_attr); | 279 | EXPORT_SYMBOL_GPL(cpufreq_generic_attr); |
285 | 280 | ||
286 | /* | ||
287 | * if you use these, you must assure that the frequency table is valid | ||
288 | * all the time between get_attr and put_attr! | ||
289 | */ | ||
290 | void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, | ||
291 | unsigned int cpu) | ||
292 | { | ||
293 | pr_debug("setting show_table for cpu %u to %p\n", cpu, table); | ||
294 | per_cpu(cpufreq_show_table, cpu) = table; | ||
295 | } | ||
296 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_attr); | ||
297 | |||
298 | void cpufreq_frequency_table_put_attr(unsigned int cpu) | ||
299 | { | ||
300 | pr_debug("clearing show_table for cpu %u\n", cpu); | ||
301 | per_cpu(cpufreq_show_table, cpu) = NULL; | ||
302 | } | ||
303 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr); | ||
304 | |||
305 | int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, | 281 | int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, |
306 | struct cpufreq_frequency_table *table) | 282 | struct cpufreq_frequency_table *table) |
307 | { | 283 | { |
308 | int ret = cpufreq_frequency_table_cpuinfo(policy, table); | 284 | int ret = cpufreq_frequency_table_cpuinfo(policy, table); |
309 | 285 | ||
310 | if (!ret) | 286 | if (!ret) |
311 | cpufreq_frequency_table_get_attr(table, policy->cpu); | 287 | policy->freq_table = table; |
312 | 288 | ||
313 | return ret; | 289 | return ret; |
314 | } | 290 | } |
315 | EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show); | 291 | EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show); |
316 | 292 | ||
317 | void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy) | 293 | struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu); |
318 | { | ||
319 | pr_debug("Updating show_table for new_cpu %u from last_cpu %u\n", | ||
320 | policy->cpu, policy->last_cpu); | ||
321 | per_cpu(cpufreq_show_table, policy->cpu) = per_cpu(cpufreq_show_table, | ||
322 | policy->last_cpu); | ||
323 | per_cpu(cpufreq_show_table, policy->last_cpu) = NULL; | ||
324 | } | ||
325 | 294 | ||
326 | struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu) | 295 | struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu) |
327 | { | 296 | { |
328 | return per_cpu(cpufreq_show_table, cpu); | 297 | struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu); |
298 | return policy ? policy->freq_table : NULL; | ||
329 | } | 299 | } |
330 | EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); | 300 | EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); |
331 | 301 | ||