Skip to content

Commit 25e3ef8

Browse files
andy-shevLinus Walleij
authored andcommitted
gpio: acpi: Split out acpi_gpio_get_irq_resource() helper
The helper does retrieve pointer to struct acpi_resource_gpio from struct acpi_resource if it represents GpioInt() resource. It will be used by PNP code later on. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent a31f5c3 commit 25e3ef8

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

‎drivers/gpio/gpiolib-acpi.c‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,23 @@ static void acpi_gpio_chip_dh(acpi_handle handle, void *data)
165165
/* The address of this function is used as a key. */
166166
}
167167

168+
bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
169+
struct acpi_resource_gpio **agpio)
170+
{
171+
struct acpi_resource_gpio *gpio;
172+
173+
if (ares->type != ACPI_RESOURCE_TYPE_GPIO)
174+
return false;
175+
176+
gpio = &ares->data.gpio;
177+
if (gpio->connection_type != ACPI_RESOURCE_GPIO_TYPE_INT)
178+
return false;
179+
180+
*agpio = gpio;
181+
return true;
182+
}
183+
EXPORT_SYMBOL_GPL(acpi_gpio_get_irq_resource);
184+
168185
static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
169186
void *context)
170187
{
@@ -178,11 +195,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
178195
unsigned long irqflags;
179196
int ret, pin, irq;
180197

181-
if (ares->type != ACPI_RESOURCE_TYPE_GPIO)
182-
return AE_OK;
183-
184-
agpio = &ares->data.gpio;
185-
if (agpio->connection_type != ACPI_RESOURCE_GPIO_TYPE_INT)
198+
if (!acpi_gpio_get_irq_resource(ares, &agpio))
186199
return AE_OK;
187200

188201
handle = ACPI_HANDLE(chip->parent);

‎include/linux/acpi.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,8 @@ int devm_acpi_dev_add_driver_gpios(struct device *dev,
964964
const struct acpi_gpio_mapping *gpios);
965965
void devm_acpi_dev_remove_driver_gpios(struct device *dev);
966966

967+
bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
968+
struct acpi_resource_gpio **agpio);
967969
int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index);
968970
#else
969971
static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
@@ -980,6 +982,11 @@ static inline int devm_acpi_dev_add_driver_gpios(struct device *dev,
980982
}
981983
static inline void devm_acpi_dev_remove_driver_gpios(struct device *dev) {}
982984

985+
static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
986+
struct acpi_resource_gpio **agpio)
987+
{
988+
return false;
989+
}
983990
static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
984991
{
985992
return -ENXIO;

0 commit comments

Comments
 (0)