From 46eeb1405961f091aac2c7ccef593075c1e4d137 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lothar=20Wa=C3=9Fmann?= Date: Wed, 19 Aug 2015 13:25:28 +0200 Subject: [PATCH] gpio: remove gpiolib.c and define remaining functions as static inline in asm/gpio.h --- drivers/gpio/gpio-uclass.c | 53 ---------------------- drivers/gpio/gpiolib.c | 55 ----------------------- include/asm-generic/gpio.h | 92 ++++++++++++++++++++++++++++---------- 3 files changed, 69 insertions(+), 131 deletions(-) delete mode 100644 drivers/gpio/gpiolib.c diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 8ff82c5e62..a69bbd2002 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -190,48 +190,6 @@ int gpio_requestf(unsigned gpio, const char *fmt, ...) return gpio_request(gpio, buf); } -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 _dm_gpio_free(struct udevice *dev, uint offset) { struct gpio_dev_priv *uc_priv; @@ -252,17 +210,6 @@ int _dm_gpio_free(struct udevice *dev, uint offset) return 0; } -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; -} - /** * gpio_free() - [COMPAT] Relinquish GPIO * gpio: GPIO number 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