From 9ea836005a5d885c4182da128282fdb4d69c72b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lothar=20Wa=C3=9Fmann?= Date: Thu, 16 Jul 2015 13:28:05 +0200 Subject: [PATCH] gpio: remove gpiolib.c and define remaining functions as static inline in asm/gpio.h --- drivers/gpio/gpiolib.c | 55 ----------------------- include/asm-generic/gpio.h | 92 ++++++++++++++++++++++++++++---------- 2 files changed, 69 insertions(+), 78 deletions(-) delete mode 100644 drivers/gpio/gpiolib.c diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c deleted file mode 100644 index 63b287cda3..0000000000 --- a/drivers/gpio/gpiolib.c +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include - -int gpio_request_one(unsigned int gpio, enum gpio_flags flags, - const char *label) -{ - int ret; - - ret = gpio_request(gpio, label); - if (ret) - return ret; - - if (flags == GPIOFLAG_INPUT) - gpio_direction_input(gpio); - else if (flags == GPIOFLAG_OUTPUT_INIT_LOW) - gpio_direction_output(gpio, 0); - else if (flags == GPIOFLAG_OUTPUT_INIT_HIGH) - gpio_direction_output(gpio, 1); - - return ret; -} - -int gpio_request_array(const struct gpio *gpios, int count) -{ - int ret; - int i; - - for (i = 0; i < count; i++) { - ret = gpio_request_one(gpios[i].gpio, gpios[i].flags, - gpios[i].label); - if (ret) { - printf("Failed to request GPIO%d (%u of %u): %d\n", - gpios[i].gpio, i, count, ret); - goto error; - } - } - return 0; - -error: - while (--i >= 0) - gpio_free(gpios[i].gpio); - - return ret; -} - -int gpio_free_array(const struct gpio *gpios, int count) -{ - int ret = 0; - int i; - - for (i = 0; i < count; i++) - ret |= gpio_free(gpios[i].gpio); - - return ret; -} diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index d4f4f0685b..e728c1e776 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -60,21 +60,6 @@ struct gpio { */ int gpio_request(unsigned gpio, const char *label); -/** - * @deprecated Please use driver model instead - * Request a GPIO and configure it - * @param gpios pointer to array of gpio defs - * @param count number of GPIOs to set up - */ -int gpio_request_one(unsigned gpio, enum gpio_flags flags, const char *label); - -/** - * Request a set of GPIOs and configure them - * @param gpios pointer to array of gpio defs - * @param count number of GPIOs to set up - */ -int gpio_request_array(const struct gpio *gpios, int count); - /** * @deprecated Please use driver model instead * Stop using the GPIO. This function should not alter pin configuration. @@ -84,14 +69,6 @@ int gpio_request_array(const struct gpio *gpios, int count); */ int gpio_free(unsigned gpio); -/** - * @deprecated Please use driver model instead - * Release a set of GPIOs - * @param gpios pointer to array of gpio defs - * @param count number of GPIOs to set up - */ -int gpio_free_array(const struct gpio *gpios, int count); - /** * @deprecated Please use driver model instead * Make a GPIO an input. @@ -568,4 +545,73 @@ int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags); */ int gpio_get_number(struct gpio_desc *desc); +/** + * @deprecated Please use driver model instead + * Request a GPIO and configure it + * @param gpios pointer to array of gpio defs + * @param count number of GPIOs to set up + */ +static inline int gpio_request_one(unsigned int gpio, enum gpio_flags flags, + const char *label) +{ + int ret; + + ret = gpio_request(gpio, label); + if (ret) + return ret; + + if (flags == GPIOFLAG_INPUT) + gpio_direction_input(gpio); + else if (flags == GPIOFLAG_OUTPUT_INIT_LOW) + gpio_direction_output(gpio, 0); + else if (flags == GPIOFLAG_OUTPUT_INIT_HIGH) + gpio_direction_output(gpio, 1); + + return ret; +} + +/** + * Request a set of GPIOs and configure them + * @param gpios pointer to array of gpio defs + * @param count number of GPIOs to set up + */ +static inline int gpio_request_array(const struct gpio *gpios, int count) +{ + int ret; + int i; + + for (i = 0; i < count; i++) { + ret = gpio_request_one(gpios[i].gpio, gpios[i].flags, + gpios[i].label); + if (ret) { + printf("Failed to request GPIO%d (%u of %u): %d\n", + gpios[i].gpio, i, count, ret); + goto error; + } + } + return 0; + +error: + while (--i >= 0) + gpio_free(gpios[i].gpio); + + return ret; +} + +/** + * @deprecated Please use driver model instead + * Release a set of GPIOs + * @param gpios pointer to array of gpio defs + * @param count number of GPIOs to set up + */ +static inline int gpio_free_array(const struct gpio *gpios, int count) +{ + int ret = 0; + int i; + + for (i = 0; i < count; i++) + ret |= gpio_free(gpios[i].gpio); + + return ret; +} #endif /* _ASM_GENERIC_GPIO_H_ */ -- 2.39.2