gpio_request() followed by gpio_direction_{in,out}put is a gpio usage pattern (e.g. the similar functions are used in a ARM boards code). Signed-off-by: Antony Pavlov <antonynpavlov@xxxxxxxxx> --- drivers/gpio/gpio.c | 26 ++++++++++++++++++++++++++ include/gpio.h | 13 +++++++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpio.c index d37f5a0..f32f304 100644 --- a/drivers/gpio/gpio.c +++ b/drivers/gpio/gpio.c @@ -47,6 +47,32 @@ int gpio_request(unsigned gpio, const char *label) return 0; } +int gpio_request_input(unsigned gpio, const char *label) +{ + int ret; + + ret = gpio_request(gpio, label); + if (ret) + return ret; + + ret = gpio_direction_input(gpio); + + return ret; +} + +int gpio_request_output(unsigned gpio, const char *label, int value) +{ + int ret; + + ret = gpio_request(gpio, label); + if (ret) + return ret; + + ret = gpio_direction_output(gpio, value); + + return ret; +} + void gpio_free(unsigned gpio) { struct gpio_info *gi = &gpio_desc[gpio]; diff --git a/include/gpio.h b/include/gpio.h index 794d959..309c1c5 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -9,11 +9,24 @@ static inline int gpio_request(unsigned gpio, const char *label) return 0; } +static inline int gpio_request_input(unsigned gpio, const char *label) +{ + return 0; +} + +static inline int gpio_request_output(unsigned gpio, const char *label, + int value) +{ + return 0; +} + static inline void gpio_free(unsigned gpio) { } #else int gpio_request(unsigned gpio, const char *label); +int gpio_request_input(unsigned gpio, const char *label); +int gpio_request_output(unsigned gpio, const char *label, int value); void gpio_free(unsigned gpio); #endif -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox