From 45e888ef99d9f378c2cbadc3caa4eee1aaf09eac Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 19 Dec 2022 11:20:12 -0800 Subject: gpiolib: of: remove of_gpio_count() There are no more users of of_gpio_count() in the mainline kernel, remove it. Signed-off-by: Dmitry Torokhov Reviewed-by: Andy Shevchenko Signed-off-by: Bartosz Golaszewski --- include/linux/of_gpio.h | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'include/linux') diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index 6db627257a7b..39f16a960565 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -105,17 +105,6 @@ static inline int of_gpio_named_count(const struct device_node *np, return of_count_phandle_with_args(np, propname, "#gpio-cells"); } -/** - * of_gpio_count() - Count GPIOs for a device - * @np: device node to count GPIOs for - * - * Same as of_gpio_named_count, but hard coded to use the 'gpios' property - */ -static inline int of_gpio_count(const struct device_node *np) -{ - return of_gpio_named_count(np, "gpios"); -} - static inline int of_get_gpio_flags(const struct device_node *np, int index, enum of_gpio_flags *flags) { -- cgit From c7835652a85df183c967f574d1999505ebf80b88 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 19 Dec 2022 11:20:13 -0800 Subject: gpiolib: of: stop exporting of_gpio_named_count() The only user of this function is gpiolib-of.c so move it there. Signed-off-by: Dmitry Torokhov Reviewed-by: Andy Shevchenko Signed-off-by: Bartosz Golaszewski --- include/linux/of_gpio.h | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'include/linux') diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index 39f16a960565..680025c1a55b 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -79,32 +79,6 @@ static inline int of_get_named_gpio_flags(const struct device_node *np, #endif /* CONFIG_OF_GPIO */ -/** - * of_gpio_named_count() - Count GPIOs for a device - * @np: device node to count GPIOs for - * @propname: property name containing gpio specifier(s) - * - * The function returns the count of GPIOs specified for a node. - * Note that the empty GPIO specifiers count too. Returns either - * Number of gpios defined in property, - * -EINVAL for an incorrectly formed gpios property, or - * -ENOENT for a missing gpios property - * - * Example: - * gpios = <0 - * &gpio1 1 2 - * 0 - * &gpio2 3 4>; - * - * The above example defines four GPIOs, two of which are not specified. - * This function will return '4' - */ -static inline int of_gpio_named_count(const struct device_node *np, - const char *propname) -{ - return of_count_phandle_with_args(np, propname, "#gpio-cells"); -} - static inline int of_get_gpio_flags(const struct device_node *np, int index, enum of_gpio_flags *flags) { -- cgit From 40fc56ee608cdb20022c225ac6f1e4b7ba63f8f1 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 19 Dec 2022 11:20:15 -0800 Subject: gpiolib: of: remove of_get_gpio[_flags]() and of_get_named_gpio_flags() There are no more users of these APIs in the mainline kernel, remove them. This leaves of_get_named_gpio() as the only legacy OF-specific API. Signed-off-by: Dmitry Torokhov Reviewed-by: Andy Shevchenko Signed-off-by: Bartosz Golaszewski --- include/linux/of_gpio.h | 45 ++++----------------------------------------- 1 file changed, 4 insertions(+), 41 deletions(-) (limited to 'include/linux') diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index 680025c1a55b..e27a9187c0c6 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -50,8 +50,8 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) return container_of(gc, struct of_mm_gpio_chip, gc); } -extern int of_get_named_gpio_flags(const struct device_node *np, - const char *list_name, int index, enum of_gpio_flags *flags); +extern int of_get_named_gpio(const struct device_node *np, + const char *list_name, int index); extern int of_mm_gpiochip_add_data(struct device_node *np, struct of_mm_gpio_chip *mm_gc, @@ -68,49 +68,12 @@ extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc); #include /* Drivers may not strictly depend on the GPIO support, so let them link. */ -static inline int of_get_named_gpio_flags(const struct device_node *np, - const char *list_name, int index, enum of_gpio_flags *flags) -{ - if (flags) - *flags = 0; - - return -ENOSYS; -} - -#endif /* CONFIG_OF_GPIO */ - -static inline int of_get_gpio_flags(const struct device_node *np, int index, - enum of_gpio_flags *flags) -{ - return of_get_named_gpio_flags(np, "gpios", index, flags); -} - -/** - * of_get_named_gpio() - Get a GPIO number to use with GPIO API - * @np: device node to get GPIO from - * @propname: Name of property containing gpio specifier(s) - * @index: index of the GPIO - * - * Returns GPIO number to use with Linux generic GPIO API, or one of the errno - * value on the error condition. - */ static inline int of_get_named_gpio(const struct device_node *np, const char *propname, int index) { - return of_get_named_gpio_flags(np, propname, index, NULL); + return -ENOSYS; } -/** - * of_get_gpio() - Get a GPIO number to use with GPIO API - * @np: device node to get GPIO from - * @index: index of the GPIO - * - * Returns GPIO number to use with Linux generic GPIO API, or one of the errno - * value on the error condition. - */ -static inline int of_get_gpio(const struct device_node *np, int index) -{ - return of_get_gpio_flags(np, index, NULL); -} +#endif /* CONFIG_OF_GPIO */ #endif /* __LINUX_OF_GPIO_H */ -- cgit From 650f2dc970539b3344a98c4bd18efa309e66623b Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 19 Dec 2022 11:20:16 -0800 Subject: gpiolib: of: remove [devm_]gpiod_get_from_of_node() APIs Now that everyone is using [devm_]fwnode_gpiod_get[_index]() APIs, remove OF-specific [devm_]gpiod_get_from_of_node(). Signed-off-by: Dmitry Torokhov Reviewed-by: Andy Shevchenko Signed-off-by: Bartosz Golaszewski --- include/linux/gpio/consumer.h | 48 ------------------------------------------- 1 file changed, 48 deletions(-) (limited to 'include/linux') diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 45da8f137fe5..59cb20cfac3d 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -581,54 +581,6 @@ struct gpio_desc *devm_fwnode_gpiod_get(struct device *dev, flags, label); } -#if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_OF_GPIO) -struct device_node; - -struct gpio_desc *gpiod_get_from_of_node(const struct device_node *node, - const char *propname, int index, - enum gpiod_flags dflags, - const char *label); - -#else /* CONFIG_GPIOLIB && CONFIG_OF_GPIO */ - -struct device_node; - -static inline -struct gpio_desc *gpiod_get_from_of_node(const struct device_node *node, - const char *propname, int index, - enum gpiod_flags dflags, - const char *label) -{ - return ERR_PTR(-ENOSYS); -} - -#endif /* CONFIG_GPIOLIB && CONFIG_OF_GPIO */ - -#ifdef CONFIG_GPIOLIB -struct device_node; - -struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev, - const struct device_node *node, - const char *propname, int index, - enum gpiod_flags dflags, - const char *label); - -#else /* CONFIG_GPIOLIB */ - -struct device_node; - -static inline -struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev, - const struct device_node *node, - const char *propname, int index, - enum gpiod_flags dflags, - const char *label) -{ - return ERR_PTR(-ENOSYS); -} - -#endif /* CONFIG_GPIOLIB */ - struct acpi_gpio_params { unsigned int crs_entry_index; unsigned int line_index; -- cgit From f2527d8f566a45fa00ee5abd04d1c9476d4d704f Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 2 Jan 2023 23:08:50 +0200 Subject: gpio: Remove unused and obsoleted gpio_export_link() gpio_export_link() is legacy and unused API, remove it for good. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij Reviewed-by: Yanteng Si Signed-off-by: Bartosz Golaszewski --- include/linux/gpio.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'include/linux') diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 346f60bbab30..e94815b3ce1d 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -197,14 +197,6 @@ static inline int gpio_export(unsigned gpio, bool direction_may_change) return -EINVAL; } -static inline int gpio_export_link(struct device *dev, const char *name, - unsigned gpio) -{ - /* GPIO can never have been exported */ - WARN_ON(1); - return -EINVAL; -} - static inline void gpio_unexport(unsigned gpio) { /* GPIO can never have been exported */ -- cgit From 70d0fc4288dabd65025fde7774b4f9262afa9034 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 28 Dec 2022 11:20:44 +0200 Subject: gpiolib: Get rid of not used of_node member All new drivers should use fwnode and / or parent to provide the necessary information to the GPIO library. Cc: Thierry Reding Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij Signed-off-by: Bartosz Golaszewski --- include/linux/gpio/driver.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include/linux') diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 44783fc16125..2316cb7fa667 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -503,13 +503,6 @@ struct gpio_chip { * the device tree automatically may have an OF translation */ - /** - * @of_node: - * - * Pointer to a device tree node representing this GPIO controller. - */ - struct device_node *of_node; - /** * @of_gpio_n_cells: * -- cgit From 9a7dcaefdb8ab1c2f8558e3a66261165c86c5059 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 12 Jan 2023 16:17:43 +0200 Subject: gpiolib: Do not mention legacy API in the code Replace mentioning of legacy API by the latest one. Signed-off-by: Andy Shevchenko Signed-off-by: Bartosz Golaszewski --- include/linux/gpio/driver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 2316cb7fa667..26a808fb8a25 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -336,7 +336,7 @@ struct gpio_irq_chip { * @set_multiple: assigns output values for multiple signals defined by "mask" * @set_config: optional hook for all kinds of settings. Uses the same * packed config format as generic pinconf. - * @to_irq: optional hook supporting non-static gpio_to_irq() mappings; + * @to_irq: optional hook supporting non-static gpiod_to_irq() mappings; * implementation may not sleep * @dbg_show: optional routine to show contents in debugfs; default code * will be used when this is omitted, but custom code can show extra -- cgit From 149a028a5134ab740079bc88ee58c24a7d072ab9 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 12 Jan 2023 16:45:26 +0200 Subject: gpiolib: Remove unused of_mm_gpiochip_add() of_mm_gpiochip_add() is unused API, remove it for good. Signed-off-by: Andy Shevchenko Signed-off-by: Bartosz Golaszewski --- include/linux/of_gpio.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include/linux') diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index e27a9187c0c6..935225caf70d 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -56,11 +56,6 @@ extern int of_get_named_gpio(const struct device_node *np, extern int of_mm_gpiochip_add_data(struct device_node *np, struct of_mm_gpio_chip *mm_gc, void *data); -static inline int of_mm_gpiochip_add(struct device_node *np, - struct of_mm_gpio_chip *mm_gc) -{ - return of_mm_gpiochip_add_data(np, mm_gc, NULL); -} extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc); #else /* CONFIG_OF_GPIO */ -- cgit From a5ec171efdc6151d3a51c4e1a59abb3ab9d8b710 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 12 Jan 2023 15:39:42 +0200 Subject: gpio: Remove unused and obsoleted irq_to_gpio() irq_to_gpio() is legacy and unused API, remove it for good. This leaves gpio_to_irq() as it's used yet in many places. Nevertheless, removal of its counterpart is a good signal to whoever even trying to consider using them that do not. Signed-off-by: Andy Shevchenko Acked-by: Geert Uytterhoeven Signed-off-by: Bartosz Golaszewski --- include/linux/gpio.h | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'include/linux') diff --git a/include/linux/gpio.h b/include/linux/gpio.h index e94815b3ce1d..85beb236c925 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -81,11 +81,6 @@ static inline int gpio_to_irq(unsigned int gpio) return __gpio_to_irq(gpio); } -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - #endif /* ! CONFIG_ARCH_HAVE_CUSTOM_GPIO_H */ /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */ @@ -210,13 +205,6 @@ static inline int gpio_to_irq(unsigned gpio) return -EINVAL; } -static inline int irq_to_gpio(unsigned irq) -{ - /* irq can never have been returned from gpio_to_irq() */ - WARN_ON(1); - return -EINVAL; -} - static inline int devm_gpio_request(struct device *dev, unsigned gpio, const char *label) { -- cgit From 91a0192e90e9df40d4b63c4ce11126114ed5d79d Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 16 Jan 2023 14:47:02 +0200 Subject: gpio: pcf857x: Get rid of legacy platform data Platform data is a legacy interface to supply device properties to the driver. In this case we don't have in-kernel users for it. Moreover it uses plain GPIO numbers which is no-no for a new code. Just remove it for good. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij Signed-off-by: Bartosz Golaszewski --- include/linux/platform_data/pcf857x.h | 45 ----------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 include/linux/platform_data/pcf857x.h (limited to 'include/linux') diff --git a/include/linux/platform_data/pcf857x.h b/include/linux/platform_data/pcf857x.h deleted file mode 100644 index 01d0a3ea3aef..000000000000 --- a/include/linux/platform_data/pcf857x.h +++ /dev/null @@ -1,45 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __LINUX_PCF857X_H -#define __LINUX_PCF857X_H - -/** - * struct pcf857x_platform_data - data to set up pcf857x driver - * @gpio_base: number of the chip's first GPIO - * @n_latch: optional bit-inverse of initial register value; if - * you leave this initialized to zero the driver will act - * like the chip was just reset - * @setup: optional callback issued once the GPIOs are valid - * @teardown: optional callback issued before the GPIOs are invalidated - * @context: optional parameter passed to setup() and teardown() - * - * In addition to the I2C_BOARD_INFO() state appropriate to each chip, - * the i2c_board_info used with the pcf875x driver must provide its - * platform_data (pointer to one of these structures) with at least - * the gpio_base value initialized. - * - * The @setup callback may be used with the kind of board-specific glue - * which hands the (now-valid) GPIOs to other drivers, or which puts - * devices in their initial states using these GPIOs. - * - * These GPIO chips are only "quasi-bidirectional"; read the chip specs - * to understand the behavior. They don't have separate registers to - * record which pins are used for input or output, record which output - * values are driven, or provide access to input values. That must be - * inferred by reading the chip's value and knowing the last value written - * to it. If you leave n_latch initialized to zero, that last written - * value is presumed to be all ones (as if the chip were just reset). - */ -struct pcf857x_platform_data { - unsigned gpio_base; - unsigned n_latch; - - int (*setup)(struct i2c_client *client, - int gpio, unsigned ngpio, - void *context); - void (*teardown)(struct i2c_client *client, - int gpio, unsigned ngpio, - void *context); - void *context; -}; - -#endif /* __LINUX_PCF857X_H */ -- cgit From eed5a3bfafe6840494f7752b5cecd2a610b54fef Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 12 Jan 2023 16:51:40 +0200 Subject: gpiolib: of: Move enum of_gpio_flags to its only user GPIO library for OF is the only user for enum of_gpio_flags. Move it there. Signed-off-by: Andy Shevchenko Acked-by: Rob Herring Reviewed-by: Arnd Bergmann Signed-off-by: Bartosz Golaszewski --- include/linux/of_gpio.h | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'include/linux') diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index 935225caf70d..5d58b3b0a97e 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -17,21 +17,6 @@ struct device_node; -/* - * This is Linux-specific flags. By default controllers' and Linux' mapping - * match, but GPIO controllers are free to translate their own flags to - * Linux-specific in their .xlate callback. Though, 1:1 mapping is recommended. - */ -enum of_gpio_flags { - OF_GPIO_ACTIVE_LOW = 0x1, - OF_GPIO_SINGLE_ENDED = 0x2, - OF_GPIO_OPEN_DRAIN = 0x4, - OF_GPIO_TRANSITORY = 0x8, - OF_GPIO_PULL_UP = 0x10, - OF_GPIO_PULL_DOWN = 0x20, - OF_GPIO_PULL_DISABLE = 0x40, -}; - #ifdef CONFIG_OF_GPIO #include -- cgit