gpio: acpi: Make acpi_gpio_count() take firmware node as a parameter
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 29 Feb 2024 14:51:39 +0000 (16:51 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Fri, 1 Mar 2024 08:08:34 +0000 (09:08 +0100)
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>
drivers/gpio/gpiolib-acpi.c
drivers/gpio/gpiolib-acpi.h
drivers/gpio/gpiolib.c

index 899cd505073e358a5c254b93869ed0ffe0109b97..7f140df40f35bd104f3742774eeeba171e497f67 100644 (file)
@@ -1402,17 +1402,17 @@ static int acpi_find_gpio_count(struct acpi_resource *ares, void *data)
 }
 
 /**
- * acpi_gpio_count - count the GPIOs associated with a device / function
- * @dev:       GPIO consumer, can be %NULL for system-global GPIOs
+ * acpi_gpio_count - count the GPIOs associated with a firmware node / function
+ * @fwnode:    firmware node of the GPIO consumer
  * @con_id:    function within the GPIO consumer
  *
  * Return:
- * The number of GPIOs associated with a device / function or %-ENOENT,
+ * The number of GPIOs associated with a firmware node / function or %-ENOENT,
  * if no GPIO has been assigned to the requested function.
  */
-int acpi_gpio_count(struct device *dev, const char *con_id)
+int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id)
 {
-       struct acpi_device *adev = ACPI_COMPANION(dev);
+       struct acpi_device *adev = to_acpi_device_node(fwnode);
        const union acpi_object *obj;
        const struct acpi_gpio_mapping *gm;
        int count = -ENOENT;
@@ -1429,8 +1429,7 @@ int acpi_gpio_count(struct device *dev, const char *con_id)
                        snprintf(propname, sizeof(propname), "%s",
                                 gpio_suffixes[i]);
 
-               ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_ANY,
-                                           &obj);
+               ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_ANY, &obj);
                if (ret == 0) {
                        if (obj->type == ACPI_TYPE_LOCAL_REFERENCE)
                                count = 1;
index 0fcd7e14d7f9b78ac974fcf7fed36c3792e78760..7e1c51d04040be0ac42c37c840ffbec6f2293a78 100644 (file)
@@ -33,7 +33,7 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
                                 enum gpiod_flags *dflags,
                                 unsigned long *lookupflags);
 
-int acpi_gpio_count(struct device *dev, const char *con_id);
+int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id);
 #else
 static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
 static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
@@ -51,7 +51,8 @@ acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id,
 {
        return ERR_PTR(-ENOENT);
 }
-static inline int acpi_gpio_count(struct device *dev, const char *con_id)
+static inline int acpi_gpio_count(const struct fwnode_handle *fwnode,
+                                 const char *con_id)
 {
        return -ENODEV;
 }
index 01016b4c467473f5fe114528260c5c7a0c35f2a7..6ea71b72c19a61c85606417d7b4134bbb0cd93e7 100644 (file)
@@ -4287,7 +4287,7 @@ int gpiod_count(struct device *dev, const char *con_id)
        if (is_of_node(fwnode))
                count = of_gpio_count(fwnode, con_id);
        else if (is_acpi_node(fwnode))
-               count = acpi_gpio_count(dev, con_id);
+               count = acpi_gpio_count(fwnode, con_id);
        else if (is_software_node(fwnode))
                count = swnode_gpio_count(fwnode, con_id);