]> www.infradead.org Git - linux-platform-drivers-x86.git/commitdiff
gpiolib: Introduce acpi_gpio_dev_init() and call it from core
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 9 Mar 2021 09:37:34 +0000 (11:37 +0200)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Fri, 26 Mar 2021 13:56:18 +0000 (14:56 +0100)
In the ACPI case we may use the firmware node in the similar way
as it's done for OF case. We may use that fwnode for other purposes
in the future.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
drivers/gpio/gpiolib-acpi.c
drivers/gpio/gpiolib-acpi.h
drivers/gpio/gpiolib.c

index 1aacd2a5a1fd53560469dbd3571a7929f4a4e4ca..21750be9c489ca193afd17e2398ca9fa098c7777 100644 (file)
@@ -1291,6 +1291,13 @@ void acpi_gpiochip_remove(struct gpio_chip *chip)
        kfree(acpi_gpio);
 }
 
+void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev)
+{
+       /* Set default fwnode to parent's one if present */
+       if (gc->parent)
+               ACPI_COMPANION_SET(&gdev->dev, ACPI_COMPANION(gc->parent));
+}
+
 static int acpi_gpio_package_count(const union acpi_object *obj)
 {
        const union acpi_object *element = obj->package.elements;
index e2edb632b2cc9bf8ecc809548ac4e1dc35e5b596..e476558d947136d12d62abd29c26ca6b9b2d741b 100644 (file)
@@ -36,6 +36,8 @@ struct acpi_gpio_info {
 void acpi_gpiochip_add(struct gpio_chip *chip);
 void acpi_gpiochip_remove(struct gpio_chip *chip);
 
+void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev);
+
 void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
 void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
 
@@ -58,6 +60,8 @@ int acpi_gpio_count(struct device *dev, const char *con_id);
 static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
 static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
 
+static inline void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) { }
+
 static inline void
 acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
 
index 90ead10bc0869e2ed2e09c637d8dd8e6780de068..84b0a83f87ed1717acc9b57e2fd73f615c59f673 100644 (file)
@@ -591,6 +591,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
        gc->gpiodev = gdev;
 
        of_gpio_dev_init(gc, gdev);
+       acpi_gpio_dev_init(gc, gdev);
 
        /*
         * Assign fwnode depending on the result of the previous calls,