Skip to content

Commit 4b2c9f2

Browse files
vireshkAlex Shi
authored andcommitted
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> (cherry picked from commit df2c8ec28e73d47392b8cb24828c15c54819da41) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent 5da10c8 commit 4b2c9f2

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

drivers/cpufreq/cpufreq-dt.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ struct private_data {
3333
struct device *cpu_dev;
3434
struct regulator *cpu_reg;
3535
struct thermal_cooling_device *cdev;
36-
unsigned int voltage_tolerance; /* in percentage */
3736
const char *reg_name;
3837
};
3938

@@ -55,24 +54,38 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
5554
* An earlier version of opp-v1 bindings used to name the regulator
5655
* "cpu0-supply", we still need to handle that for backwards compatibility.
5756
*/
58-
static const char *find_supply_name(struct device *dev, struct device_node *np)
57+
static const char *find_supply_name(struct device *dev)
5958
{
59+
struct device_node *np;
6060
struct property *pp;
6161
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;
6269

6370
/* Try "cpu0" for older DTs */
6471
if (!cpu) {
6572
pp = of_find_property(np, "cpu0-supply", NULL);
66-
if (pp)
67-
return "cpu0";
73+
if (pp) {
74+
name = "cpu0";
75+
goto node_put;
76+
}
6877
}
6978

7079
pp = of_find_property(np, "cpu-supply", NULL);
71-
if (pp)
72-
return "cpu";
80+
if (pp) {
81+
name = "cpu";
82+
goto node_put;
83+
}
7384

7485
dev_dbg(dev, "no regulator for cpu%d\n", cpu);
75-
return NULL;
86+
node_put:
87+
of_node_put(np);
88+
return name;
7689
}
7790

7891
static int allocate_resources(int cpu, struct device **cdev,
@@ -147,7 +160,6 @@ static int allocate_resources(int cpu, struct device **cdev,
147160
static int cpufreq_init(struct cpufreq_policy *policy)
148161
{
149162
struct cpufreq_frequency_table *freq_table;
150-
struct device_node *np;
151163
struct private_data *priv;
152164
struct device *cpu_dev;
153165
struct regulator *cpu_reg;
@@ -164,13 +176,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
164176
return ret;
165177
}
166178

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-
174179
/* Get OPP-sharing information from "operating-points-v2" bindings */
175180
ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, policy->cpus);
176181
if (ret) {
@@ -181,20 +186,20 @@ static int cpufreq_init(struct cpufreq_policy *policy)
181186
if (ret == -ENOENT)
182187
opp_v1 = true;
183188
else
184-
goto out_node_put;
189+
goto out_put_reg_clk;
185190
}
186191

187192
/*
188193
* OPP layer will be taking care of regulators now, but it needs to know
189194
* the name of the regulator first.
190195
*/
191-
name = find_supply_name(cpu_dev, np);
196+
name = find_supply_name(cpu_dev);
192197
if (name) {
193198
ret = dev_pm_opp_set_regulator(cpu_dev, name);
194199
if (ret) {
195200
dev_err(cpu_dev, "Failed to set regulator for cpu%d: %d\n",
196201
policy->cpu, ret);
197-
goto out_node_put;
202+
goto out_put_reg_clk;
198203
}
199204
}
200205

@@ -244,7 +249,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
244249
}
245250

246251
priv->reg_name = name;
247-
of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance);
248252

249253
ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
250254
if (ret) {
@@ -286,8 +290,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
286290

287291
policy->cpuinfo.transition_latency = transition_latency;
288292

289-
of_node_put(np);
290-
291293
return 0;
292294

293295
out_free_cpufreq_table:
@@ -298,8 +300,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
298300
dev_pm_opp_of_cpumask_remove_table(policy->cpus);
299301
if (name)
300302
dev_pm_opp_put_regulator(cpu_dev);
301-
out_node_put:
302-
of_node_put(np);
303303
out_put_reg_clk:
304304
clk_put(cpu_clk);
305305
if (!IS_ERR(cpu_reg))

0 commit comments

Comments
 (0)