@@ -350,6 +350,27 @@ static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
350
350
return desc ;
351
351
}
352
352
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
+
353
374
bool acpi_gpio_in_ignore_list (enum acpi_gpio_ignore_list list , const char * controller_in ,
354
375
unsigned int pin_in )
355
376
{
@@ -536,7 +557,6 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
536
557
struct acpi_gpio_chip * acpi_gpio ;
537
558
acpi_handle handle ;
538
559
acpi_status status ;
539
- bool defer ;
540
560
541
561
if (!chip -> parent || !chip -> to_irq )
542
562
return ;
@@ -555,14 +575,7 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
555
575
acpi_walk_resources (handle , METHOD_NAME__AEI ,
556
576
acpi_gpiochip_alloc_event , acpi_gpio );
557
577
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 ))
566
579
return ;
567
580
568
581
acpi_gpiochip_request_irqs (acpi_gpio );
@@ -594,10 +607,7 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
594
607
if (ACPI_FAILURE (status ))
595
608
return ;
596
609
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 );
601
611
602
612
list_for_each_entry_safe_reverse (event , ep , & acpi_gpio -> events , node ) {
603
613
if (event -> irq_requested ) {
@@ -615,6 +625,14 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
615
625
}
616
626
EXPORT_SYMBOL_GPL (acpi_gpiochip_free_interrupts );
617
627
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
+
618
636
int acpi_dev_add_driver_gpios (struct acpi_device * adev ,
619
637
const struct acpi_gpio_mapping * gpios )
620
638
{
@@ -1503,14 +1521,8 @@ int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id)
1503
1521
/* Run deferred acpi_gpiochip_request_irqs() */
1504
1522
static int __init acpi_gpio_handle_deferred_request_irqs (void )
1505
1523
{
1506
- struct acpi_gpio_chip * acpi_gpio , * tmp ;
1507
-
1508
1524
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 );
1514
1526
acpi_gpio_deferred_req_irqs_done = true;
1515
1527
mutex_unlock (& acpi_gpio_deferred_req_irqs_lock );
1516
1528
0 commit comments