Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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@huawei.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20240808031552.3156-1-zhangzekun11@huawei.com

authored by

Zhang Zekun and committed by
Thomas Gleixner
76bee035 b77c6a73

+7 -17
+7 -17
drivers/irqchip/irq-mbigen.c
··· 222 222 struct mbigen_device *mgn_chip) 223 223 { 224 224 struct platform_device *child; 225 - struct device_node *np; 226 225 u32 num_pins; 227 - int ret = 0; 228 226 229 - for_each_child_of_node(pdev->dev.of_node, np) { 227 + for_each_child_of_node_scoped(pdev->dev.of_node, np) { 230 228 if (!of_property_read_bool(np, "interrupt-controller")) 231 229 continue; 232 230 233 231 child = of_platform_device_create(np, NULL, NULL); 234 - if (!child) { 235 - ret = -ENOMEM; 236 - break; 237 - } 232 + if (!child) 233 + return -ENOMEM; 238 234 239 235 if (of_property_read_u32(child->dev.of_node, "num-pins", 240 236 &num_pins) < 0) { 241 237 dev_err(&pdev->dev, "No num-pins property\n"); 242 - ret = -EINVAL; 243 - break; 238 + return -EINVAL; 244 239 } 245 240 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; 250 243 } 251 244 252 - if (ret) 253 - of_node_put(np); 254 - 255 - return ret; 245 + return 0; 256 246 } 257 247 258 248 #ifdef CONFIG_ACPI