Skip to content

Commit 12b0e30

Browse files
javiercarrascocruzandy-shev
authored andcommitted
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 <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]>
1 parent 9852d85 commit 12b0e30

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/gpio/gpiolib-acpi.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,9 +1315,8 @@ acpi_gpiochip_parse_own_gpio(struct acpi_gpio_chip *achip,
13151315
static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip)
13161316
{
13171317
struct gpio_chip *chip = achip->chip;
1318-
struct fwnode_handle *fwnode;
13191318

1320-
device_for_each_child_node(chip->parent, fwnode) {
1319+
device_for_each_child_node_scoped(chip->parent, fwnode) {
13211320
unsigned long lflags;
13221321
enum gpiod_flags dflags;
13231322
struct gpio_desc *desc;
@@ -1335,7 +1334,6 @@ static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip)
13351334
ret = gpiod_hog(desc, name, lflags, dflags);
13361335
if (ret) {
13371336
dev_err(chip->parent, "Failed to hog GPIO\n");
1338-
fwnode_handle_put(fwnode);
13391337
return;
13401338
}
13411339
}

0 commit comments

Comments
 (0)