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

gpio: make of_get_named_gpiod_flags() private

of_get_named_gpiod_flags() is visible and directly usable by GPIO
consumers, but it really should not as the gpiod interface relies
on the simpler gpiod_get() to provide properly-configured GPIOs.

of_get_named_gpiod_flags() is just used internally by gpiolib to
implement gpiod_get(), and by the old of_get_named_gpio_flags()
function, therefore it makes sense to make it gpiolib-private.

As a side-effect, the unused (and unneeded) of_get_gpiod_flags()
inline function is also removed, and of_get_named_gpio_flags() is moved
from a static inline function to a regular one in gpiolib-of.c

This results in all references to gpiod_* functions in of_gpio.h being
gone, which is the way it should be since this file is part of the old
integer GPIO interface.

Changes since v1:
- Fixed compilation error when CONFIG_OF_GPIO is not defined
- Fixed warning due to of_gpio_flags enum not being declared
in private gpiolib.h header

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Alexandre Courbot and committed by
Linus Walleij
f01d9075 1aeede0b

+22 -32
+14
drivers/gpio/gpiolib-of.c
··· 96 96 } 97 97 EXPORT_SYMBOL(of_get_named_gpiod_flags); 98 98 99 + int of_get_named_gpio_flags(struct device_node *np, const char *list_name, 100 + int index, enum of_gpio_flags *flags) 101 + { 102 + struct gpio_desc *desc; 103 + 104 + desc = of_get_named_gpiod_flags(np, list_name, index, flags); 105 + 106 + if (IS_ERR(desc)) 107 + return PTR_ERR(desc); 108 + else 109 + return desc_to_gpio(desc); 110 + } 111 + EXPORT_SYMBOL(of_get_named_gpio_flags); 112 + 99 113 /** 100 114 * of_gpio_simple_xlate - translate gpio_spec to the GPIO number and flags 101 115 * @gc: pointer to the gpio_chip structure
+5
drivers/gpio/gpiolib.h
··· 15 15 #include <linux/err.h> 16 16 #include <linux/device.h> 17 17 18 + enum of_gpio_flags; 19 + 18 20 /** 19 21 * struct acpi_gpio_info - ACPI GPIO specific information 20 22 * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo ··· 47 45 48 46 int gpiochip_request_own_desc(struct gpio_desc *desc, const char *label); 49 47 void gpiochip_free_own_desc(struct gpio_desc *desc); 48 + 49 + struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, 50 + const char *list_name, int index, enum of_gpio_flags *flags); 50 51 51 52 #endif /* GPIOLIB_H */
+3 -32
include/linux/of_gpio.h
··· 19 19 #include <linux/errno.h> 20 20 #include <linux/gpio.h> 21 21 #include <linux/of.h> 22 - #include <linux/gpio/consumer.h> 23 22 24 23 struct device_node; 25 24 ··· 47 48 return container_of(gc, struct of_mm_gpio_chip, gc); 48 49 } 49 50 50 - extern struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, 51 + extern int of_get_named_gpio_flags(struct device_node *np, 51 52 const char *list_name, int index, enum of_gpio_flags *flags); 52 53 53 54 extern int of_mm_gpiochip_add(struct device_node *np, ··· 62 63 #else /* CONFIG_OF_GPIO */ 63 64 64 65 /* Drivers may not strictly depend on the GPIO support, so let them link. */ 65 - static inline struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, 66 + static inline int of_get_named_gpio_flags(struct device_node *np, 66 67 const char *list_name, int index, enum of_gpio_flags *flags) 67 68 { 68 - return ERR_PTR(-ENOSYS); 69 + return -ENOSYS; 69 70 } 70 71 71 72 static inline int of_gpio_simple_xlate(struct gpio_chip *gc, ··· 79 80 static inline void of_gpiochip_remove(struct gpio_chip *gc) { } 80 81 81 82 #endif /* CONFIG_OF_GPIO */ 82 - 83 - static inline int of_get_named_gpio_flags(struct device_node *np, 84 - const char *list_name, int index, enum of_gpio_flags *flags) 85 - { 86 - struct gpio_desc *desc; 87 - desc = of_get_named_gpiod_flags(np, list_name, index, flags); 88 - 89 - if (IS_ERR(desc)) 90 - return PTR_ERR(desc); 91 - else 92 - return desc_to_gpio(desc); 93 - } 94 83 95 84 /** 96 85 * of_gpio_named_count() - Count GPIOs for a device ··· 114 127 static inline int of_gpio_count(struct device_node *np) 115 128 { 116 129 return of_gpio_named_count(np, "gpios"); 117 - } 118 - 119 - /** 120 - * of_get_gpiod_flags() - Get a GPIO descriptor and flags to use with GPIO API 121 - * @np: device node to get GPIO from 122 - * @index: index of the GPIO 123 - * @flags: a flags pointer to fill in 124 - * 125 - * Returns GPIO descriptor to use with Linux generic GPIO API, or a errno 126 - * value on the error condition. If @flags is not NULL the function also fills 127 - * in flags for the GPIO. 128 - */ 129 - static inline struct gpio_desc *of_get_gpiod_flags(struct device_node *np, 130 - int index, enum of_gpio_flags *flags) 131 - { 132 - return of_get_named_gpiod_flags(np, "gpios", index, flags); 133 130 } 134 131 135 132 static inline int of_get_gpio_flags(struct device_node *np, int index,