Commit 515321ac authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Bartosz Golaszewski

gpiolib: Introduce acpi_gpio_dev_init() and call it from core

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
parent 1df62542
...@@ -1291,6 +1291,13 @@ void acpi_gpiochip_remove(struct gpio_chip *chip) ...@@ -1291,6 +1291,13 @@ void acpi_gpiochip_remove(struct gpio_chip *chip)
kfree(acpi_gpio); 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) static int acpi_gpio_package_count(const union acpi_object *obj)
{ {
const union acpi_object *element = obj->package.elements; const union acpi_object *element = obj->package.elements;
......
...@@ -36,6 +36,8 @@ struct acpi_gpio_info { ...@@ -36,6 +36,8 @@ struct acpi_gpio_info {
void acpi_gpiochip_add(struct gpio_chip *chip); void acpi_gpiochip_add(struct gpio_chip *chip);
void acpi_gpiochip_remove(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_request_interrupts(struct gpio_chip *chip);
void acpi_gpiochip_free_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); ...@@ -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_add(struct gpio_chip *chip) { }
static inline void acpi_gpiochip_remove(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 static inline void
acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { } acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
......
...@@ -591,6 +591,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, ...@@ -591,6 +591,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
gc->gpiodev = gdev; gc->gpiodev = gdev;
of_gpio_dev_init(gc, gdev); of_gpio_dev_init(gc, gdev);
acpi_gpio_dev_init(gc, gdev);
/* /*
* Assign fwnode depending on the result of the previous calls, * Assign fwnode depending on the result of the previous calls,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment