Skip to content

Commit a594877

Browse files
committed
gpiolib: acpi: Handle deferred list via new API
Introduce a new API and handle deferred list via it which moves towards isolating the GPIO ACPI and quirk APIs. It will helps splitting them completely in the next changes. No functional changes. Reviewed-by: Hans de Goede <[email protected]> Acked-by: Mika Westerberg <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]>
1 parent b24fd5b commit a594877

File tree

2 files changed

+37
-20
lines changed

2 files changed

+37
-20
lines changed

drivers/gpio/gpiolib-acpi.c

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,27 @@ static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
350350
return desc;
351351
}
352352

353+
bool acpi_gpio_add_to_deferred_list(struct list_head *list)
354+
{
355+
bool defer;
356+
357+
mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
358+
defer = !acpi_gpio_deferred_req_irqs_done;
359+
if (defer)
360+
list_add(list, &acpi_gpio_deferred_req_irqs_list);
361+
mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
362+
363+
return defer;
364+
}
365+
366+
void acpi_gpio_remove_from_deferred_list(struct list_head *list)
367+
{
368+
mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
369+
if (!list_empty(list))
370+
list_del_init(list);
371+
mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
372+
}
373+
353374
bool acpi_gpio_in_ignore_list(enum acpi_gpio_ignore_list list, const char *controller_in,
354375
unsigned int pin_in)
355376
{
@@ -536,7 +557,6 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
536557
struct acpi_gpio_chip *acpi_gpio;
537558
acpi_handle handle;
538559
acpi_status status;
539-
bool defer;
540560

541561
if (!chip->parent || !chip->to_irq)
542562
return;
@@ -555,14 +575,7 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
555575
acpi_walk_resources(handle, METHOD_NAME__AEI,
556576
acpi_gpiochip_alloc_event, acpi_gpio);
557577

558-
mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
559-
defer = !acpi_gpio_deferred_req_irqs_done;
560-
if (defer)
561-
list_add(&acpi_gpio->deferred_req_irqs_list_entry,
562-
&acpi_gpio_deferred_req_irqs_list);
563-
mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
564-
565-
if (defer)
578+
if (acpi_gpio_add_to_deferred_list(&acpi_gpio->deferred_req_irqs_list_entry))
566579
return;
567580

568581
acpi_gpiochip_request_irqs(acpi_gpio);
@@ -594,10 +607,7 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
594607
if (ACPI_FAILURE(status))
595608
return;
596609

597-
mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
598-
if (!list_empty(&acpi_gpio->deferred_req_irqs_list_entry))
599-
list_del_init(&acpi_gpio->deferred_req_irqs_list_entry);
600-
mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
610+
acpi_gpio_remove_from_deferred_list(&acpi_gpio->deferred_req_irqs_list_entry);
601611

602612
list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) {
603613
if (event->irq_requested) {
@@ -615,6 +625,14 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
615625
}
616626
EXPORT_SYMBOL_GPL(acpi_gpiochip_free_interrupts);
617627

628+
void __init acpi_gpio_process_deferred_list(struct list_head *list)
629+
{
630+
struct acpi_gpio_chip *acpi_gpio, *tmp;
631+
632+
list_for_each_entry_safe(acpi_gpio, tmp, list, deferred_req_irqs_list_entry)
633+
acpi_gpiochip_request_irqs(acpi_gpio);
634+
}
635+
618636
int acpi_dev_add_driver_gpios(struct acpi_device *adev,
619637
const struct acpi_gpio_mapping *gpios)
620638
{
@@ -1503,14 +1521,8 @@ int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id)
15031521
/* Run deferred acpi_gpiochip_request_irqs() */
15041522
static int __init acpi_gpio_handle_deferred_request_irqs(void)
15051523
{
1506-
struct acpi_gpio_chip *acpi_gpio, *tmp;
1507-
15081524
mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
1509-
list_for_each_entry_safe(acpi_gpio, tmp,
1510-
&acpi_gpio_deferred_req_irqs_list,
1511-
deferred_req_irqs_list_entry)
1512-
acpi_gpiochip_request_irqs(acpi_gpio);
1513-
1525+
acpi_gpio_process_deferred_list(&acpi_gpio_deferred_req_irqs_list);
15141526
acpi_gpio_deferred_req_irqs_done = true;
15151527
mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
15161528

drivers/gpio/gpiolib-acpi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ static inline int acpi_gpio_count(const struct fwnode_handle *fwnode,
5858
}
5959
#endif
6060

61+
void acpi_gpio_process_deferred_list(struct list_head *list);
62+
63+
bool acpi_gpio_add_to_deferred_list(struct list_head *list);
64+
void acpi_gpio_remove_from_deferred_list(struct list_head *list);
65+
6166
enum acpi_gpio_ignore_list {
6267
ACPI_GPIO_IGNORE_WAKE,
6368
ACPI_GPIO_IGNORE_INTERRUPT,

0 commit comments

Comments
 (0)