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

gpio: of: Make of_gpio_get_count() take firmware node as a parameter

Make of_gpio_get_count() take firmware node as a parameter in order
to be aligned with other functions and decouple from unused device
pointer. The latter helps to create a common fwnode_gpio_count()
in the future.

While at it, rename to be of_gpio_count() to be aligned with the others.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Andy Shevchenko and committed by
Bartosz Golaszewski
adcad536 0d776cfd

+12 -10
+7 -7
drivers/gpio/gpiolib-of.c
··· 68 68 69 69 /** 70 70 * of_gpio_spi_cs_get_count() - special GPIO counting for SPI 71 - * @dev: Consuming device 71 + * @np: Consuming device node 72 72 * @con_id: Function within the GPIO consumer 73 73 * 74 74 * Some elder GPIO controllers need special quirks. Currently we handle ··· 78 78 * the counting of "cs-gpios" to count "gpios" transparent to the 79 79 * driver. 80 80 */ 81 - static int of_gpio_spi_cs_get_count(struct device *dev, const char *con_id) 81 + static int of_gpio_spi_cs_get_count(const struct device_node *np, 82 + const char *con_id) 82 83 { 83 - struct device_node *np = dev->of_node; 84 - 85 84 if (!IS_ENABLED(CONFIG_SPI_MASTER)) 86 85 return 0; 87 86 if (!con_id || strcmp(con_id, "cs")) ··· 92 93 return of_gpio_named_count(np, "gpios"); 93 94 } 94 95 95 - int of_gpio_get_count(struct device *dev, const char *con_id) 96 + int of_gpio_count(const struct fwnode_handle *fwnode, const char *con_id) 96 97 { 98 + const struct device_node *np = to_of_node(fwnode); 97 99 int ret; 98 100 char propname[32]; 99 101 unsigned int i; 100 102 101 - ret = of_gpio_spi_cs_get_count(dev, con_id); 103 + ret = of_gpio_spi_cs_get_count(np, con_id); 102 104 if (ret > 0) 103 105 return ret; 104 106 ··· 111 111 snprintf(propname, sizeof(propname), "%s", 112 112 gpio_suffixes[i]); 113 113 114 - ret = of_gpio_named_count(dev->of_node, propname); 114 + ret = of_gpio_named_count(np, propname); 115 115 if (ret > 0) 116 116 break; 117 117 }
+4 -2
drivers/gpio/gpiolib-of.h
··· 9 9 #include <linux/notifier.h> 10 10 11 11 struct device; 12 + struct fwnode_handle; 12 13 13 14 struct gpio_chip; 14 15 struct gpio_desc; ··· 22 21 unsigned long *lookupflags); 23 22 int of_gpiochip_add(struct gpio_chip *gc); 24 23 void of_gpiochip_remove(struct gpio_chip *gc); 25 - int of_gpio_get_count(struct device *dev, const char *con_id); 24 + int of_gpio_count(const struct fwnode_handle *fwnode, const char *con_id); 26 25 #else 27 26 static inline struct gpio_desc *of_find_gpio(struct device_node *np, 28 27 const char *con_id, ··· 33 32 } 34 33 static inline int of_gpiochip_add(struct gpio_chip *gc) { return 0; } 35 34 static inline void of_gpiochip_remove(struct gpio_chip *gc) { } 36 - static inline int of_gpio_get_count(struct device *dev, const char *con_id) 35 + static inline int of_gpio_count(const struct fwnode_handle *fwnode, 36 + const char *con_id) 37 37 { 38 38 return 0; 39 39 }
+1 -1
drivers/gpio/gpiolib.c
··· 4285 4285 int count = -ENOENT; 4286 4286 4287 4287 if (is_of_node(fwnode)) 4288 - count = of_gpio_get_count(dev, con_id); 4288 + count = of_gpio_count(fwnode, con_id); 4289 4289 else if (is_acpi_node(fwnode)) 4290 4290 count = acpi_gpio_count(dev, con_id); 4291 4291 else if (is_software_node(fwnode))