irqchip/mbigen: Simplify code logic with for_each_child_of_node_scoped()
PATCH 1/1 irqchip/mbigen: Simplify code logic with for_each_child_of_node_scoped()
for_each_child_of_node_scoped() can put the device_node automaticlly. So, using it to make the code logic more simple and remove the device_node clean up code.
Signed-off-by Zhang Zekun <[email protected]>
--- drivers/irqchip/irq-mbigen.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-)
drivers/irqchip/irq-mbigen.c +7 -17
@@ -234,37 +234,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
Signature · 1 line
2.17.1
The following commit has been merged into the irq/core branch of tip:
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 <[email protected]> AuthorDate: Thu, 08 Aug 2024 11:15:52 +08:00 Committer: Thomas Gleixner <[email protected]> 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 <[email protected]>
Signed-off-by Thomas Gleixner <[email protected]>
--- drivers/irqchip/irq-mbigen.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-)
drivers/irqchip/irq-mbigen.c +7 -17
@@ -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