Skip to content

Commit

Permalink
gpiolib: cosmetic improvements for error handling in gpiochip_add()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Anton Vorontsov authored and Grant Likely committed Jul 5, 2010
1 parent ac80a51 commit cedb188
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1101,14 +1101,20 @@ int gpiochip_add(struct gpio_chip *chip)

unlock:
spin_unlock_irqrestore(&gpio_lock, flags);
if (status == 0)
status = gpiochip_export(chip);

if (status)
goto fail;

status = gpiochip_export(chip);
if (status)
goto fail;

return 0;
fail:
/* failures here can mean systems won't boot... */
if (status)
pr_err("gpiochip_add: gpios %d..%d (%s) failed to register\n",
chip->base, chip->base + chip->ngpio - 1,
chip->label ? : "generic");
pr_err("gpiochip_add: gpios %d..%d (%s) failed to register\n",
chip->base, chip->base + chip->ngpio - 1,
chip->label ? : "generic");
return status;
}
EXPORT_SYMBOL_GPL(gpiochip_add);
Expand Down

0 comments on commit cedb188

Please sign in to comment.