From: Zhang Zekun Date: Wed, 21 Aug 2024 03:40:21 +0000 (+0800) Subject: pmdomain: qcom-cpr: Use helper function for_each_available_child_of_node() X-Git-Tag: v6.12-rc1~154^2~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f253f6d922da29d0d7091801cbc9b4166c3959fe;p=thirdparty%2Fkernel%2Flinux.git pmdomain: qcom-cpr: Use helper function for_each_available_child_of_node() for_each_available_child_of_node() can help to iterate through the device_node, and we don't need to use while loop. Besides, the purpose of the while loop is to find a device_node which fits the condition "child_req_np == ref_np", we can just read the property of "child_np" directly in for_each_available_child_of_node(). No functional change with such conversion. Signed-off-by: Zhang Zekun Link: https://lore.kernel.org/r/20240821034022.27394-2-zhangzekun11@huawei.com Signed-off-by: Ulf Hansson --- diff --git a/drivers/pmdomain/qcom/cpr.c b/drivers/pmdomain/qcom/cpr.c index c64e84a27cc7f..1834b3861232e 100644 --- a/drivers/pmdomain/qcom/cpr.c +++ b/drivers/pmdomain/qcom/cpr.c @@ -1054,14 +1054,14 @@ static unsigned long cpr_get_opp_hz_for_req(struct dev_pm_opp *ref, if (!ref_np) goto out_ref; - do { + for_each_available_child_of_node(desc_np, child_np) { of_node_put(child_req_np); - child_np = of_get_next_available_child(desc_np, child_np); child_req_np = of_parse_phandle(child_np, "required-opps", 0); - } while (child_np && child_req_np != ref_np); - - if (child_np && child_req_np == ref_np) - of_property_read_u64(child_np, "opp-hz", &rate); + if (child_req_np == ref_np) { + of_property_read_u64(child_np, "opp-hz", &rate); + break; + } + } of_node_put(child_req_np); of_node_put(child_np);