diff mbox series

firmware: arm_scmi: Simplify with scoped for each OF child loop

Message ID 20240816151407.155034-1-krzysztof.kozlowski@linaro.org (mailing list archive)
State New, archived
Headers show
Series firmware: arm_scmi: Simplify with scoped for each OF child loop | expand

Commit Message

Krzysztof Kozlowski Aug. 16, 2024, 3:14 p.m. UTC
Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/firmware/arm_scmi/driver.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Sudeep Holla Aug. 20, 2024, 2:38 p.m. UTC | #1
On Fri, 16 Aug 2024 17:14:07 +0200, Krzysztof Kozlowski wrote:
> Use scoped for_each_child_of_node_scoped() when iterating over device
> nodes to make code a bit simpler.
>
>

Applied to sudeep.holla/linux (for-next/scmi/updates), thanks!

[1/1] firmware: arm_scmi: Simplify with scoped for each OF child loop
      https://git.kernel.org/sudeep.holla/c/a8bd37e64560
--
Regards,
Sudeep
diff mbox series

Patch

diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 33676b6ece95..2b9c38f55989 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2726,14 +2726,14 @@  scmi_txrx_setup(struct scmi_info *info, struct device_node *of_node,
 static int scmi_channels_setup(struct scmi_info *info)
 {
 	int ret;
-	struct device_node *child, *top_np = info->dev->of_node;
+	struct device_node *top_np = info->dev->of_node;
 
 	/* Initialize a common generic channel at first */
 	ret = scmi_txrx_setup(info, top_np, SCMI_PROTOCOL_BASE);
 	if (ret)
 		return ret;
 
-	for_each_available_child_of_node(top_np, child) {
+	for_each_available_child_of_node_scoped(top_np, child) {
 		u32 prot_id;
 
 		if (of_property_read_u32(child, "reg", &prot_id))
@@ -2744,10 +2744,8 @@  static int scmi_channels_setup(struct scmi_info *info)
 				"Out of range protocol %d\n", prot_id);
 
 		ret = scmi_txrx_setup(info, child, prot_id);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;