diff options
-rw-r--r-- | drivers/acpi/device_pm.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 17e8eb93a76c..69ffd1dc1de7 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c | |||
@@ -387,6 +387,7 @@ EXPORT_SYMBOL(acpi_bus_power_manageable); | |||
387 | 387 | ||
388 | #ifdef CONFIG_PM | 388 | #ifdef CONFIG_PM |
389 | static DEFINE_MUTEX(acpi_pm_notifier_lock); | 389 | static DEFINE_MUTEX(acpi_pm_notifier_lock); |
390 | static DEFINE_MUTEX(acpi_pm_notifier_install_lock); | ||
390 | 391 | ||
391 | void acpi_pm_wakeup_event(struct device *dev) | 392 | void acpi_pm_wakeup_event(struct device *dev) |
392 | { | 393 | { |
@@ -443,24 +444,25 @@ acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev, | |||
443 | if (!dev && !func) | 444 | if (!dev && !func) |
444 | return AE_BAD_PARAMETER; | 445 | return AE_BAD_PARAMETER; |
445 | 446 | ||
446 | mutex_lock(&acpi_pm_notifier_lock); | 447 | mutex_lock(&acpi_pm_notifier_install_lock); |
447 | 448 | ||
448 | if (adev->wakeup.flags.notifier_present) | 449 | if (adev->wakeup.flags.notifier_present) |
449 | goto out; | 450 | goto out; |
450 | 451 | ||
451 | adev->wakeup.ws = wakeup_source_register(dev_name(&adev->dev)); | ||
452 | adev->wakeup.context.dev = dev; | ||
453 | adev->wakeup.context.func = func; | ||
454 | |||
455 | status = acpi_install_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY, | 452 | status = acpi_install_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY, |
456 | acpi_pm_notify_handler, NULL); | 453 | acpi_pm_notify_handler, NULL); |
457 | if (ACPI_FAILURE(status)) | 454 | if (ACPI_FAILURE(status)) |
458 | goto out; | 455 | goto out; |
459 | 456 | ||
457 | mutex_lock(&acpi_pm_notifier_lock); | ||
458 | adev->wakeup.ws = wakeup_source_register(dev_name(&adev->dev)); | ||
459 | adev->wakeup.context.dev = dev; | ||
460 | adev->wakeup.context.func = func; | ||
460 | adev->wakeup.flags.notifier_present = true; | 461 | adev->wakeup.flags.notifier_present = true; |
462 | mutex_unlock(&acpi_pm_notifier_lock); | ||
461 | 463 | ||
462 | out: | 464 | out: |
463 | mutex_unlock(&acpi_pm_notifier_lock); | 465 | mutex_unlock(&acpi_pm_notifier_install_lock); |
464 | return status; | 466 | return status; |
465 | } | 467 | } |
466 | 468 | ||
@@ -472,7 +474,7 @@ acpi_status acpi_remove_pm_notifier(struct acpi_device *adev) | |||
472 | { | 474 | { |
473 | acpi_status status = AE_BAD_PARAMETER; | 475 | acpi_status status = AE_BAD_PARAMETER; |
474 | 476 | ||
475 | mutex_lock(&acpi_pm_notifier_lock); | 477 | mutex_lock(&acpi_pm_notifier_install_lock); |
476 | 478 | ||
477 | if (!adev->wakeup.flags.notifier_present) | 479 | if (!adev->wakeup.flags.notifier_present) |
478 | goto out; | 480 | goto out; |
@@ -483,14 +485,15 @@ acpi_status acpi_remove_pm_notifier(struct acpi_device *adev) | |||
483 | if (ACPI_FAILURE(status)) | 485 | if (ACPI_FAILURE(status)) |
484 | goto out; | 486 | goto out; |
485 | 487 | ||
488 | mutex_lock(&acpi_pm_notifier_lock); | ||
486 | adev->wakeup.context.func = NULL; | 489 | adev->wakeup.context.func = NULL; |
487 | adev->wakeup.context.dev = NULL; | 490 | adev->wakeup.context.dev = NULL; |
488 | wakeup_source_unregister(adev->wakeup.ws); | 491 | wakeup_source_unregister(adev->wakeup.ws); |
489 | |||
490 | adev->wakeup.flags.notifier_present = false; | 492 | adev->wakeup.flags.notifier_present = false; |
493 | mutex_unlock(&acpi_pm_notifier_lock); | ||
491 | 494 | ||
492 | out: | 495 | out: |
493 | mutex_unlock(&acpi_pm_notifier_lock); | 496 | mutex_unlock(&acpi_pm_notifier_install_lock); |
494 | return status; | 497 | return status; |
495 | } | 498 | } |
496 | 499 | ||