diff options
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 1afbe52d6782..d7efdfe0c12c 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -176,6 +176,20 @@ int cpufreq_generic_init(struct cpufreq_policy *policy, | |||
176 | } | 176 | } |
177 | EXPORT_SYMBOL_GPL(cpufreq_generic_init); | 177 | EXPORT_SYMBOL_GPL(cpufreq_generic_init); |
178 | 178 | ||
179 | unsigned int cpufreq_generic_get(unsigned int cpu) | ||
180 | { | ||
181 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); | ||
182 | |||
183 | if (!policy || IS_ERR(policy->clk)) { | ||
184 | pr_err("%s: No %s associated to cpu: %d\n", __func__, | ||
185 | policy ? "clk" : "policy", cpu); | ||
186 | return 0; | ||
187 | } | ||
188 | |||
189 | return clk_get_rate(policy->clk) / 1000; | ||
190 | } | ||
191 | EXPORT_SYMBOL_GPL(cpufreq_generic_get); | ||
192 | |||
179 | struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) | 193 | struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) |
180 | { | 194 | { |
181 | struct cpufreq_policy *policy = NULL; | 195 | struct cpufreq_policy *policy = NULL; |
@@ -1068,6 +1082,11 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | |||
1068 | goto err_set_policy_cpu; | 1082 | goto err_set_policy_cpu; |
1069 | } | 1083 | } |
1070 | 1084 | ||
1085 | write_lock_irqsave(&cpufreq_driver_lock, flags); | ||
1086 | for_each_cpu(j, policy->cpus) | ||
1087 | per_cpu(cpufreq_cpu_data, j) = policy; | ||
1088 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | ||
1089 | |||
1071 | if (cpufreq_driver->get) { | 1090 | if (cpufreq_driver->get) { |
1072 | policy->cur = cpufreq_driver->get(policy->cpu); | 1091 | policy->cur = cpufreq_driver->get(policy->cpu); |
1073 | if (!policy->cur) { | 1092 | if (!policy->cur) { |
@@ -1142,11 +1161,6 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | |||
1142 | } | 1161 | } |
1143 | #endif | 1162 | #endif |
1144 | 1163 | ||
1145 | write_lock_irqsave(&cpufreq_driver_lock, flags); | ||
1146 | for_each_cpu(j, policy->cpus) | ||
1147 | per_cpu(cpufreq_cpu_data, j) = policy; | ||
1148 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | ||
1149 | |||
1150 | if (!frozen) { | 1164 | if (!frozen) { |
1151 | ret = cpufreq_add_dev_interface(policy, dev); | 1165 | ret = cpufreq_add_dev_interface(policy, dev); |
1152 | if (ret) | 1166 | if (ret) |
@@ -1174,12 +1188,12 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | |||
1174 | return 0; | 1188 | return 0; |
1175 | 1189 | ||
1176 | err_out_unregister: | 1190 | err_out_unregister: |
1191 | err_get_freq: | ||
1177 | write_lock_irqsave(&cpufreq_driver_lock, flags); | 1192 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
1178 | for_each_cpu(j, policy->cpus) | 1193 | for_each_cpu(j, policy->cpus) |
1179 | per_cpu(cpufreq_cpu_data, j) = NULL; | 1194 | per_cpu(cpufreq_cpu_data, j) = NULL; |
1180 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1195 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1181 | 1196 | ||
1182 | err_get_freq: | ||
1183 | if (cpufreq_driver->exit) | 1197 | if (cpufreq_driver->exit) |
1184 | cpufreq_driver->exit(policy); | 1198 | cpufreq_driver->exit(policy); |
1185 | err_set_policy_cpu: | 1199 | err_set_policy_cpu: |