Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpiolib: remove asm-generic/gpio.h

The asm-generic/gpio.h file is now always included when
using gpiolib, so just move its contents into linux/gpio.h
with a few minor simplifications.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

authored by

Arnd Bergmann and committed by
Andy Shevchenko
eccb7a00 94d20f7d

+85 -161
-1
MAINTAINERS
··· 8752 8752 F: Documentation/devicetree/bindings/gpio/ 8753 8753 F: Documentation/driver-api/gpio/ 8754 8754 F: drivers/gpio/ 8755 - F: include/asm-generic/gpio.h 8756 8755 F: include/dt-bindings/gpio/ 8757 8756 F: include/linux/gpio.h 8758 8757 F: include/linux/gpio/
+1 -1
arch/m68k/include/asm/mcfgpio.h
··· 9 9 #define mcfgpio_h 10 10 11 11 #ifdef CONFIG_GPIOLIB 12 - #include <asm-generic/gpio.h> 12 + #include <linux/gpio.h> 13 13 #else 14 14 15 15 int __mcfgpio_get_value(unsigned gpio);
-2
drivers/gpio/gpio-davinci.c
··· 24 24 #include <linux/spinlock.h> 25 25 #include <linux/pm_runtime.h> 26 26 27 - #include <asm-generic/gpio.h> 28 - 29 27 #define MAX_REGS_BANKS 5 30 28 #define MAX_INT_PER_BANK 32 31 29
-1
drivers/pinctrl/core.c
··· 30 30 31 31 #ifdef CONFIG_GPIOLIB 32 32 #include "../gpio/gpiolib.h" 33 - #include <asm-generic/gpio.h> 34 33 #endif 35 34 36 35 #include "core.h"
-146
include/asm-generic/gpio.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _ASM_GENERIC_GPIO_H 3 - #define _ASM_GENERIC_GPIO_H 4 - 5 - #include <linux/types.h> 6 - #include <linux/errno.h> 7 - 8 - #ifdef CONFIG_GPIOLIB 9 - 10 - #include <linux/compiler.h> 11 - #include <linux/gpio/consumer.h> 12 - 13 - /* 14 - * Platforms may implement their GPIO interface with library code, 15 - * at a small performance cost for non-inlined operations and some 16 - * extra memory (for code and for per-GPIO table entries). 17 - */ 18 - 19 - /* 20 - * At the end we want all GPIOs to be dynamically allocated from 0. 21 - * However, some legacy drivers still perform fixed allocation. 22 - * Until they are all fixed, leave 0-512 space for them. 23 - */ 24 - #define GPIO_DYNAMIC_BASE 512 25 - 26 - struct device; 27 - struct gpio; 28 - struct seq_file; 29 - struct module; 30 - struct device_node; 31 - struct gpio_desc; 32 - 33 - /* Always use the library code for GPIO management calls, 34 - * or when sleeping may be involved. 35 - */ 36 - extern int gpio_request(unsigned gpio, const char *label); 37 - extern void gpio_free(unsigned gpio); 38 - 39 - static inline int gpio_direction_input(unsigned gpio) 40 - { 41 - return gpiod_direction_input(gpio_to_desc(gpio)); 42 - } 43 - static inline int gpio_direction_output(unsigned gpio, int value) 44 - { 45 - return gpiod_direction_output_raw(gpio_to_desc(gpio), value); 46 - } 47 - 48 - static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) 49 - { 50 - return gpiod_set_debounce(gpio_to_desc(gpio), debounce); 51 - } 52 - 53 - static inline int gpio_get_value_cansleep(unsigned gpio) 54 - { 55 - return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio)); 56 - } 57 - static inline void gpio_set_value_cansleep(unsigned gpio, int value) 58 - { 59 - return gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value); 60 - } 61 - 62 - 63 - /* A platform's <asm/gpio.h> code may want to inline the I/O calls when 64 - * the GPIO is constant and refers to some always-present controller, 65 - * giving direct access to chip registers and tight bitbanging loops. 66 - */ 67 - static inline int __gpio_get_value(unsigned gpio) 68 - { 69 - return gpiod_get_raw_value(gpio_to_desc(gpio)); 70 - } 71 - static inline void __gpio_set_value(unsigned gpio, int value) 72 - { 73 - return gpiod_set_raw_value(gpio_to_desc(gpio), value); 74 - } 75 - 76 - static inline int __gpio_cansleep(unsigned gpio) 77 - { 78 - return gpiod_cansleep(gpio_to_desc(gpio)); 79 - } 80 - 81 - static inline int __gpio_to_irq(unsigned gpio) 82 - { 83 - return gpiod_to_irq(gpio_to_desc(gpio)); 84 - } 85 - 86 - extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); 87 - extern int gpio_request_array(const struct gpio *array, size_t num); 88 - extern void gpio_free_array(const struct gpio *array, size_t num); 89 - 90 - /* 91 - * A sysfs interface can be exported by individual drivers if they want, 92 - * but more typically is configured entirely from userspace. 93 - */ 94 - static inline int gpio_export(unsigned gpio, bool direction_may_change) 95 - { 96 - return gpiod_export(gpio_to_desc(gpio), direction_may_change); 97 - } 98 - 99 - static inline void gpio_unexport(unsigned gpio) 100 - { 101 - gpiod_unexport(gpio_to_desc(gpio)); 102 - } 103 - 104 - #else /* !CONFIG_GPIOLIB */ 105 - 106 - #include <linux/kernel.h> 107 - 108 - /* platforms that don't directly support access to GPIOs through I2C, SPI, 109 - * or other blocking infrastructure can use these wrappers. 110 - */ 111 - 112 - static inline int gpio_cansleep(unsigned gpio) 113 - { 114 - return 0; 115 - } 116 - 117 - static inline int gpio_get_value_cansleep(unsigned gpio) 118 - { 119 - might_sleep(); 120 - return __gpio_get_value(gpio); 121 - } 122 - 123 - static inline void gpio_set_value_cansleep(unsigned gpio, int value) 124 - { 125 - might_sleep(); 126 - __gpio_set_value(gpio, value); 127 - } 128 - 129 - #endif /* !CONFIG_GPIOLIB */ 130 - 131 - /* 132 - * "valid" GPIO numbers are nonnegative and may be passed to 133 - * setup routines like gpio_request(). only some valid numbers 134 - * can successfully be requested and used. 135 - * 136 - * Invalid GPIO numbers are useful for indicating no-such-GPIO in 137 - * platform data and other tables. 138 - */ 139 - 140 - static inline bool gpio_is_valid(int number) 141 - { 142 - /* only non-negative numbers are valid */ 143 - return number >= 0; 144 - } 145 - 146 - #endif /* _ASM_GENERIC_GPIO_H */
+84 -10
include/linux/gpio.h
··· 13 13 #define __LINUX_GPIO_H 14 14 15 15 #include <linux/errno.h> 16 + #include <linux/types.h> 16 17 17 18 /* see Documentation/driver-api/gpio/legacy.rst */ 18 19 ··· 55 54 }; 56 55 57 56 #ifdef CONFIG_GPIOLIB 58 - #include <asm-generic/gpio.h> 59 57 60 - static inline int gpio_get_value(unsigned int gpio) 58 + #include <linux/gpio/consumer.h> 59 + 60 + /* 61 + * "valid" GPIO numbers are nonnegative and may be passed to 62 + * setup routines like gpio_request(). Only some valid numbers 63 + * can successfully be requested and used. 64 + * 65 + * Invalid GPIO numbers are useful for indicating no-such-GPIO in 66 + * platform data and other tables. 67 + */ 68 + static inline bool gpio_is_valid(int number) 61 69 { 62 - return __gpio_get_value(gpio); 70 + /* only non-negative numbers are valid */ 71 + return number >= 0; 63 72 } 64 73 65 - static inline void gpio_set_value(unsigned int gpio, int value) 74 + /* 75 + * Platforms may implement their GPIO interface with library code, 76 + * at a small performance cost for non-inlined operations and some 77 + * extra memory (for code and for per-GPIO table entries). 78 + */ 79 + 80 + /* 81 + * At the end we want all GPIOs to be dynamically allocated from 0. 82 + * However, some legacy drivers still perform fixed allocation. 83 + * Until they are all fixed, leave 0-512 space for them. 84 + */ 85 + #define GPIO_DYNAMIC_BASE 512 86 + 87 + /* Always use the library code for GPIO management calls, 88 + * or when sleeping may be involved. 89 + */ 90 + int gpio_request(unsigned gpio, const char *label); 91 + void gpio_free(unsigned gpio); 92 + 93 + static inline int gpio_direction_input(unsigned gpio) 66 94 { 67 - __gpio_set_value(gpio, value); 95 + return gpiod_direction_input(gpio_to_desc(gpio)); 96 + } 97 + static inline int gpio_direction_output(unsigned gpio, int value) 98 + { 99 + return gpiod_direction_output_raw(gpio_to_desc(gpio), value); 68 100 } 69 101 70 - static inline int gpio_cansleep(unsigned int gpio) 102 + static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) 71 103 { 72 - return __gpio_cansleep(gpio); 104 + return gpiod_set_debounce(gpio_to_desc(gpio), debounce); 73 105 } 74 106 75 - static inline int gpio_to_irq(unsigned int gpio) 107 + static inline int gpio_get_value_cansleep(unsigned gpio) 76 108 { 77 - return __gpio_to_irq(gpio); 109 + return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio)); 110 + } 111 + static inline void gpio_set_value_cansleep(unsigned gpio, int value) 112 + { 113 + return gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value); 114 + } 115 + 116 + static inline int gpio_get_value(unsigned gpio) 117 + { 118 + return gpiod_get_raw_value(gpio_to_desc(gpio)); 119 + } 120 + static inline void gpio_set_value(unsigned gpio, int value) 121 + { 122 + return gpiod_set_raw_value(gpio_to_desc(gpio), value); 123 + } 124 + 125 + static inline int gpio_cansleep(unsigned gpio) 126 + { 127 + return gpiod_cansleep(gpio_to_desc(gpio)); 128 + } 129 + 130 + static inline int gpio_to_irq(unsigned gpio) 131 + { 132 + return gpiod_to_irq(gpio_to_desc(gpio)); 133 + } 134 + 135 + int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); 136 + int gpio_request_array(const struct gpio *array, size_t num); 137 + void gpio_free_array(const struct gpio *array, size_t num); 138 + 139 + /* 140 + * A sysfs interface can be exported by individual drivers if they want, 141 + * but more typically is configured entirely from userspace. 142 + */ 143 + static inline int gpio_export(unsigned gpio, bool direction_may_change) 144 + { 145 + return gpiod_export(gpio_to_desc(gpio), direction_may_change); 146 + } 147 + 148 + static inline void gpio_unexport(unsigned gpio) 149 + { 150 + gpiod_unexport(gpio_to_desc(gpio)); 78 151 } 79 152 80 153 /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */ ··· 163 88 164 89 #include <linux/bug.h> 165 90 #include <linux/kernel.h> 166 - #include <linux/types.h> 167 91 168 92 struct device; 169 93 struct gpio_chip;