Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <julia.lawall@inria.fr>
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

authored by

Javier Carrasco and committed by
Viresh Kumar
b5e230aa 4cece764

+6 -13
+6 -13
drivers/cpufreq/tegra124-cpufreq.c
··· 52 52 53 53 static int tegra124_cpufreq_probe(struct platform_device *pdev) 54 54 { 55 + struct device_node *np __free(device_node) = of_cpu_device_node_get(0); 55 56 struct tegra124_cpufreq_priv *priv; 56 - struct device_node *np; 57 57 struct device *cpu_dev; 58 58 struct platform_device_info cpufreq_dt_devinfo = {}; 59 59 int ret; 60 + 61 + if (!np) 62 + return -ENODEV; 60 63 61 64 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 62 65 if (!priv) ··· 69 66 if (!cpu_dev) 70 67 return -ENODEV; 71 68 72 - np = of_cpu_device_node_get(0); 73 - if (!np) 74 - return -ENODEV; 75 - 76 69 priv->cpu_clk = of_clk_get_by_name(np, "cpu_g"); 77 - if (IS_ERR(priv->cpu_clk)) { 78 - ret = PTR_ERR(priv->cpu_clk); 79 - goto out_put_np; 80 - } 70 + if (IS_ERR(priv->cpu_clk)) 71 + return PTR_ERR(priv->cpu_clk); 81 72 82 73 priv->dfll_clk = of_clk_get_by_name(np, "dfll"); 83 74 if (IS_ERR(priv->dfll_clk)) { ··· 107 110 108 111 platform_set_drvdata(pdev, priv); 109 112 110 - of_node_put(np); 111 - 112 113 return 0; 113 114 114 115 out_put_pllp_clk: ··· 117 122 clk_put(priv->dfll_clk); 118 123 out_put_cpu_clk: 119 124 clk_put(priv->cpu_clk); 120 - out_put_np: 121 - of_node_put(np); 122 125 123 126 return ret; 124 127 }