Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bin Shi and committed by
Jiri Kosina
15820439 5e01dc7b

+11 -2
+9 -2
drivers/char/apm-emulation.c
··· 531 531 { 532 532 struct apm_user *as; 533 533 int err; 534 + unsigned long apm_event; 534 535 535 536 /* short-cut emergency suspends */ 536 537 if (atomic_read(&userspace_notification_inhibit)) ··· 539 538 540 539 switch (event) { 541 540 case PM_SUSPEND_PREPARE: 541 + case PM_HIBERNATION_PREPARE: 542 + apm_event = (event == PM_SUSPEND_PREPARE) ? 543 + APM_USER_SUSPEND : APM_USER_HIBERNATION; 542 544 /* 543 545 * Queue an event to all "writer" users that we want 544 546 * to suspend and need their ack. ··· 554 550 as->writer && as->suser) { 555 551 as->suspend_state = SUSPEND_PENDING; 556 552 atomic_inc(&suspend_acks_pending); 557 - queue_add_event(&as->queue, APM_USER_SUSPEND); 553 + queue_add_event(&as->queue, apm_event); 558 554 } 559 555 } 560 556 ··· 605 601 return notifier_from_errno(err); 606 602 607 603 case PM_POST_SUSPEND: 604 + case PM_POST_HIBERNATION: 605 + apm_event = (event == PM_POST_SUSPEND) ? 606 + APM_NORMAL_RESUME : APM_HIBERNATION_RESUME; 608 607 /* 609 608 * Anyone on the APM queues will think we're still suspended. 610 609 * Send a message so everyone knows we're now awake again. 611 610 */ 612 - queue_event(APM_NORMAL_RESUME); 611 + queue_event(apm_event); 613 612 614 613 /* 615 614 * Finally, wake up anyone who is sleeping on the suspend.
+2
include/uapi/linux/apm_bios.h
··· 67 67 #define APM_USER_SUSPEND 0x000a 68 68 #define APM_STANDBY_RESUME 0x000b 69 69 #define APM_CAPABILITY_CHANGE 0x000c 70 + #define APM_USER_HIBERNATION 0x000d 71 + #define APM_HIBERNATION_RESUME 0x000e 70 72 71 73 /* 72 74 * Error codes