diff options
author | Zhang Zekun <zhangzekun11@huawei.com> | 2024-08-21 05:40:22 +0200 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2024-09-13 11:56:33 +0200 |
commit | 181c8148556a2a7dd3047ea687873937b1be4f00 (patch) | |
tree | c09e4c133fdb8b6b7c90385d1670f424a5c98216 /drivers/pmdomain | |
parent | pmdomain: qcom-cpr: Use helper function for_each_available_child_of_node() (diff) | |
download | linux-181c8148556a2a7dd3047ea687873937b1be4f00.tar.xz linux-181c8148556a2a7dd3047ea687873937b1be4f00.zip |
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 <zhangzekun11@huawei.com>
Link: https://lore.kernel.org/r/20240821034022.27394-3-zhangzekun11@huawei.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/pmdomain')
-rw-r--r-- | drivers/pmdomain/qcom/cpr.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/drivers/pmdomain/qcom/cpr.c b/drivers/pmdomain/qcom/cpr.c index 1834b3861232..37b318bf505a 100644 --- a/drivers/pmdomain/qcom/cpr.c +++ b/drivers/pmdomain/qcom/cpr.c @@ -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, struct device *cpu_dev) { - u64 rate = 0; - struct device_node *ref_np; - struct device_node *desc_np; - struct device_node *child_np = NULL; - struct device_node *child_req_np = NULL; + struct device_node *ref_np __free(device_node) = NULL; + struct device_node *desc_np __free(device_node) = + dev_pm_opp_of_get_opp_desc_node(cpu_dev); - desc_np = dev_pm_opp_of_get_opp_desc_node(cpu_dev); if (!desc_np) return 0; ref_np = dev_pm_opp_get_of_node(ref); 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) { + u64 rate; + of_property_read_u64(child_np, "opp-hz", &rate); - break; + return (unsigned long) rate; } } - of_node_put(child_req_np); - of_node_put(child_np); - of_node_put(ref_np); -out_ref: - of_node_put(desc_np); - - return (unsigned long) rate; + return 0; } static int cpr_corner_init(struct cpr_drv *drv) |