wakeup.c (6791e36c4a40e8930e08669e60077eea6770c429) | wakeup.c (7483b4a4d9abf9dcf1ffe6e805ead2847ec3264e) |
---|---|
1/* 2 * drivers/base/power/wakeup.c - System wakeup events framework 3 * 4 * Copyright (c) 2010 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. 5 * 6 * This file is released under the GPLv2. 7 */ 8 --- 646 unchanged lines hidden (view full) --- 655 } 656 spin_unlock_irqrestore(&events_lock, flags); 657 return ret; 658} 659 660/** 661 * pm_get_wakeup_count - Read the number of registered wakeup events. 662 * @count: Address to store the value at. | 1/* 2 * drivers/base/power/wakeup.c - System wakeup events framework 3 * 4 * Copyright (c) 2010 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. 5 * 6 * This file is released under the GPLv2. 7 */ 8 --- 646 unchanged lines hidden (view full) --- 655 } 656 spin_unlock_irqrestore(&events_lock, flags); 657 return ret; 658} 659 660/** 661 * pm_get_wakeup_count - Read the number of registered wakeup events. 662 * @count: Address to store the value at. |
663 * @block: Whether or not to block. |
|
663 * | 664 * |
664 * Store the number of registered wakeup events at the address in @count. Block 665 * if the current number of wakeup events being processed is nonzero. | 665 * Store the number of registered wakeup events at the address in @count. If 666 * @block is set, block until the current number of wakeup events being 667 * processed is zero. |
666 * | 668 * |
667 * Return 'false' if the wait for the number of wakeup events being processed to 668 * drop down to zero has been interrupted by a signal (and the current number 669 * of wakeup events being processed is still nonzero). Otherwise return 'true'. | 669 * Return 'false' if the current number of wakeup events being processed is 670 * nonzero. Otherwise return 'true'. |
670 */ | 671 */ |
671bool pm_get_wakeup_count(unsigned int *count) | 672bool pm_get_wakeup_count(unsigned int *count, bool block) |
672{ 673 unsigned int cnt, inpr; | 673{ 674 unsigned int cnt, inpr; |
674 DEFINE_WAIT(wait); | |
675 | 675 |
676 for (;;) { 677 prepare_to_wait(&wakeup_count_wait_queue, &wait, 678 TASK_INTERRUPTIBLE); 679 split_counters(&cnt, &inpr); 680 if (inpr == 0 || signal_pending(current)) 681 break; | 676 if (block) { 677 DEFINE_WAIT(wait); |
682 | 678 |
683 schedule(); | 679 for (;;) { 680 prepare_to_wait(&wakeup_count_wait_queue, &wait, 681 TASK_INTERRUPTIBLE); 682 split_counters(&cnt, &inpr); 683 if (inpr == 0 || signal_pending(current)) 684 break; 685 686 schedule(); 687 } 688 finish_wait(&wakeup_count_wait_queue, &wait); |
684 } | 689 } |
685 finish_wait(&wakeup_count_wait_queue, &wait); | |
686 687 split_counters(&cnt, &inpr); 688 *count = cnt; 689 return !inpr; 690} 691 692/** 693 * pm_save_wakeup_count - Save the current number of registered wakeup events. --- 107 unchanged lines hidden --- | 690 691 split_counters(&cnt, &inpr); 692 *count = cnt; 693 return !inpr; 694} 695 696/** 697 * pm_save_wakeup_count - Save the current number of registered wakeup events. --- 107 unchanged lines hidden --- |