[tip: irq/core] irqchip/mbigen: Simplify code logic with for_each_child_of_node_scoped()

From: tip-bot2 for Zhang Zekun
Date: Thu Aug 08 2024 - 11:22:57 EST


The following commit has been merged into the irq/core branch of tip:

Commit-ID: 76bee035c6add05841addc3f31b41cd726b912c4
Gitweb: https://git.kernel.org/tip/76bee035c6add05841addc3f31b41cd726b912c4
Author: Zhang Zekun <zhangzekun11@xxxxxxxxxx>
AuthorDate: Thu, 08 Aug 2024 11:15:52 +08:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CommitterDate: Thu, 08 Aug 2024 17:15:01 +02:00

irqchip/mbigen: Simplify code logic with for_each_child_of_node_scoped()

for_each_child_of_node_scoped() handles the device_node automaticlly, so
switching over to it removes the device node cleanups and allows to return
directly from the loop.

Signed-off-by: Zhang Zekun <zhangzekun11@xxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Link: https://lore.kernel.org/all/20240808031552.3156-1-zhangzekun11@xxxxxxxxxx

---
drivers/irqchip/irq-mbigen.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index 093fd42..1291983 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -222,37 +222,27 @@ static int mbigen_of_create_domain(struct platform_device *pdev,
struct mbigen_device *mgn_chip)
{
struct platform_device *child;
- struct device_node *np;
u32 num_pins;
- int ret = 0;

- for_each_child_of_node(pdev->dev.of_node, np) {
+ for_each_child_of_node_scoped(pdev->dev.of_node, np) {
if (!of_property_read_bool(np, "interrupt-controller"))
continue;

child = of_platform_device_create(np, NULL, NULL);
- if (!child) {
- ret = -ENOMEM;
- break;
- }
+ if (!child)
+ return -ENOMEM;

if (of_property_read_u32(child->dev.of_node, "num-pins",
&num_pins) < 0) {
dev_err(&pdev->dev, "No num-pins property\n");
- ret = -EINVAL;
- break;
+ return -EINVAL;
}

- if (!mbigen_create_device_domain(&child->dev, num_pins, mgn_chip)) {
- ret = -ENOMEM;
- break;
- }
+ if (!mbigen_create_device_domain(&child->dev, num_pins, mgn_chip))
+ return -ENOMEM;
}

- if (ret)
- of_node_put(np);
-
- return ret;
+ return 0;
}

#ifdef CONFIG_ACPI