diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-12 19:04:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-12 19:04:50 -0400 |
commit | 3f603ed319d5120e883e64ac5967b2fc848fc43b (patch) | |
tree | 52ef311c245e4e4cd623b546ea1daf05a5ea8911 /kernel/power | |
parent | 55ee3b8365fd5d301b9076eea739146f2b91e82c (diff) | |
parent | 5028770a42e7bc4d15791a44c28f0ad539323807 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/lenb/linux-2.6
Diffstat (limited to 'kernel/power')
-rw-r--r-- | kernel/power/main.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c index c94cb9e95090..71aa0fd22007 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -19,6 +19,9 @@ | |||
19 | 19 | ||
20 | #include "power.h" | 20 | #include "power.h" |
21 | 21 | ||
22 | /*This is just an arbitrary number */ | ||
23 | #define FREE_PAGE_NUMBER (100) | ||
24 | |||
22 | DECLARE_MUTEX(pm_sem); | 25 | DECLARE_MUTEX(pm_sem); |
23 | 26 | ||
24 | struct pm_ops * pm_ops = NULL; | 27 | struct pm_ops * pm_ops = NULL; |
@@ -49,6 +52,7 @@ void pm_set_ops(struct pm_ops * ops) | |||
49 | static int suspend_prepare(suspend_state_t state) | 52 | static int suspend_prepare(suspend_state_t state) |
50 | { | 53 | { |
51 | int error = 0; | 54 | int error = 0; |
55 | unsigned int free_pages; | ||
52 | 56 | ||
53 | if (!pm_ops || !pm_ops->enter) | 57 | if (!pm_ops || !pm_ops->enter) |
54 | return -EPERM; | 58 | return -EPERM; |
@@ -67,6 +71,16 @@ static int suspend_prepare(suspend_state_t state) | |||
67 | goto Thaw; | 71 | goto Thaw; |
68 | } | 72 | } |
69 | 73 | ||
74 | if ((free_pages = nr_free_pages()) < FREE_PAGE_NUMBER) { | ||
75 | pr_debug("PM: free some memory\n"); | ||
76 | shrink_all_memory(FREE_PAGE_NUMBER - free_pages); | ||
77 | if (nr_free_pages() < FREE_PAGE_NUMBER) { | ||
78 | error = -ENOMEM; | ||
79 | printk(KERN_ERR "PM: No enough memory\n"); | ||
80 | goto Thaw; | ||
81 | } | ||
82 | } | ||
83 | |||
70 | if (pm_ops->prepare) { | 84 | if (pm_ops->prepare) { |
71 | if ((error = pm_ops->prepare(state))) | 85 | if ((error = pm_ops->prepare(state))) |
72 | goto Thaw; | 86 | goto Thaw; |
@@ -194,7 +208,7 @@ int software_suspend(void) | |||
194 | 208 | ||
195 | int pm_suspend(suspend_state_t state) | 209 | int pm_suspend(suspend_state_t state) |
196 | { | 210 | { |
197 | if (state > PM_SUSPEND_ON && state < PM_SUSPEND_MAX) | 211 | if (state > PM_SUSPEND_ON && state <= PM_SUSPEND_MAX) |
198 | return enter_state(state); | 212 | return enter_state(state); |
199 | return -EINVAL; | 213 | return -EINVAL; |
200 | } | 214 | } |