summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2017-07-28 07:44:18 -0700
committerLucas Stach <l.stach@pengutronix.de>2017-07-30 16:15:57 +0200
commit858b797e529e26c19bfa893fdb37ed67ff7a6006 (patch)
treeef9009e14667eb7672c3c8e883f1a61dfe258fee
parent3918ca48a7fb20488786dd9644c31e6cae3195bd (diff)
downloadbarebox-858b797e529e26c19bfa893fdb37ed67ff7a6006.tar.gz
gpiolib: Simplify code of gpio_request_one()
Looks like we can get rid of an 'if' and 'goto', so do it to simplify the code. Acked-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-rw-r--r--drivers/gpio/gpiolib.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index d081e02..67d771b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -119,6 +119,7 @@ void gpio_free(unsigned gpio)
int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
{
int err;
+ struct gpio_info *gi = gpio_to_desc(gpio);
/*
* Not all of the flags below are mulit-bit, but, for the sake
@@ -134,10 +135,7 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
if (err)
return err;
- if (active_low) {
- struct gpio_info *gi = gpio_to_desc(gpio);
- gi->active_low = true;
- }
+ gi->active_low = active_low;
if (dir_in)
err = gpio_direction_input(gpio);
@@ -147,12 +145,8 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
err = gpio_direction_output(gpio, init_high);
if (err)
- goto free_gpio;
-
- return 0;
+ gpio_free(gpio);
- free_gpio:
- gpio_free(gpio);
return err;
}
EXPORT_SYMBOL_GPL(gpio_request_one);