diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2016-02-09 00:00:47 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-02-10 18:24:37 -0500 |
commit | df2c8ec28e73d47392b8cb24828c15c54819da41 (patch) | |
tree | 0532b4e71598c993670577d7735b8e8f8d0c7ca8 /drivers/cpufreq/cpufreq-dt.c | |
parent | 78c3ba5df96c875b1668e1cd3ee0a69e62454f32 (diff) |
cpufreq: dt: No need to fetch voltage-tolerance
Its already done by core and we don't need to get it anymore. And so,
we don't need to get of node in cpufreq_init() anymore, move that to
find_supply_name() instead.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq-dt.c')
-rw-r--r-- | drivers/cpufreq/cpufreq-dt.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 150a172c7d0a..bbafd7b63d1a 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c | |||
@@ -33,7 +33,6 @@ struct private_data { | |||
33 | struct device *cpu_dev; | 33 | struct device *cpu_dev; |
34 | struct regulator *cpu_reg; | 34 | struct regulator *cpu_reg; |
35 | struct thermal_cooling_device *cdev; | 35 | struct thermal_cooling_device *cdev; |
36 | unsigned int voltage_tolerance; /* in percentage */ | ||
37 | const char *reg_name; | 36 | const char *reg_name; |
38 | }; | 37 | }; |
39 | 38 | ||
@@ -55,24 +54,38 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index) | |||
55 | * An earlier version of opp-v1 bindings used to name the regulator | 54 | * An earlier version of opp-v1 bindings used to name the regulator |
56 | * "cpu0-supply", we still need to handle that for backwards compatibility. | 55 | * "cpu0-supply", we still need to handle that for backwards compatibility. |
57 | */ | 56 | */ |
58 | static const char *find_supply_name(struct device *dev, struct device_node *np) | 57 | static const char *find_supply_name(struct device *dev) |
59 | { | 58 | { |
59 | struct device_node *np; | ||
60 | struct property *pp; | 60 | struct property *pp; |
61 | int cpu = dev->id; | 61 | int cpu = dev->id; |
62 | const char *name = NULL; | ||
63 | |||
64 | np = of_node_get(dev->of_node); | ||
65 | |||
66 | /* This must be valid for sure */ | ||
67 | if (WARN_ON(!np)) | ||
68 | return NULL; | ||
62 | 69 | ||
63 | /* Try "cpu0" for older DTs */ | 70 | /* Try "cpu0" for older DTs */ |
64 | if (!cpu) { | 71 | if (!cpu) { |
65 | pp = of_find_property(np, "cpu0-supply", NULL); | 72 | pp = of_find_property(np, "cpu0-supply", NULL); |
66 | if (pp) | 73 | if (pp) { |
67 | return "cpu0"; | 74 | name = "cpu0"; |
75 | goto node_put; | ||
76 | } | ||
68 | } | 77 | } |
69 | 78 | ||
70 | pp = of_find_property(np, "cpu-supply", NULL); | 79 | pp = of_find_property(np, "cpu-supply", NULL); |
71 | if (pp) | 80 | if (pp) { |
72 | return "cpu"; | 81 | name = "cpu"; |
82 | goto node_put; | ||
83 | } | ||
73 | 84 | ||
74 | dev_dbg(dev, "no regulator for cpu%d\n", cpu); | 85 | dev_dbg(dev, "no regulator for cpu%d\n", cpu); |
75 | return NULL; | 86 | node_put: |
87 | of_node_put(np); | ||
88 | return name; | ||
76 | } | 89 | } |
77 | 90 | ||
78 | static int allocate_resources(int cpu, struct device **cdev, | 91 | static int allocate_resources(int cpu, struct device **cdev, |
@@ -147,7 +160,6 @@ try_again: | |||
147 | static int cpufreq_init(struct cpufreq_policy *policy) | 160 | static int cpufreq_init(struct cpufreq_policy *policy) |
148 | { | 161 | { |
149 | struct cpufreq_frequency_table *freq_table; | 162 | struct cpufreq_frequency_table *freq_table; |
150 | struct device_node *np; | ||
151 | struct private_data *priv; | 163 | struct private_data *priv; |
152 | struct device *cpu_dev; | 164 | struct device *cpu_dev; |
153 | struct regulator *cpu_reg; | 165 | struct regulator *cpu_reg; |
@@ -164,13 +176,6 @@ static int cpufreq_init(struct cpufreq_policy *policy) | |||
164 | return ret; | 176 | return ret; |
165 | } | 177 | } |
166 | 178 | ||
167 | np = of_node_get(cpu_dev->of_node); | ||
168 | if (!np) { | ||
169 | dev_err(cpu_dev, "failed to find cpu%d node\n", policy->cpu); | ||
170 | ret = -ENOENT; | ||
171 | goto out_put_reg_clk; | ||
172 | } | ||
173 | |||
174 | /* Get OPP-sharing information from "operating-points-v2" bindings */ | 179 | /* Get OPP-sharing information from "operating-points-v2" bindings */ |
175 | ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, policy->cpus); | 180 | ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, policy->cpus); |
176 | if (ret) { | 181 | if (ret) { |
@@ -181,20 +186,20 @@ static int cpufreq_init(struct cpufreq_policy *policy) | |||
181 | if (ret == -ENOENT) | 186 | if (ret == -ENOENT) |
182 | opp_v1 = true; | 187 | opp_v1 = true; |
183 | else | 188 | else |
184 | goto out_node_put; | 189 | goto out_put_reg_clk; |
185 | } | 190 | } |
186 | 191 | ||
187 | /* | 192 | /* |
188 | * OPP layer will be taking care of regulators now, but it needs to know | 193 | * OPP layer will be taking care of regulators now, but it needs to know |
189 | * the name of the regulator first. | 194 | * the name of the regulator first. |
190 | */ | 195 | */ |
191 | name = find_supply_name(cpu_dev, np); | 196 | name = find_supply_name(cpu_dev); |
192 | if (name) { | 197 | if (name) { |
193 | ret = dev_pm_opp_set_regulator(cpu_dev, name); | 198 | ret = dev_pm_opp_set_regulator(cpu_dev, name); |
194 | if (ret) { | 199 | if (ret) { |
195 | dev_err(cpu_dev, "Failed to set regulator for cpu%d: %d\n", | 200 | dev_err(cpu_dev, "Failed to set regulator for cpu%d: %d\n", |
196 | policy->cpu, ret); | 201 | policy->cpu, ret); |
197 | goto out_node_put; | 202 | goto out_put_reg_clk; |
198 | } | 203 | } |
199 | } | 204 | } |
200 | 205 | ||
@@ -244,7 +249,6 @@ static int cpufreq_init(struct cpufreq_policy *policy) | |||
244 | } | 249 | } |
245 | 250 | ||
246 | priv->reg_name = name; | 251 | priv->reg_name = name; |
247 | of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance); | ||
248 | 252 | ||
249 | ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table); | 253 | ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table); |
250 | if (ret) { | 254 | if (ret) { |
@@ -286,8 +290,6 @@ static int cpufreq_init(struct cpufreq_policy *policy) | |||
286 | 290 | ||
287 | policy->cpuinfo.transition_latency = transition_latency; | 291 | policy->cpuinfo.transition_latency = transition_latency; |
288 | 292 | ||
289 | of_node_put(np); | ||
290 | |||
291 | return 0; | 293 | return 0; |
292 | 294 | ||
293 | out_free_cpufreq_table: | 295 | out_free_cpufreq_table: |
@@ -298,8 +300,6 @@ out_free_opp: | |||
298 | dev_pm_opp_of_cpumask_remove_table(policy->cpus); | 300 | dev_pm_opp_of_cpumask_remove_table(policy->cpus); |
299 | if (name) | 301 | if (name) |
300 | dev_pm_opp_put_regulator(cpu_dev); | 302 | dev_pm_opp_put_regulator(cpu_dev); |
301 | out_node_put: | ||
302 | of_node_put(np); | ||
303 | out_put_reg_clk: | 303 | out_put_reg_clk: |
304 | clk_put(cpu_clk); | 304 | clk_put(cpu_clk); |
305 | if (!IS_ERR(cpu_reg)) | 305 | if (!IS_ERR(cpu_reg)) |