Commit 181c8148 authored by Zhang Zekun's avatar Zhang Zekun Committed by Ulf Hansson

pmdomain: qcom-cpr: 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(). This will simplify the code a lot.
Signed-off-by: default avatarZhang Zekun <zhangzekun11@huawei.com>
Link: https://lore.kernel.org/r/20240821034022.27394-3-zhangzekun11@huawei.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent f253f6d9
...@@ -1040,36 +1040,30 @@ static unsigned int cpr_get_fuse_corner(struct dev_pm_opp *opp) ...@@ -1040,36 +1040,30 @@ static unsigned int cpr_get_fuse_corner(struct dev_pm_opp *opp)
static unsigned long cpr_get_opp_hz_for_req(struct dev_pm_opp *ref, static unsigned long cpr_get_opp_hz_for_req(struct dev_pm_opp *ref,
struct device *cpu_dev) struct device *cpu_dev)
{ {
u64 rate = 0; struct device_node *ref_np __free(device_node) = NULL;
struct device_node *ref_np; struct device_node *desc_np __free(device_node) =
struct device_node *desc_np; dev_pm_opp_of_get_opp_desc_node(cpu_dev);
struct device_node *child_np = NULL;
struct device_node *child_req_np = NULL;
desc_np = dev_pm_opp_of_get_opp_desc_node(cpu_dev);
if (!desc_np) if (!desc_np)
return 0; return 0;
ref_np = dev_pm_opp_get_of_node(ref); ref_np = dev_pm_opp_get_of_node(ref);
if (!ref_np) if (!ref_np)
goto out_ref; return 0;
for_each_available_child_of_node_scoped(desc_np, child_np) {
struct device_node *child_req_np __free(device_node) =
of_parse_phandle(child_np, "required-opps", 0);
for_each_available_child_of_node(desc_np, child_np) {
of_node_put(child_req_np);
child_req_np = of_parse_phandle(child_np, "required-opps", 0);
if (child_req_np == ref_np) { if (child_req_np == ref_np) {
u64 rate;
of_property_read_u64(child_np, "opp-hz", &rate); of_property_read_u64(child_np, "opp-hz", &rate);
break; return (unsigned long) rate;
} }
} }
of_node_put(child_req_np); return 0;
of_node_put(child_np);
of_node_put(ref_np);
out_ref:
of_node_put(desc_np);
return (unsigned long) rate;
} }
static int cpr_corner_init(struct cpr_drv *drv) static int cpr_corner_init(struct cpr_drv *drv)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment