Skip to content

Commit b5e230a

Browse files
javiercarrascocruzvireshk
authored andcommitted
cpupfreq: tegra124: eliminate uses of of_node_put()
Make use of the __free() cleanup handler to automatically free nodes when they get out of scope. Only the probe function is affected by this modification. Given that this mechanism requires the node to be initialized, its initialization and the value check have been moved to the top of the function. After removing uses of of_node_put(), the jump to out_put_np is no longer necessary. Suggested-by: Julia Lawall <[email protected]> Signed-off-by: Javier Carrasco <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent 4cece76 commit b5e230a

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

drivers/cpufreq/tegra124-cpufreq.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@ static int tegra124_cpu_switch_to_dfll(struct tegra124_cpufreq_priv *priv)
5252

5353
static int tegra124_cpufreq_probe(struct platform_device *pdev)
5454
{
55+
struct device_node *np __free(device_node) = of_cpu_device_node_get(0);
5556
struct tegra124_cpufreq_priv *priv;
56-
struct device_node *np;
5757
struct device *cpu_dev;
5858
struct platform_device_info cpufreq_dt_devinfo = {};
5959
int ret;
6060

61+
if (!np)
62+
return -ENODEV;
63+
6164
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
6265
if (!priv)
6366
return -ENOMEM;
@@ -66,15 +69,9 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)
6669
if (!cpu_dev)
6770
return -ENODEV;
6871

69-
np = of_cpu_device_node_get(0);
70-
if (!np)
71-
return -ENODEV;
72-
7372
priv->cpu_clk = of_clk_get_by_name(np, "cpu_g");
74-
if (IS_ERR(priv->cpu_clk)) {
75-
ret = PTR_ERR(priv->cpu_clk);
76-
goto out_put_np;
77-
}
73+
if (IS_ERR(priv->cpu_clk))
74+
return PTR_ERR(priv->cpu_clk);
7875

7976
priv->dfll_clk = of_clk_get_by_name(np, "dfll");
8077
if (IS_ERR(priv->dfll_clk)) {
@@ -110,8 +107,6 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)
110107

111108
platform_set_drvdata(pdev, priv);
112109

113-
of_node_put(np);
114-
115110
return 0;
116111

117112
out_put_pllp_clk:
@@ -122,8 +117,6 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev)
122117
clk_put(priv->dfll_clk);
123118
out_put_cpu_clk:
124119
clk_put(priv->cpu_clk);
125-
out_put_np:
126-
of_node_put(np);
127120

128121
return ret;
129122
}

0 commit comments

Comments
 (0)