From 606be34440ee3e6da3799691fcab7b69e1ad06cd Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 10 Apr 2019 18:39:20 +0300 Subject: [PATCH] gpiolib: acpi: Add acpi_gpio_update_gpiod_lookup_flags() helper This helper consolidates all settings of GPIO descriptor lookup flags and quirks in the future if any. No functional change intended. Signed-off-by: Andy Shevchenko Acked-by: Hans de Goede Reviewed-by: Mika Westerberg Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib-acpi.c | 13 ++++++++++--- drivers/gpio/gpiolib.c | 4 +--- drivers/gpio/gpiolib.h | 8 ++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 878c7a7dea8b..9c6ebaaa02fe 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -525,6 +525,15 @@ acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *inf return ret; } +int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags, + struct acpi_gpio_info *info) +{ + if (info->polarity == GPIO_ACTIVE_LOW) + *lookupflags |= GPIO_ACTIVE_LOW; + + return 0; +} + struct acpi_gpio_lookup { struct acpi_gpio_info info; int index; @@ -745,10 +754,8 @@ struct gpio_desc *acpi_find_gpio(struct device *dev, return ERR_PTR(-ENOENT); } - if (info.polarity == GPIO_ACTIVE_LOW) - *lookupflags |= GPIO_ACTIVE_LOW; - acpi_gpio_update_gpiod_flags(dflags, &info); + acpi_gpio_update_gpiod_lookup_flags(lookupflags, &info); return desc; } diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index b8e4c9cd7b9e..bfbe5d7af372 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -4350,9 +4350,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, return desc; acpi_gpio_update_gpiod_flags(&dflags, &info); - - if (info.polarity == GPIO_ACTIVE_LOW) - lflags |= GPIO_ACTIVE_LOW; + acpi_gpio_update_gpiod_lookup_flags(&lflags, &info); } /* Currently only ACPI takes this path */ diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 5dbfce616ae1..e1636e152a6c 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -125,6 +125,8 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *info); +int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags, + struct acpi_gpio_info *info); struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, @@ -153,6 +155,12 @@ acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *inf { return 0; } +static inline int +acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags, + struct acpi_gpio_info *info) +{ + return 0; +} static inline struct gpio_desc * acpi_find_gpio(struct device *dev, const char *con_id,