Skip to content

Commit cedb188

Browse files
Anton Vorontsovglikely
authored andcommitted
gpiolib: cosmetic improvements for error handling in gpiochip_add()
Hopefully it makes the code look nicer and makes it easier to extend this function. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Grant Likely <grant.likely@secretlab.ca> CC: devicetree-discuss@lists.ozlabs.org CC: linux-kernel@vger.kernel.org
1 parent ac80a51 commit cedb188

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎drivers/gpio/gpiolib.c‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,14 +1101,20 @@ int gpiochip_add(struct gpio_chip *chip)
11011101

11021102
unlock:
11031103
spin_unlock_irqrestore(&gpio_lock, flags);
1104-
if (status == 0)
1105-
status = gpiochip_export(chip);
1104+
1105+
if (status)
1106+
goto fail;
1107+
1108+
status = gpiochip_export(chip);
1109+
if (status)
1110+
goto fail;
1111+
1112+
return 0;
11061113
fail:
11071114
/* failures here can mean systems won't boot... */
1108-
if (status)
1109-
pr_err("gpiochip_add: gpios %d..%d (%s) failed to register\n",
1110-
chip->base, chip->base + chip->ngpio - 1,
1111-
chip->label ? : "generic");
1115+
pr_err("gpiochip_add: gpios %d..%d (%s) failed to register\n",
1116+
chip->base, chip->base + chip->ngpio - 1,
1117+
chip->label ? : "generic");
11121118
return status;
11131119
}
11141120
EXPORT_SYMBOL_GPL(gpiochip_add);

0 commit comments

Comments
 (0)