[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240928-gpio_device_for_each_child_node_scoped-v1-3-c20eff315f4f@gmail.com>
Date: Sat, 28 Sep 2024 21:47:37 +0200
From: Javier Carrasco <javier.carrasco.cruz@...il.com>
To: Hoan Tran <hoan@...amperecomputing.com>,
Serge Semin <fancer.lancer@...il.com>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-acpi@...r.kernel.org,
Javier Carrasco <javier.carrasco.cruz@...il.com>
Subject: [PATCH 3/3] gpio: acpi: switch to
device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for a call to fwnode_handle_put() in the error path.
This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@...il.com>
---
drivers/gpio/gpiolib-acpi.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 78ecd56123a3..1f9fe50bba00 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -1315,9 +1315,8 @@ acpi_gpiochip_parse_own_gpio(struct acpi_gpio_chip *achip,
static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip)
{
struct gpio_chip *chip = achip->chip;
- struct fwnode_handle *fwnode;
- device_for_each_child_node(chip->parent, fwnode) {
+ device_for_each_child_node_scoped(chip->parent, fwnode) {
unsigned long lflags;
enum gpiod_flags dflags;
struct gpio_desc *desc;
@@ -1335,7 +1334,6 @@ static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip)
ret = gpiod_hog(desc, name, lflags, dflags);
if (ret) {
dev_err(chip->parent, "Failed to hog GPIO\n");
- fwnode_handle_put(fwnode);
return;
}
}
--
2.43.0
Powered by blists - more mailing lists