@@ -459,85 +459,67 @@ static void acpi_bus_osc_negotiate_usb_control(void)
459
459
Notification Handling
460
460
-------------------------------------------------------------------------- */
461
461
462
- /*
463
- * acpi_bus_notify
464
- * ---------------
465
- * Callback for all 'system-level' device notifications (values 0x00-0x7F).
462
+ /**
463
+ * acpi_bus_notify - Global system-level (0x00-0x7F) notifications handler
464
+ * @handle: Target ACPI object.
465
+ * @type: Notification type.
466
+ * @data: Ignored.
467
+ *
468
+ * This only handles notifications related to device hotplug.
466
469
*/
467
470
static void acpi_bus_notify (acpi_handle handle , u32 type , void * data )
468
471
{
469
472
struct acpi_device * adev ;
470
- u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE ;
471
- bool hotplug_event = false;
472
473
473
474
switch (type ) {
474
475
case ACPI_NOTIFY_BUS_CHECK :
475
476
acpi_handle_debug (handle , "ACPI_NOTIFY_BUS_CHECK event\n" );
476
- hotplug_event = true;
477
477
break ;
478
478
479
479
case ACPI_NOTIFY_DEVICE_CHECK :
480
480
acpi_handle_debug (handle , "ACPI_NOTIFY_DEVICE_CHECK event\n" );
481
- hotplug_event = true;
482
481
break ;
483
482
484
483
case ACPI_NOTIFY_DEVICE_WAKE :
485
484
acpi_handle_debug (handle , "ACPI_NOTIFY_DEVICE_WAKE event\n" );
486
- break ;
485
+ return ;
487
486
488
487
case ACPI_NOTIFY_EJECT_REQUEST :
489
488
acpi_handle_debug (handle , "ACPI_NOTIFY_EJECT_REQUEST event\n" );
490
- hotplug_event = true;
491
489
break ;
492
490
493
491
case ACPI_NOTIFY_DEVICE_CHECK_LIGHT :
494
492
acpi_handle_debug (handle , "ACPI_NOTIFY_DEVICE_CHECK_LIGHT event\n" );
495
493
/* TBD: Exactly what does 'light' mean? */
496
- break ;
494
+ return ;
497
495
498
496
case ACPI_NOTIFY_FREQUENCY_MISMATCH :
499
497
acpi_handle_err (handle , "Device cannot be configured due "
500
498
"to a frequency mismatch\n" );
501
- break ;
499
+ return ;
502
500
503
501
case ACPI_NOTIFY_BUS_MODE_MISMATCH :
504
502
acpi_handle_err (handle , "Device cannot be configured due "
505
503
"to a bus mode mismatch\n" );
506
- break ;
504
+ return ;
507
505
508
506
case ACPI_NOTIFY_POWER_FAULT :
509
507
acpi_handle_err (handle , "Device has suffered a power fault\n" );
510
- break ;
508
+ return ;
511
509
512
510
default :
513
511
acpi_handle_debug (handle , "Unknown event type 0x%x\n" , type );
514
- break ;
512
+ return ;
515
513
}
516
514
517
515
adev = acpi_get_acpi_dev (handle );
518
- if (!adev )
519
- goto err ;
520
-
521
- if (adev -> dev .driver ) {
522
- struct acpi_driver * driver = to_acpi_driver (adev -> dev .driver );
523
-
524
- if (driver && driver -> ops .notify &&
525
- (driver -> flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ))
526
- driver -> ops .notify (adev , type );
527
- }
528
-
529
- if (!hotplug_event ) {
530
- acpi_put_acpi_dev (adev );
531
- return ;
532
- }
533
516
534
- if (ACPI_SUCCESS (acpi_hotplug_schedule (adev , type )))
517
+ if (adev && ACPI_SUCCESS (acpi_hotplug_schedule (adev , type )))
535
518
return ;
536
519
537
520
acpi_put_acpi_dev (adev );
538
521
539
- err :
540
- acpi_evaluate_ost (handle , type , ost_code , NULL );
522
+ acpi_evaluate_ost (handle , type , ACPI_OST_SC_NON_SPECIFIC_FAILURE , NULL );
541
523
}
542
524
543
525
static void acpi_notify_device (acpi_handle handle , u32 event , void * data )
@@ -562,42 +544,51 @@ static u32 acpi_device_fixed_event(void *data)
562
544
return ACPI_INTERRUPT_HANDLED ;
563
545
}
564
546
565
- static int acpi_device_install_notify_handler (struct acpi_device * device )
547
+ static int acpi_device_install_notify_handler (struct acpi_device * device ,
548
+ struct acpi_driver * acpi_drv )
566
549
{
567
550
acpi_status status ;
568
551
569
- if (device -> device_type == ACPI_BUS_TYPE_POWER_BUTTON )
552
+ if (device -> device_type == ACPI_BUS_TYPE_POWER_BUTTON ) {
570
553
status =
571
554
acpi_install_fixed_event_handler (ACPI_EVENT_POWER_BUTTON ,
572
555
acpi_device_fixed_event ,
573
556
device );
574
- else if (device -> device_type == ACPI_BUS_TYPE_SLEEP_BUTTON )
557
+ } else if (device -> device_type == ACPI_BUS_TYPE_SLEEP_BUTTON ) {
575
558
status =
576
559
acpi_install_fixed_event_handler (ACPI_EVENT_SLEEP_BUTTON ,
577
560
acpi_device_fixed_event ,
578
561
device );
579
- else
580
- status = acpi_install_notify_handler (device -> handle ,
581
- ACPI_DEVICE_NOTIFY ,
562
+ } else {
563
+ u32 type = acpi_drv -> flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ?
564
+ ACPI_ALL_NOTIFY : ACPI_DEVICE_NOTIFY ;
565
+
566
+ status = acpi_install_notify_handler (device -> handle , type ,
582
567
acpi_notify_device ,
583
568
device );
569
+ }
584
570
585
571
if (ACPI_FAILURE (status ))
586
572
return - EINVAL ;
587
573
return 0 ;
588
574
}
589
575
590
- static void acpi_device_remove_notify_handler (struct acpi_device * device )
576
+ static void acpi_device_remove_notify_handler (struct acpi_device * device ,
577
+ struct acpi_driver * acpi_drv )
591
578
{
592
- if (device -> device_type == ACPI_BUS_TYPE_POWER_BUTTON )
579
+ if (device -> device_type == ACPI_BUS_TYPE_POWER_BUTTON ) {
593
580
acpi_remove_fixed_event_handler (ACPI_EVENT_POWER_BUTTON ,
594
581
acpi_device_fixed_event );
595
- else if (device -> device_type == ACPI_BUS_TYPE_SLEEP_BUTTON )
582
+ } else if (device -> device_type == ACPI_BUS_TYPE_SLEEP_BUTTON ) {
596
583
acpi_remove_fixed_event_handler (ACPI_EVENT_SLEEP_BUTTON ,
597
584
acpi_device_fixed_event );
598
- else
599
- acpi_remove_notify_handler (device -> handle , ACPI_DEVICE_NOTIFY ,
585
+ } else {
586
+ u32 type = acpi_drv -> flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ?
587
+ ACPI_ALL_NOTIFY : ACPI_DEVICE_NOTIFY ;
588
+
589
+ acpi_remove_notify_handler (device -> handle , type ,
600
590
acpi_notify_device );
591
+ }
601
592
}
602
593
603
594
/* Handle events targeting \_SB device (at present only graceful shutdown) */
@@ -1039,7 +1030,7 @@ static int acpi_device_probe(struct device *dev)
1039
1030
acpi_drv -> name , acpi_dev -> pnp .bus_id );
1040
1031
1041
1032
if (acpi_drv -> ops .notify ) {
1042
- ret = acpi_device_install_notify_handler (acpi_dev );
1033
+ ret = acpi_device_install_notify_handler (acpi_dev , acpi_drv );
1043
1034
if (ret ) {
1044
1035
if (acpi_drv -> ops .remove )
1045
1036
acpi_drv -> ops .remove (acpi_dev );
@@ -1062,7 +1053,7 @@ static void acpi_device_remove(struct device *dev)
1062
1053
struct acpi_driver * acpi_drv = to_acpi_driver (dev -> driver );
1063
1054
1064
1055
if (acpi_drv -> ops .notify )
1065
- acpi_device_remove_notify_handler (acpi_dev );
1056
+ acpi_device_remove_notify_handler (acpi_dev , acpi_drv );
1066
1057
1067
1058
if (acpi_drv -> ops .remove )
1068
1059
acpi_drv -> ops .remove (acpi_dev );
0 commit comments