GPIO: Check for "gpio_is_valid" first
Subsystems (3)
PATCH 2/2 GPIO: Remove unneeded "gpio_is_valid" calls
In reply to Alexander Shiyan--- drivers/mci/atmel_mci.c | 3 +-- drivers/w1/masters/w1-gpio.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/mci/atmel_mci.c +1 -2
@@ -608,8 +608,7 @@ static int atmci_probe(struct device_d *hw_dev)return 0 ; err_gpio_cd_request: -if (gpio_is_valid (pd->detect_pin)) -gpio_free (pd->detect_pin); +gpio_free (pd->detect_pin);return ret; }
drivers/w1/masters/w1-gpio.c +2 -4
@@ -88,14 +88,12 @@ static int __init w1_gpio_probe(struct device_d *dev)if (pdata->enable_external_pullup) pdata->enable_external_pullup (1 ); -if (gpio_is_valid (pdata->ext_pullup_enable_pin)) -gpio_set_value (pdata->ext_pullup_enable_pin,1 ); +gpio_set_value (pdata->ext_pullup_enable_pin,1 );return 0 ; free_gpio_ext_pu: -if (gpio_is_valid (pdata->ext_pullup_enable_pin)) -gpio_free (pdata->ext_pullup_enable_pin); +gpio_free (pdata->ext_pullup_enable_pin); free_gpio:gpio_free (pdata->pin); free_master:
Signature · 7 lines
1.8.1.5 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/2 GPIO: Check for "gpio_is_valid" first
--- drivers/gpio/gpiolib.c | 181 ++++++++++++++++++++++++++----------------------- 1 file changed, 95 insertions(+), 86 deletions(-)
drivers/gpio/gpiolib.c +95 -86
@@ -34,117 +34,126 @@ static int gpio_ensure_requested(struct gpio_info *gi, int gpio)int gpio_request (unsigned gpio,const char *label) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -EINVAL ; -if (gi->requested) -return -EBUSY ; -if (chip->ops->request) { - ret = chip->ops->request (chip, gpio - chip->base); -if (ret) -return ret; - } +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -EINVAL ; +if (gi->requested) +return -EBUSY ; +if (chip->ops->request) { + ret = chip->ops->request (chip, gpio - chip->base); +if (ret) +return ret; + } - gi->requested = true; - gi->label =xstrdup (label); + gi->requested = true; + gi->label =xstrdup (label); -return 0 ; +return 0 ; + } + +return -EINVAL ; }void gpio_free (unsigned gpio) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; - -if (!gpio_is_valid (gpio)) -return ; -if (!chip) -return ; -if (!gi->requested) -return ; -if (chip->ops->free) - chip->ops->free (chip, gpio - chip->base); - - gi->requested = false; -free (gi->label); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; + +if (!chip) +return ; +if (!gi->requested) +return ; +if (chip->ops->free) + chip->ops->free (chip, gpio - chip->base); + + gi->requested = false; +free (gi->label); + } }void gpio_set_value (unsigned gpio,int value) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; - -if (!gpio_is_valid (gpio)) -return ; -if (!chip) -return ; -if (gpio_ensure_requested (gi, gpio)) -return ; -if (!chip->ops->set) -return ; - chip->ops->set (chip, gpio - chip->base, value); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; + +if (!chip) +return ; +if (gpio_ensure_requested (gi, gpio)) +return ; +if (!chip->ops->set) +return ; + chip->ops->set (chip, gpio - chip->base, value); + } }EXPORT_SYMBOL (gpio_set_value);int gpio_get_value (unsigned gpio) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -ENODEV ; - ret =gpio_ensure_requested (gi, gpio); -if (ret) -return ret; -if (!chip->ops->get) -return -ENOSYS ; -return chip->ops->get (chip, gpio - chip->base); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -ENODEV ; + ret =gpio_ensure_requested (gi, gpio); +if (ret) +return ret; +if (!chip->ops->get) +return -ENOSYS ; +return chip->ops->get (chip, gpio - chip->base); + } + +return -EINVAL ; }EXPORT_SYMBOL (gpio_get_value);int gpio_direction_output (unsigned gpio,int value) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -ENODEV ; - ret =gpio_ensure_requested (gi, gpio); -if (ret) -return ret; -if (!chip->ops->direction_output) -return -ENOSYS ; -return chip->ops->direction_output (chip, gpio - chip->base, value); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -ENODEV ; + ret =gpio_ensure_requested (gi, gpio); +if (ret) +return ret; +if (!chip->ops->direction_output) +return -ENOSYS ; +return chip->ops->direction_output (chip, gpio - chip->base, + value); + } + +return -EINVAL ; }EXPORT_SYMBOL (gpio_direction_output);int gpio_direction_input (unsigned gpio) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -ENODEV ; - ret =gpio_ensure_requested (gi, gpio); -if (ret) -return ret; -if (!chip->ops->direction_input) -return -ENOSYS ; -return chip->ops->direction_input (chip, gpio - chip->base); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -ENODEV ; + ret =gpio_ensure_requested (gi, gpio); +if (ret) +return ret; +if (!chip->ops->direction_input) +return -ENOSYS ; +return chip->ops->direction_input (chip, gpio - chip->base); + } + +return -EINVAL ; }EXPORT_SYMBOL (gpio_direction_input);
Signature · 7 lines
1.8.1.5 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
no the current code is more clean
just move
gi = &gpio_desc[gpio];
chip = gi->chip
after the current check;
Quoted 231 lines · Alexander Shiyan
Signed-off-by Alexander Shiyan <[email protected]>--- drivers/gpio/gpiolib.c | 181 ++++++++++++++++++++++++++----------------------- 1 file changed, 95 insertions(+), 86 deletions(-)drivers/gpio/gpiolib.c +95
-86@@ -34,117 +34,126 @@ static int gpio_ensure_requested(struct gpio_info *gi, int gpio)int gpio_request (unsigned gpio,const char *label) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -EINVAL ; -if (gi->requested) -return -EBUSY ; -if (chip->ops->request) { - ret = chip->ops->request (chip, gpio - chip->base); -if (ret) -return ret; - } +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -EINVAL ; +if (gi->requested) +return -EBUSY ; +if (chip->ops->request) { + ret = chip->ops->request (chip, gpio - chip->base); +if (ret) +return ret; + } - gi->requested = true; - gi->label =xstrdup (label); + gi->requested = true; + gi->label =xstrdup (label); -return 0 ; +return 0 ; + } + +return -EINVAL ; }void gpio_free (unsigned gpio) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; - -if (!gpio_is_valid (gpio)) -return ; -if (!chip) -return ; -if (!gi->requested) -return ; -if (chip->ops->free) - chip->ops->free (chip, gpio - chip->base); - - gi->requested = false; -free (gi->label); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; + +if (!chip) +return ; +if (!gi->requested) +return ; +if (chip->ops->free) + chip->ops->free (chip, gpio - chip->base); + + gi->requested = false; +free (gi->label); + } }void gpio_set_value (unsigned gpio,int value) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; - -if (!gpio_is_valid (gpio)) -return ; -if (!chip) -return ; -if (gpio_ensure_requested (gi, gpio)) -return ; -if (!chip->ops->set) -return ; - chip->ops->set (chip, gpio - chip->base, value); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; + +if (!chip) +return ; +if (gpio_ensure_requested (gi, gpio)) +return ; +if (!chip->ops->set) +return ; + chip->ops->set (chip, gpio - chip->base, value); + } }EXPORT_SYMBOL (gpio_set_value);int gpio_get_value (unsigned gpio) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -ENODEV ; - ret =gpio_ensure_requested (gi, gpio); -if (ret) -return ret; -if (!chip->ops->get) -return -ENOSYS ; -return chip->ops->get (chip, gpio - chip->base); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -ENODEV ; + ret =gpio_ensure_requested (gi, gpio); +if (ret) +return ret; +if (!chip->ops->get) +return -ENOSYS ; +return chip->ops->get (chip, gpio - chip->base); + } + +return -EINVAL ; }EXPORT_SYMBOL (gpio_get_value);int gpio_direction_output (unsigned gpio,int value) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -ENODEV ; - ret =gpio_ensure_requested (gi, gpio); -if (ret) -return ret; -if (!chip->ops->direction_output) -return -ENOSYS ; -return chip->ops->direction_output (chip, gpio - chip->base, value); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -ENODEV ; + ret =gpio_ensure_requested (gi, gpio); +if (ret) +return ret; +if (!chip->ops->direction_output) +return -ENOSYS ; +return chip->ops->direction_output (chip, gpio - chip->base, + value); + } + +return -EINVAL ; }EXPORT_SYMBOL (gpio_direction_output);int gpio_direction_input (unsigned gpio) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -ENODEV ; - ret =gpio_ensure_requested (gi, gpio); -if (ret) -return ret; -if (!chip->ops->direction_input) -return -ENOSYS ; -return chip->ops->direction_input (chip, gpio - chip->base); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -ENODEV ; + ret =gpio_ensure_requested (gi, gpio); +if (ret) +return ret; +if (!chip->ops->direction_input) +return -ENOSYS ; +return chip->ops->direction_input (chip, gpio - chip->base); + } + +return -EINVAL ; }EXPORT_SYMBOL (gpio_direction_input);Signature · 7 lines
1.8.1.5 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
HI,
do as in linux
introduce
static struct gpio_desc *gpio_to_desc(unsigned gpio)
and we need to check the gpio is valid before calling _free/ser/get etc..
Quoted 231 lines · Alexander Shiyan
Signed-off-by Alexander Shiyan <[email protected]>--- drivers/gpio/gpiolib.c | 181 ++++++++++++++++++++++++++----------------------- 1 file changed, 95 insertions(+), 86 deletions(-)drivers/gpio/gpiolib.c +95
-86@@ -34,117 +34,126 @@ static int gpio_ensure_requested(struct gpio_info *gi, int gpio)int gpio_request (unsigned gpio,const char *label) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -EINVAL ; -if (gi->requested) -return -EBUSY ; -if (chip->ops->request) { - ret = chip->ops->request (chip, gpio - chip->base); -if (ret) -return ret; - } +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -EINVAL ; +if (gi->requested) +return -EBUSY ; +if (chip->ops->request) { + ret = chip->ops->request (chip, gpio - chip->base); +if (ret) +return ret; + } - gi->requested = true; - gi->label =xstrdup (label); + gi->requested = true; + gi->label =xstrdup (label); -return 0 ; +return 0 ; + } + +return -EINVAL ; }void gpio_free (unsigned gpio) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; - -if (!gpio_is_valid (gpio)) -return ; -if (!chip) -return ; -if (!gi->requested) -return ; -if (chip->ops->free) - chip->ops->free (chip, gpio - chip->base); - - gi->requested = false; -free (gi->label); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; + +if (!chip) +return ; +if (!gi->requested) +return ; +if (chip->ops->free) + chip->ops->free (chip, gpio - chip->base); + + gi->requested = false; +free (gi->label); + } }void gpio_set_value (unsigned gpio,int value) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; - -if (!gpio_is_valid (gpio)) -return ; -if (!chip) -return ; -if (gpio_ensure_requested (gi, gpio)) -return ; -if (!chip->ops->set) -return ; - chip->ops->set (chip, gpio - chip->base, value); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; + +if (!chip) +return ; +if (gpio_ensure_requested (gi, gpio)) +return ; +if (!chip->ops->set) +return ; + chip->ops->set (chip, gpio - chip->base, value); + } }EXPORT_SYMBOL (gpio_set_value);int gpio_get_value (unsigned gpio) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -ENODEV ; - ret =gpio_ensure_requested (gi, gpio); -if (ret) -return ret; -if (!chip->ops->get) -return -ENOSYS ; -return chip->ops->get (chip, gpio - chip->base); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -ENODEV ; + ret =gpio_ensure_requested (gi, gpio); +if (ret) +return ret; +if (!chip->ops->get) +return -ENOSYS ; +return chip->ops->get (chip, gpio - chip->base); + } + +return -EINVAL ; }EXPORT_SYMBOL (gpio_get_value);int gpio_direction_output (unsigned gpio,int value) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -ENODEV ; - ret =gpio_ensure_requested (gi, gpio); -if (ret) -return ret; -if (!chip->ops->direction_output) -return -ENOSYS ; -return chip->ops->direction_output (chip, gpio - chip->base, value); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -ENODEV ; + ret =gpio_ensure_requested (gi, gpio); +if (ret) +return ret; +if (!chip->ops->direction_output) +return -ENOSYS ; +return chip->ops->direction_output (chip, gpio - chip->base, + value); + } + +return -EINVAL ; }EXPORT_SYMBOL (gpio_direction_output);int gpio_direction_input (unsigned gpio) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -ENODEV ; - ret =gpio_ensure_requested (gi, gpio); -if (ret) -return ret; -if (!chip->ops->direction_input) -return -ENOSYS ; -return chip->ops->direction_input (chip, gpio - chip->base); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -ENODEV ; + ret =gpio_ensure_requested (gi, gpio); +if (ret) +return ret; +if (!chip->ops->direction_input) +return -ENOSYS ; +return chip->ops->direction_input (chip, gpio - chip->base); + } + +return -EINVAL ; }EXPORT_SYMBOL (gpio_direction_input);Signature · 7 lines
1.8.1.5 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 10 lines
HI,
do as in linux
introduce
static struct
gpio_desc*gpio_to_desc(unsigned gpio)and we need to check the gpio is valid before calling _free/ser/get etc..
Indeed.
Quoted 213 lines
Quoted 213 lines
Signed-off-by Alexander Shiyan <[email protected]>--- drivers/gpio/gpiolib.c | 181 ++++++++++++++++++++++++++----------------------- 1 file changed, 95 insertions(+), 86 deletions(-)drivers/gpio/gpiolib.c +89
-86@@ -34,117 +34,126 @@ static int gpio_ensure_requested(struct gpio_info *gi, int gpio)int gpio_request (unsigned gpio,const char *label) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -EINVAL ; -if (gi->requested) -return -EBUSY ; -if (chip->ops->request) { - ret = chip->ops->request (chip, gpio - chip->base); -if (ret) -return ret; - } +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -EINVAL ; +if (gi->requested) +return -EBUSY ; +if (chip->ops->request) { + ret = chip->ops->request (chip, gpio - chip->base); +if (ret) +return ret; + } - gi->requested = true; - gi->label =xstrdup (label); + gi->requested = true; + gi->label =xstrdup (label); -return 0 ; +return 0 ; + } + +return -EINVAL ; }void gpio_free (unsigned gpio) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; - -if (!gpio_is_valid (gpio)) -return ; -if (!chip) -return ; -if (!gi->requested) -return ; -if (chip->ops->free) - chip->ops->free (chip, gpio - chip->base); - - gi->requested = false; -free (gi->label); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; + +if (!chip) +return ; +if (!gi->requested) +return ; +if (chip->ops->free) + chip->ops->free (chip, gpio - chip->base); + + gi->requested = false; +free (gi->label); + } }void gpio_set_value (unsigned gpio,int value) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; - -if (!gpio_is_valid (gpio)) -return ; -if (!chip) -return ; -if (gpio_ensure_requested (gi, gpio)) -return ; -if (!chip->ops->set) -return ; - chip->ops->set (chip, gpio - chip->base, value); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; + +if (!chip) +return ; +if (gpio_ensure_requested (gi, gpio)) +return ; +if (!chip->ops->set) +return ; + chip->ops->set (chip, gpio - chip->base, value); + } }EXPORT_SYMBOL (gpio_set_value);int gpio_get_value (unsigned gpio) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -ENODEV ; - ret =gpio_ensure_requested (gi, gpio); -if (ret) -return ret; -if (!chip->ops->get) -return -ENOSYS ; -return chip->ops->get (chip, gpio - chip->base); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -ENODEV ; + ret =gpio_ensure_requested (gi, gpio); +if (ret) +return ret; +if (!chip->ops->get) +return -ENOSYS ; +return chip->ops->get (chip, gpio - chip->base); + } + +return -EINVAL ; }EXPORT_SYMBOL (gpio_get_value);int gpio_direction_output (unsigned gpio,int value) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -ENODEV ; - ret =gpio_ensure_requested (gi, gpio); -if (ret) -return ret; -if (!chip->ops->direction_output) -return -ENOSYS ; -return chip->ops->direction_output (chip, gpio - chip->base, value); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -ENODEV ; + ret =gpio_ensure_requested (gi, gpio); +if (ret) +return ret; +if (!chip->ops->direction_output) +return -ENOSYS ; +return chip->ops->direction_output (chip, gpio - chip->base, + value); + } + +return -EINVAL ; }EXPORT_SYMBOL (gpio_direction_output);int gpio_direction_input (unsigned gpio) { -struct gpio_info *gi = &gpio_desc[gpio]; -struct gpio_chip *chip = gi->chip; -int ret; - -if (!gpio_is_valid (gpio)) -return -EINVAL ; -if (!chip) -return -ENODEV ; - ret =gpio_ensure_requested (gi, gpio); -if (ret) -return ret; -if (!chip->ops->direction_input) -return -ENOSYS ; -return chip->ops->direction_input (chip, gpio - chip->base); +if (gpio_is_valid (gpio)) { +struct gpio_info *gi = &gpio_desc[gpio]; +struct gpio_chip *chip = gi->chip; +int ret; + +if (!chip) +return -ENODEV ; + ret =gpio_ensure_requested (gi, gpio); +if (ret) +return ret;
Quoted 8 lines
drivers/gpio/gpiolib.c static int gpio_ensure_requested(struct gpio_info *gi, int gpio) · line 158
Quoted 8 lines
drivers/gpio/gpiolib.c +6
-0+if (!chip->ops->direction_input) +return -ENOSYS ; +return chip->ops->direction_input (chip, gpio - chip->base); + } + +return -EINVAL ; }EXPORT_SYMBOL (gpio_direction_input);
---
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox