aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/bus.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/bus.c')
-rw-r--r--drivers/acpi/bus.c91
1 files changed, 24 insertions, 67 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index ae862f1798dc..2876fc70c3a9 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -450,18 +450,16 @@ int acpi_bus_receive_event(struct acpi_bus_event *event)
450 Notification Handling 450 Notification Handling
451 -------------------------------------------------------------------------- */ 451 -------------------------------------------------------------------------- */
452 452
453static int 453static void acpi_bus_check_device(acpi_handle handle)
454acpi_bus_check_device(struct acpi_device *device, int *status_changed)
455{ 454{
456 acpi_status status = 0; 455 struct acpi_device *device;
456 acpi_status status;
457 struct acpi_device_status old_status; 457 struct acpi_device_status old_status;
458 458
459 459 if (acpi_bus_get_device(handle, &device))
460 return;
460 if (!device) 461 if (!device)
461 return -EINVAL; 462 return;
462
463 if (status_changed)
464 *status_changed = 0;
465 463
466 old_status = device->status; 464 old_status = device->status;
467 465
@@ -471,22 +469,15 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed)
471 */ 469 */
472 if (device->parent && !device->parent->status.present) { 470 if (device->parent && !device->parent->status.present) {
473 device->status = device->parent->status; 471 device->status = device->parent->status;
474 if (STRUCT_TO_INT(old_status) != STRUCT_TO_INT(device->status)) { 472 return;
475 if (status_changed)
476 *status_changed = 1;
477 }
478 return 0;
479 } 473 }
480 474
481 status = acpi_bus_get_status(device); 475 status = acpi_bus_get_status(device);
482 if (ACPI_FAILURE(status)) 476 if (ACPI_FAILURE(status))
483 return -ENODEV; 477 return;
484 478
485 if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status)) 479 if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))
486 return 0; 480 return;
487
488 if (status_changed)
489 *status_changed = 1;
490 481
491 /* 482 /*
492 * Device Insertion/Removal 483 * Device Insertion/Removal
@@ -498,33 +489,17 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed)
498 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n")); 489 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n"));
499 /* TBD: Handle device removal */ 490 /* TBD: Handle device removal */
500 } 491 }
501
502 return 0;
503} 492}
504 493
505static int acpi_bus_check_scope(struct acpi_device *device) 494static void acpi_bus_check_scope(acpi_handle handle)
506{ 495{
507 int result = 0;
508 int status_changed = 0;
509
510
511 if (!device)
512 return -EINVAL;
513
514 /* Status Change? */ 496 /* Status Change? */
515 result = acpi_bus_check_device(device, &status_changed); 497 acpi_bus_check_device(handle);
516 if (result)
517 return result;
518
519 if (!status_changed)
520 return 0;
521 498
522 /* 499 /*
523 * TBD: Enumerate child devices within this device's scope and 500 * TBD: Enumerate child devices within this device's scope and
524 * run acpi_bus_check_device()'s on them. 501 * run acpi_bus_check_device()'s on them.
525 */ 502 */
526
527 return 0;
528} 503}
529 504
530static BLOCKING_NOTIFIER_HEAD(acpi_bus_notify_list); 505static BLOCKING_NOTIFIER_HEAD(acpi_bus_notify_list);
@@ -547,22 +522,19 @@ EXPORT_SYMBOL_GPL(unregister_acpi_bus_notifier);
547 */ 522 */
548static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) 523static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
549{ 524{
550 int result = 0;
551 struct acpi_device *device = NULL; 525 struct acpi_device *device = NULL;
526 struct acpi_driver *driver;
527
528 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Notification %#02x to handle %p\n",
529 type, handle));
552 530
553 blocking_notifier_call_chain(&acpi_bus_notify_list, 531 blocking_notifier_call_chain(&acpi_bus_notify_list,
554 type, (void *)handle); 532 type, (void *)handle);
555 533
556 if (acpi_bus_get_device(handle, &device))
557 return;
558
559 switch (type) { 534 switch (type) {
560 535
561 case ACPI_NOTIFY_BUS_CHECK: 536 case ACPI_NOTIFY_BUS_CHECK:
562 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 537 acpi_bus_check_scope(handle);
563 "Received BUS CHECK notification for device [%s]\n",
564 device->pnp.bus_id));
565 result = acpi_bus_check_scope(device);
566 /* 538 /*
567 * TBD: We'll need to outsource certain events to non-ACPI 539 * TBD: We'll need to outsource certain events to non-ACPI
568 * drivers via the device manager (device.c). 540 * drivers via the device manager (device.c).
@@ -570,10 +542,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
570 break; 542 break;
571 543
572 case ACPI_NOTIFY_DEVICE_CHECK: 544 case ACPI_NOTIFY_DEVICE_CHECK:
573 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 545 acpi_bus_check_device(handle);
574 "Received DEVICE CHECK notification for device [%s]\n",
575 device->pnp.bus_id));
576 result = acpi_bus_check_device(device, NULL);
577 /* 546 /*
578 * TBD: We'll need to outsource certain events to non-ACPI 547 * TBD: We'll need to outsource certain events to non-ACPI
579 * drivers via the device manager (device.c). 548 * drivers via the device manager (device.c).
@@ -581,44 +550,26 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
581 break; 550 break;
582 551
583 case ACPI_NOTIFY_DEVICE_WAKE: 552 case ACPI_NOTIFY_DEVICE_WAKE:
584 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
585 "Received DEVICE WAKE notification for device [%s]\n",
586 device->pnp.bus_id));
587 /* TBD */ 553 /* TBD */
588 break; 554 break;
589 555
590 case ACPI_NOTIFY_EJECT_REQUEST: 556 case ACPI_NOTIFY_EJECT_REQUEST:
591 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
592 "Received EJECT REQUEST notification for device [%s]\n",
593 device->pnp.bus_id));
594 /* TBD */ 557 /* TBD */
595 break; 558 break;
596 559
597 case ACPI_NOTIFY_DEVICE_CHECK_LIGHT: 560 case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:
598 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
599 "Received DEVICE CHECK LIGHT notification for device [%s]\n",
600 device->pnp.bus_id));
601 /* TBD: Exactly what does 'light' mean? */ 561 /* TBD: Exactly what does 'light' mean? */
602 break; 562 break;
603 563
604 case ACPI_NOTIFY_FREQUENCY_MISMATCH: 564 case ACPI_NOTIFY_FREQUENCY_MISMATCH:
605 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
606 "Received FREQUENCY MISMATCH notification for device [%s]\n",
607 device->pnp.bus_id));
608 /* TBD */ 565 /* TBD */
609 break; 566 break;
610 567
611 case ACPI_NOTIFY_BUS_MODE_MISMATCH: 568 case ACPI_NOTIFY_BUS_MODE_MISMATCH:
612 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
613 "Received BUS MODE MISMATCH notification for device [%s]\n",
614 device->pnp.bus_id));
615 /* TBD */ 569 /* TBD */
616 break; 570 break;
617 571
618 case ACPI_NOTIFY_POWER_FAULT: 572 case ACPI_NOTIFY_POWER_FAULT:
619 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
620 "Received POWER FAULT notification for device [%s]\n",
621 device->pnp.bus_id));
622 /* TBD */ 573 /* TBD */
623 break; 574 break;
624 575
@@ -629,7 +580,13 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
629 break; 580 break;
630 } 581 }
631 582
632 return; 583 acpi_bus_get_device(handle, &device);
584 if (device) {
585 driver = device->driver;
586 if (driver && driver->ops.notify &&
587 (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS))
588 driver->ops.notify(device, type);
589 }
633} 590}
634 591
635/* -------------------------------------------------------------------------- 592/* --------------------------------------------------------------------------