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

gpio: acpi: Make acpi_gpio_count() take firmware node as a parameter

Make acpi_gpio_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.

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
8122c7c6 adcad536

+10 -10
+6 -7
drivers/gpio/gpiolib-acpi.c
··· 1402 1402 } 1403 1403 1404 1404 /** 1405 - * acpi_gpio_count - count the GPIOs associated with a device / function 1406 - * @dev: GPIO consumer, can be %NULL for system-global GPIOs 1405 + * acpi_gpio_count - count the GPIOs associated with a firmware node / function 1406 + * @fwnode: firmware node of the GPIO consumer 1407 1407 * @con_id: function within the GPIO consumer 1408 1408 * 1409 1409 * Return: 1410 - * The number of GPIOs associated with a device / function or %-ENOENT, 1410 + * The number of GPIOs associated with a firmware node / function or %-ENOENT, 1411 1411 * if no GPIO has been assigned to the requested function. 1412 1412 */ 1413 - int acpi_gpio_count(struct device *dev, const char *con_id) 1413 + int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id) 1414 1414 { 1415 - struct acpi_device *adev = ACPI_COMPANION(dev); 1415 + struct acpi_device *adev = to_acpi_device_node(fwnode); 1416 1416 const union acpi_object *obj; 1417 1417 const struct acpi_gpio_mapping *gm; 1418 1418 int count = -ENOENT; ··· 1429 1429 snprintf(propname, sizeof(propname), "%s", 1430 1430 gpio_suffixes[i]); 1431 1431 1432 - ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_ANY, 1433 - &obj); 1432 + ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_ANY, &obj); 1434 1433 if (ret == 0) { 1435 1434 if (obj->type == ACPI_TYPE_LOCAL_REFERENCE) 1436 1435 count = 1;
+3 -2
drivers/gpio/gpiolib-acpi.h
··· 33 33 enum gpiod_flags *dflags, 34 34 unsigned long *lookupflags); 35 35 36 - int acpi_gpio_count(struct device *dev, const char *con_id); 36 + int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id); 37 37 #else 38 38 static inline void acpi_gpiochip_add(struct gpio_chip *chip) { } 39 39 static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { } ··· 51 51 { 52 52 return ERR_PTR(-ENOENT); 53 53 } 54 - static inline int acpi_gpio_count(struct device *dev, const char *con_id) 54 + static inline int acpi_gpio_count(const struct fwnode_handle *fwnode, 55 + const char *con_id) 55 56 { 56 57 return -ENODEV; 57 58 }
+1 -1
drivers/gpio/gpiolib.c
··· 4287 4287 if (is_of_node(fwnode)) 4288 4288 count = of_gpio_count(fwnode, con_id); 4289 4289 else if (is_acpi_node(fwnode)) 4290 - count = acpi_gpio_count(dev, con_id); 4290 + count = acpi_gpio_count(fwnode, con_id); 4291 4291 else if (is_software_node(fwnode)) 4292 4292 count = swnode_gpio_count(fwnode, con_id); 4293 4293