]>
Commit | Line | Data |
---|---|---|
c15ed09d GKH |
1 | From e3beb0ac521d50d158a9d253373eae8421ac3998 Mon Sep 17 00:00:00 2001 |
2 | From: Lucas Stach <l.stach@pengutronix.de> | |
3 | Date: Fri, 16 May 2014 12:20:42 +0200 | |
4 | Subject: cpufreq: cpu0: drop wrong devm usage | |
5 | ||
6 | From: Lucas Stach <l.stach@pengutronix.de> | |
7 | ||
8 | commit e3beb0ac521d50d158a9d253373eae8421ac3998 upstream. | |
9 | ||
10 | This driver is using devres managed calls incorrectly, giving the cpu0 | |
11 | device as first parameter instead of the cpufreq platform device. | |
12 | This results in resources not being freed if the cpufreq platform device | |
13 | is unbound, for example if probing has to be deferred for a missing | |
14 | regulator. | |
15 | ||
16 | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> | |
17 | Acked-by: Viresh Kumar <viresh.kumar@linaro.org> | |
18 | Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | |
19 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
20 | ||
21 | --- | |
22 | drivers/cpufreq/cpufreq-cpu0.c | 16 +++++++++++----- | |
23 | 1 file changed, 11 insertions(+), 5 deletions(-) | |
24 | ||
25 | --- a/drivers/cpufreq/cpufreq-cpu0.c | |
26 | +++ b/drivers/cpufreq/cpufreq-cpu0.c | |
27 | @@ -131,7 +131,7 @@ static int cpu0_cpufreq_probe(struct pla | |
28 | return -ENOENT; | |
29 | } | |
30 | ||
31 | - cpu_reg = devm_regulator_get_optional(cpu_dev, "cpu0"); | |
32 | + cpu_reg = regulator_get_optional(cpu_dev, "cpu0"); | |
33 | if (IS_ERR(cpu_reg)) { | |
34 | /* | |
35 | * If cpu0 regulator supply node is present, but regulator is | |
36 | @@ -146,23 +146,23 @@ static int cpu0_cpufreq_probe(struct pla | |
37 | PTR_ERR(cpu_reg)); | |
38 | } | |
39 | ||
40 | - cpu_clk = devm_clk_get(cpu_dev, NULL); | |
41 | + cpu_clk = clk_get(cpu_dev, NULL); | |
42 | if (IS_ERR(cpu_clk)) { | |
43 | ret = PTR_ERR(cpu_clk); | |
44 | pr_err("failed to get cpu0 clock: %d\n", ret); | |
45 | - goto out_put_node; | |
46 | + goto out_put_reg; | |
47 | } | |
48 | ||
49 | ret = of_init_opp_table(cpu_dev); | |
50 | if (ret) { | |
51 | pr_err("failed to init OPP table: %d\n", ret); | |
52 | - goto out_put_node; | |
53 | + goto out_put_clk; | |
54 | } | |
55 | ||
56 | ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table); | |
57 | if (ret) { | |
58 | pr_err("failed to init cpufreq table: %d\n", ret); | |
59 | - goto out_put_node; | |
60 | + goto out_put_clk; | |
61 | } | |
62 | ||
63 | of_property_read_u32(np, "voltage-tolerance", &voltage_tolerance); | |
64 | @@ -217,6 +217,12 @@ static int cpu0_cpufreq_probe(struct pla | |
65 | ||
66 | out_free_table: | |
67 | dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); | |
68 | +out_put_clk: | |
69 | + if (!IS_ERR(cpu_clk)) | |
70 | + clk_put(cpu_clk); | |
71 | +out_put_reg: | |
72 | + if (!IS_ERR(cpu_reg)) | |
73 | + regulator_put(cpu_reg); | |
74 | out_put_node: | |
75 | of_node_put(np); | |
76 | return ret; |