diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2010-06-08 09:48:15 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-07-05 18:14:29 -0400 |
commit | cedb1881ba32f7e9cd49250bd79debccbe52b094 (patch) | |
tree | eefcda635b7b5f683a473c965f8cbeeaff38d6b5 /drivers/gpio/gpiolib.c | |
parent | ac80a51e2ce5c431de9997085f33cb6093218b1f (diff) |
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
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 3ca36542e338..713ca0e37f23 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -1101,14 +1101,20 @@ int gpiochip_add(struct gpio_chip *chip) | |||
1101 | 1101 | ||
1102 | unlock: | 1102 | unlock: |
1103 | spin_unlock_irqrestore(&gpio_lock, flags); | 1103 | spin_unlock_irqrestore(&gpio_lock, flags); |
1104 | if (status == 0) | 1104 | |
1105 | status = gpiochip_export(chip); | 1105 | if (status) |
1106 | goto fail; | ||
1107 | |||
1108 | status = gpiochip_export(chip); | ||
1109 | if (status) | ||
1110 | goto fail; | ||
1111 | |||
1112 | return 0; | ||
1106 | fail: | 1113 | fail: |
1107 | /* failures here can mean systems won't boot... */ | 1114 | /* failures here can mean systems won't boot... */ |
1108 | if (status) | 1115 | pr_err("gpiochip_add: gpios %d..%d (%s) failed to register\n", |
1109 | pr_err("gpiochip_add: gpios %d..%d (%s) failed to register\n", | 1116 | chip->base, chip->base + chip->ngpio - 1, |
1110 | chip->base, chip->base + chip->ngpio - 1, | 1117 | chip->label ? : "generic"); |
1111 | chip->label ? : "generic"); | ||
1112 | return status; | 1118 | return status; |
1113 | } | 1119 | } |
1114 | EXPORT_SYMBOL_GPL(gpiochip_add); | 1120 | EXPORT_SYMBOL_GPL(gpiochip_add); |