diff options
author | Bin Shi <Bin.Shi@csr.com> | 2014-01-03 01:08:54 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2014-01-07 07:50:28 -0500 |
commit | 158204397034f088bfd505eeee281f7072da1c24 (patch) | |
tree | bd97dcca3c13c7ebf58c252b76ca1df9e16f4254 /drivers/char/apm-emulation.c | |
parent | 5e01dc7b26d9f24f39abace5da98ccbd6a5ceb52 (diff) |
apm-emulation: add hibernation APM events to support suspend2disk
Some embedded systems use hibernation for fast boot. and in it,
some software components need to handle specific things before
hibernation and after restore. So it needs to capture the apm
status about these pm events.
Currently apm just supports suspend to ram, but not suspend to disk,
so here add logic about hibernation apm events.
Signed-off-by: Bin Shi <Bin.Shi@csr.com>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/char/apm-emulation.c')
-rw-r--r-- | drivers/char/apm-emulation.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c index 46118f845948..dd9dfa15e9d1 100644 --- a/drivers/char/apm-emulation.c +++ b/drivers/char/apm-emulation.c | |||
@@ -531,6 +531,7 @@ static int apm_suspend_notifier(struct notifier_block *nb, | |||
531 | { | 531 | { |
532 | struct apm_user *as; | 532 | struct apm_user *as; |
533 | int err; | 533 | int err; |
534 | unsigned long apm_event; | ||
534 | 535 | ||
535 | /* short-cut emergency suspends */ | 536 | /* short-cut emergency suspends */ |
536 | if (atomic_read(&userspace_notification_inhibit)) | 537 | if (atomic_read(&userspace_notification_inhibit)) |
@@ -538,6 +539,9 @@ static int apm_suspend_notifier(struct notifier_block *nb, | |||
538 | 539 | ||
539 | switch (event) { | 540 | switch (event) { |
540 | case PM_SUSPEND_PREPARE: | 541 | case PM_SUSPEND_PREPARE: |
542 | case PM_HIBERNATION_PREPARE: | ||
543 | apm_event = (event == PM_SUSPEND_PREPARE) ? | ||
544 | APM_USER_SUSPEND : APM_USER_HIBERNATION; | ||
541 | /* | 545 | /* |
542 | * Queue an event to all "writer" users that we want | 546 | * Queue an event to all "writer" users that we want |
543 | * to suspend and need their ack. | 547 | * to suspend and need their ack. |
@@ -550,7 +554,7 @@ static int apm_suspend_notifier(struct notifier_block *nb, | |||
550 | as->writer && as->suser) { | 554 | as->writer && as->suser) { |
551 | as->suspend_state = SUSPEND_PENDING; | 555 | as->suspend_state = SUSPEND_PENDING; |
552 | atomic_inc(&suspend_acks_pending); | 556 | atomic_inc(&suspend_acks_pending); |
553 | queue_add_event(&as->queue, APM_USER_SUSPEND); | 557 | queue_add_event(&as->queue, apm_event); |
554 | } | 558 | } |
555 | } | 559 | } |
556 | 560 | ||
@@ -601,11 +605,14 @@ static int apm_suspend_notifier(struct notifier_block *nb, | |||
601 | return notifier_from_errno(err); | 605 | return notifier_from_errno(err); |
602 | 606 | ||
603 | case PM_POST_SUSPEND: | 607 | case PM_POST_SUSPEND: |
608 | case PM_POST_HIBERNATION: | ||
609 | apm_event = (event == PM_POST_SUSPEND) ? | ||
610 | APM_NORMAL_RESUME : APM_HIBERNATION_RESUME; | ||
604 | /* | 611 | /* |
605 | * Anyone on the APM queues will think we're still suspended. | 612 | * Anyone on the APM queues will think we're still suspended. |
606 | * Send a message so everyone knows we're now awake again. | 613 | * Send a message so everyone knows we're now awake again. |
607 | */ | 614 | */ |
608 | queue_event(APM_NORMAL_RESUME); | 615 | queue_event(apm_event); |
609 | 616 | ||
610 | /* | 617 | /* |
611 | * Finally, wake up anyone who is sleeping on the suspend. | 618 | * Finally, wake up anyone who is sleeping on the suspend. |