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

pmdomain: ti-sci: Use scope based of_node_put() to simplify code.

Use scope based of_node_put() to simplify the code logic, and we don't
need to call of_node_put(). Besides, put of_parse_phandle_with_args() in
the while loop to make code more simple.

Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Message-ID: <20241024030442.119506-3-zhangzekun11@huawei.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Zhang Zekun and committed by
Ulf Hansson
88e98cd5 afc2331e

+6 -14
+6 -14
drivers/pmdomain/ti/ti_sci_pm_domains.c
··· 131 131 struct device *dev = &pdev->dev; 132 132 struct ti_sci_genpd_provider *pd_provider; 133 133 struct ti_sci_pm_domain *pd; 134 - struct device_node *np; 134 + struct device_node *np __free(device_node) = NULL; 135 135 struct of_phandle_args args; 136 - int ret; 137 136 u32 max_id = 0; 138 137 int index; 139 138 ··· 152 153 for_each_node_with_property(np, "power-domains") { 153 154 index = 0; 154 155 155 - while (1) { 156 - ret = of_parse_phandle_with_args(np, "power-domains", 157 - "#power-domain-cells", 158 - index, &args); 159 - if (ret) 160 - break; 156 + while (!of_parse_phandle_with_args(np, "power-domains", 157 + "#power-domain-cells", 158 + index, &args)) { 161 159 162 160 if (args.args_count >= 1 && args.np == dev->of_node) { 163 161 of_node_put(args.np); ··· 168 172 } 169 173 170 174 pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); 171 - if (!pd) { 172 - of_node_put(np); 175 + if (!pd) 173 176 return -ENOMEM; 174 - } 175 177 176 178 pd->pd.name = devm_kasprintf(dev, GFP_KERNEL, 177 179 "pd:%d", 178 180 args.args[0]); 179 - if (!pd->pd.name) { 180 - of_node_put(np); 181 + if (!pd->pd.name) 181 182 return -ENOMEM; 182 - } 183 183 184 184 pd->pd.power_off = ti_sci_pd_power_off; 185 185 pd->pd.power_on = ti_sci_pd_power_on;