Skip to content

Commit 181c814

Browse files
Zhang Zekunstorulf
authored andcommitted
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: Zhang Zekun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent f253f6d commit 181c814

File tree

1 file changed

+12
-18
lines changed
  • drivers/pmdomain/qcom

1 file changed

+12
-18
lines changed

drivers/pmdomain/qcom/cpr.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,36 +1040,30 @@ static unsigned int cpr_get_fuse_corner(struct dev_pm_opp *opp)
10401040
static unsigned long cpr_get_opp_hz_for_req(struct dev_pm_opp *ref,
10411041
struct device *cpu_dev)
10421042
{
1043-
u64 rate = 0;
1044-
struct device_node *ref_np;
1045-
struct device_node *desc_np;
1046-
struct device_node *child_np = NULL;
1047-
struct device_node *child_req_np = NULL;
1043+
struct device_node *ref_np __free(device_node) = NULL;
1044+
struct device_node *desc_np __free(device_node) =
1045+
dev_pm_opp_of_get_opp_desc_node(cpu_dev);
10481046

1049-
desc_np = dev_pm_opp_of_get_opp_desc_node(cpu_dev);
10501047
if (!desc_np)
10511048
return 0;
10521049

10531050
ref_np = dev_pm_opp_get_of_node(ref);
10541051
if (!ref_np)
1055-
goto out_ref;
1052+
return 0;
1053+
1054+
for_each_available_child_of_node_scoped(desc_np, child_np) {
1055+
struct device_node *child_req_np __free(device_node) =
1056+
of_parse_phandle(child_np, "required-opps", 0);
10561057

1057-
for_each_available_child_of_node(desc_np, child_np) {
1058-
of_node_put(child_req_np);
1059-
child_req_np = of_parse_phandle(child_np, "required-opps", 0);
10601058
if (child_req_np == ref_np) {
1059+
u64 rate;
1060+
10611061
of_property_read_u64(child_np, "opp-hz", &rate);
1062-
break;
1062+
return (unsigned long) rate;
10631063
}
10641064
}
10651065

1066-
of_node_put(child_req_np);
1067-
of_node_put(child_np);
1068-
of_node_put(ref_np);
1069-
out_ref:
1070-
of_node_put(desc_np);
1071-
1072-
return (unsigned long) rate;
1066+
return 0;
10731067
}
10741068

10751069
static int cpr_corner_init(struct cpr_drv *drv)

0 commit comments

Comments
 (0)