Skip to content

Commit 76bee03

Browse files
Zhang ZekunKAGA-KOKO
authored andcommitted
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 <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent b77c6a7 commit 76bee03

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

drivers/irqchip/irq-mbigen.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -222,37 +222,27 @@ static int mbigen_of_create_domain(struct platform_device *pdev,
222222
struct mbigen_device *mgn_chip)
223223
{
224224
struct platform_device *child;
225-
struct device_node *np;
226225
u32 num_pins;
227-
int ret = 0;
228226

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

233231
child = of_platform_device_create(np, NULL, NULL);
234-
if (!child) {
235-
ret = -ENOMEM;
236-
break;
237-
}
232+
if (!child)
233+
return -ENOMEM;
238234

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

246-
if (!mbigen_create_device_domain(&child->dev, num_pins, mgn_chip)) {
247-
ret = -ENOMEM;
248-
break;
249-
}
241+
if (!mbigen_create_device_domain(&child->dev, num_pins, mgn_chip))
242+
return -ENOMEM;
250243
}
251244

252-
if (ret)
253-
of_node_put(np);
254-
255-
return ret;
245+
return 0;
256246
}
257247

258248
#ifdef CONFIG_ACPI

0 commit comments

Comments
 (0)