summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorAnton Vorontsov2010-06-08 15:48:15 +0200
committerGrant Likely2010-07-06 00:14:29 +0200
commitcedb1881ba32f7e9cd49250bd79debccbe52b094 (patch)
treeeefcda635b7b5f683a473c965f8cbeeaff38d6b5 /drivers/gpio/gpiolib.c
parentof/device: populate platform_device (of_device) resource table on allocation (diff)
downloadkernel-qcow2-linux-cedb1881ba32f7e9cd49250bd79debccbe52b094.tar.gz
kernel-qcow2-linux-cedb1881ba32f7e9cd49250bd79debccbe52b094.tar.xz
kernel-qcow2-linux-cedb1881ba32f7e9cd49250bd79debccbe52b094.zip
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.c18
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)
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);