aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/cpufreq.c35
-rw-r--r--drivers/cpufreq/exynos-cpufreq.c14
2 files changed, 39 insertions, 10 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 7f2f149ae40f..fb8a5279c5d8 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -138,7 +138,7 @@ void disable_cpufreq(void)
138static LIST_HEAD(cpufreq_governor_list); 138static LIST_HEAD(cpufreq_governor_list);
139static DEFINE_MUTEX(cpufreq_governor_mutex); 139static DEFINE_MUTEX(cpufreq_governor_mutex);
140 140
141struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) 141static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs)
142{ 142{
143 struct cpufreq_policy *data; 143 struct cpufreq_policy *data;
144 unsigned long flags; 144 unsigned long flags;
@@ -162,7 +162,7 @@ struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
162 if (!data) 162 if (!data)
163 goto err_out_put_module; 163 goto err_out_put_module;
164 164
165 if (!kobject_get(&data->kobj)) 165 if (!sysfs && !kobject_get(&data->kobj))
166 goto err_out_put_module; 166 goto err_out_put_module;
167 167
168 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 168 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
@@ -175,16 +175,35 @@ err_out_unlock:
175err_out: 175err_out:
176 return NULL; 176 return NULL;
177} 177}
178
179struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
180{
181 return __cpufreq_cpu_get(cpu, false);
182}
178EXPORT_SYMBOL_GPL(cpufreq_cpu_get); 183EXPORT_SYMBOL_GPL(cpufreq_cpu_get);
179 184
185static struct cpufreq_policy *cpufreq_cpu_get_sysfs(unsigned int cpu)
186{
187 return __cpufreq_cpu_get(cpu, true);
188}
180 189
181void cpufreq_cpu_put(struct cpufreq_policy *data) 190static void __cpufreq_cpu_put(struct cpufreq_policy *data, bool sysfs)
182{ 191{
183 kobject_put(&data->kobj); 192 if (!sysfs)
193 kobject_put(&data->kobj);
184 module_put(cpufreq_driver->owner); 194 module_put(cpufreq_driver->owner);
185} 195}
196
197void cpufreq_cpu_put(struct cpufreq_policy *data)
198{
199 __cpufreq_cpu_put(data, false);
200}
186EXPORT_SYMBOL_GPL(cpufreq_cpu_put); 201EXPORT_SYMBOL_GPL(cpufreq_cpu_put);
187 202
203static void cpufreq_cpu_put_sysfs(struct cpufreq_policy *data)
204{
205 __cpufreq_cpu_put(data, true);
206}
188 207
189/********************************************************************* 208/*********************************************************************
190 * EXTERNALLY AFFECTING FREQUENCY CHANGES * 209 * EXTERNALLY AFFECTING FREQUENCY CHANGES *
@@ -617,7 +636,7 @@ static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf)
617 struct cpufreq_policy *policy = to_policy(kobj); 636 struct cpufreq_policy *policy = to_policy(kobj);
618 struct freq_attr *fattr = to_attr(attr); 637 struct freq_attr *fattr = to_attr(attr);
619 ssize_t ret = -EINVAL; 638 ssize_t ret = -EINVAL;
620 policy = cpufreq_cpu_get(policy->cpu); 639 policy = cpufreq_cpu_get_sysfs(policy->cpu);
621 if (!policy) 640 if (!policy)
622 goto no_policy; 641 goto no_policy;
623 642
@@ -631,7 +650,7 @@ static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf)
631 650
632 unlock_policy_rwsem_read(policy->cpu); 651 unlock_policy_rwsem_read(policy->cpu);
633fail: 652fail:
634 cpufreq_cpu_put(policy); 653 cpufreq_cpu_put_sysfs(policy);
635no_policy: 654no_policy:
636 return ret; 655 return ret;
637} 656}
@@ -642,7 +661,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
642 struct cpufreq_policy *policy = to_policy(kobj); 661 struct cpufreq_policy *policy = to_policy(kobj);
643 struct freq_attr *fattr = to_attr(attr); 662 struct freq_attr *fattr = to_attr(attr);
644 ssize_t ret = -EINVAL; 663 ssize_t ret = -EINVAL;
645 policy = cpufreq_cpu_get(policy->cpu); 664 policy = cpufreq_cpu_get_sysfs(policy->cpu);
646 if (!policy) 665 if (!policy)
647 goto no_policy; 666 goto no_policy;
648 667
@@ -656,7 +675,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
656 675
657 unlock_policy_rwsem_write(policy->cpu); 676 unlock_policy_rwsem_write(policy->cpu);
658fail: 677fail:
659 cpufreq_cpu_put(policy); 678 cpufreq_cpu_put_sysfs(policy);
660no_policy: 679no_policy:
661 return ret; 680 return ret;
662} 681}
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index b243a7ee01f6..af2d81e10f71 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -62,8 +62,18 @@ static int exynos_target(struct cpufreq_policy *policy,
62 goto out; 62 goto out;
63 } 63 }
64 64
65 if (cpufreq_frequency_table_target(policy, freq_table, 65 /*
66 freqs.old, relation, &old_index)) { 66 * The policy max have been changed so that we cannot get proper
67 * old_index with cpufreq_frequency_table_target(). Thus, ignore
68 * policy and get the index from the raw freqeuncy table.
69 */
70 for (old_index = 0;
71 freq_table[old_index].frequency != CPUFREQ_TABLE_END;
72 old_index++)
73 if (freq_table[old_index].frequency == freqs.old)
74 break;
75
76 if (freq_table[old_index].frequency == CPUFREQ_TABLE_END) {
67 ret = -EINVAL; 77 ret = -EINVAL;
68 goto out; 78 goto out;
69 } 79 }