diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-12 16:04:50 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-12 16:04:50 -0700 |
commit | 3f603ed319d5120e883e64ac5967b2fc848fc43b (patch) | |
tree | 52ef311c245e4e4cd623b546ea1daf05a5ea8911 /kernel | |
parent | 55ee3b8365fd5d301b9076eea739146f2b91e82c (diff) | |
parent | 5028770a42e7bc4d15791a44c28f0ad539323807 (diff) | |
download | kernel_samsung_smdk4412-3f603ed319d5120e883e64ac5967b2fc848fc43b.tar.gz kernel_samsung_smdk4412-3f603ed319d5120e883e64ac5967b2fc848fc43b.tar.bz2 kernel_samsung_smdk4412-3f603ed319d5120e883e64ac5967b2fc848fc43b.zip |
Merge master.kernel.org:/pub/scm/linux/kernel/git/lenb/linux-2.6
Diffstat (limited to 'kernel')
-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 c94cb9e9509..71aa0fd2200 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -19,6 +19,9 @@ #include "power.h" +/*This is just an arbitrary number */ +#define FREE_PAGE_NUMBER (100) + DECLARE_MUTEX(pm_sem); struct pm_ops * pm_ops = NULL; @@ -49,6 +52,7 @@ void pm_set_ops(struct pm_ops * ops) static int suspend_prepare(suspend_state_t state) { int error = 0; + unsigned int free_pages; if (!pm_ops || !pm_ops->enter) return -EPERM; @@ -67,6 +71,16 @@ static int suspend_prepare(suspend_state_t state) goto Thaw; } + if ((free_pages = nr_free_pages()) < FREE_PAGE_NUMBER) { + pr_debug("PM: free some memory\n"); + shrink_all_memory(FREE_PAGE_NUMBER - free_pages); + if (nr_free_pages() < FREE_PAGE_NUMBER) { + error = -ENOMEM; + printk(KERN_ERR "PM: No enough memory\n"); + goto Thaw; + } + } + if (pm_ops->prepare) { if ((error = pm_ops->prepare(state))) goto Thaw; @@ -194,7 +208,7 @@ int software_suspend(void) int pm_suspend(suspend_state_t state) { - if (state > PM_SUSPEND_ON && state < PM_SUSPEND_MAX) + if (state > PM_SUSPEND_ON && state <= PM_SUSPEND_MAX) return enter_state(state); return -EINVAL; } |