Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 4712
b: refs/heads/master
c: 5ae947e
h: refs/heads/master
v: v3
  • Loading branch information
David Shaohua Li authored and Len Brown committed Jul 12, 2005
1 parent d0d70b2 commit fb30db4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e2a5b420f716cd1a46674b1a90389612eced916f
refs/heads/master: 5ae947ecc9c1c23834201e5321684a5cb68bdd3f
14 changes: 14 additions & 0 deletions trunk/kernel/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -60,6 +64,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;
Expand Down

0 comments on commit fb30db4

Please sign in to comment.