[PATCH 4.4.y-cip 15/23] cpufreq: dt: No need to fetch voltage-tolerance


Chen-Yu Tsai (Moxa) <wens@...>
 

From: Viresh Kumar <viresh.kumar@linaro.org>

commit df2c8ec28e73d47392b8cb24828c15c54819da41 upstream.

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>
Signed-off-by: Chen-Yu Tsai (Moxa) <wens@csie.org>
---
drivers/cpufreq/cpufreq-dt.c | 46 ++++++++++++++++++------------------
1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 150a172c7d0a7..bbafd7b63d1a2 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -33,7 +33,6 @@ struct private_data {
struct device *cpu_dev;
struct regulator *cpu_reg;
struct thermal_cooling_device *cdev;
- unsigned int voltage_tolerance; /* in percentage */
const char *reg_name;
};
=20
@@ -55,24 +54,38 @@ static int set_target(struct cpufreq_policy *policy, =
unsigned int index)
* An earlier version of opp-v1 bindings used to name the regulator
* "cpu0-supply", we still need to handle that for backwards compatibili=
ty.
*/
-static const char *find_supply_name(struct device *dev, struct device_no=
de *np)
+static const char *find_supply_name(struct device *dev)
{
+ struct device_node *np;
struct property *pp;
int cpu =3D dev->id;
+ const char *name =3D NULL;
+
+ np =3D of_node_get(dev->of_node);
+
+ /* This must be valid for sure */
+ if (WARN_ON(!np))
+ return NULL;
=20
/* Try "cpu0" for older DTs */
if (!cpu) {
pp =3D of_find_property(np, "cpu0-supply", NULL);
- if (pp)
- return "cpu0";
+ if (pp) {
+ name =3D "cpu0";
+ goto node_put;
+ }
}
=20
pp =3D of_find_property(np, "cpu-supply", NULL);
- if (pp)
- return "cpu";
+ if (pp) {
+ name =3D "cpu";
+ goto node_put;
+ }
=20
dev_dbg(dev, "no regulator for cpu%d\n", cpu);
- return NULL;
+node_put:
+ of_node_put(np);
+ return name;
}
=20
static int allocate_resources(int cpu, struct device **cdev,
@@ -147,7 +160,6 @@ try_again:
static int cpufreq_init(struct cpufreq_policy *policy)
{
struct cpufreq_frequency_table *freq_table;
- struct device_node *np;
struct private_data *priv;
struct device *cpu_dev;
struct regulator *cpu_reg;
@@ -164,13 +176,6 @@ static int cpufreq_init(struct cpufreq_policy *polic=
y)
return ret;
}
=20
- np =3D of_node_get(cpu_dev->of_node);
- if (!np) {
- dev_err(cpu_dev, "failed to find cpu%d node\n", policy->cpu);
- ret =3D -ENOENT;
- goto out_put_reg_clk;
- }
-
/* Get OPP-sharing information from "operating-points-v2" bindings */
ret =3D dev_pm_opp_of_get_sharing_cpus(cpu_dev, policy->cpus);
if (ret) {
@@ -181,20 +186,20 @@ static int cpufreq_init(struct cpufreq_policy *poli=
cy)
if (ret =3D=3D -ENOENT)
opp_v1 =3D true;
else
- goto out_node_put;
+ goto out_put_reg_clk;
}
=20
/*
* OPP layer will be taking care of regulators now, but it needs to kno=
w
* the name of the regulator first.
*/
- name =3D find_supply_name(cpu_dev, np);
+ name =3D find_supply_name(cpu_dev);
if (name) {
ret =3D dev_pm_opp_set_regulator(cpu_dev, name);
if (ret) {
dev_err(cpu_dev, "Failed to set regulator for cpu%d: %d\n",
policy->cpu, ret);
- goto out_node_put;
+ goto out_put_reg_clk;
}
}
=20
@@ -244,7 +249,6 @@ static int cpufreq_init(struct cpufreq_policy *policy=
)
}
=20
priv->reg_name =3D name;
- of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance)=
;
=20
ret =3D dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
if (ret) {
@@ -286,8 +290,6 @@ static int cpufreq_init(struct cpufreq_policy *policy=
)
=20
policy->cpuinfo.transition_latency =3D transition_latency;
=20
- of_node_put(np);
-
return 0;
=20
out_free_cpufreq_table:
@@ -298,8 +300,6 @@ out_free_opp:
dev_pm_opp_of_cpumask_remove_table(policy->cpus);
if (name)
dev_pm_opp_put_regulator(cpu_dev);
-out_node_put:
- of_node_put(np);
out_put_reg_clk:
clk_put(cpu_clk);
if (!IS_ERR(cpu_reg))
--=20
2.27.0

Join cip-dev@lists.cip-project.org to automatically receive all group messages.