Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 14806
b: refs/heads/master
c: 123d3c1
h: refs/heads/master
v: v3
  • Loading branch information
Pavel Machek authored and Linus Torvalds committed Nov 30, 2005
1 parent 608f9e6 commit aea354c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d91b14c463306eb6527550ba48617e7f5500d3ae
refs/heads/master: 123d3c13e2853a11b4d599d754b356acb12886e2
21 changes: 16 additions & 5 deletions trunk/kernel/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

DECLARE_MUTEX(pm_sem);

struct pm_ops * pm_ops = NULL;
struct pm_ops *pm_ops;
suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;

/**
Expand Down Expand Up @@ -151,6 +151,18 @@ static char *pm_states[PM_SUSPEND_MAX] = {
#endif
};

static inline int valid_state(suspend_state_t state)
{
/* Suspend-to-disk does not really need low-level support.
* It can work with reboot if needed. */
if (state == PM_SUSPEND_DISK)
return 1;

if (pm_ops && pm_ops->valid && !pm_ops->valid(state))
return 0;
return 1;
}


/**
* enter_state - Do common work of entering low-power state.
Expand All @@ -167,7 +179,7 @@ static int enter_state(suspend_state_t state)
{
int error;

if (pm_ops && pm_ops->valid && !pm_ops->valid(state))
if (!valid_state(state))
return -ENODEV;
if (down_trylock(&pm_sem))
return -EBUSY;
Expand Down Expand Up @@ -238,9 +250,8 @@ static ssize_t state_show(struct subsystem * subsys, char * buf)
char * s = buf;

for (i = 0; i < PM_SUSPEND_MAX; i++) {
if (pm_states[i] && pm_ops && (!pm_ops->valid
||(pm_ops->valid && pm_ops->valid(i))))
s += sprintf(s,"%s ",pm_states[i]);
if (pm_states[i] && valid_state(i))
s += sprintf(s,"%s ", pm_states[i]);
}
s += sprintf(s,"\n");
return (s - buf);
Expand Down

0 comments on commit aea354c

Please sign in to comment.