Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 42727
b: refs/heads/master
c: a6d7098
h: refs/heads/master
i:
  42725: e18f19c
  42723: 2dc69c8
  42719: 9be5602
v: v3
  • Loading branch information
Stephen Hemminger authored and Linus Torvalds committed Dec 7, 2006
1 parent ae48d17 commit e8c207e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 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: 3eb1b3a40722cbb46631db373af66d13d1e7ac81
refs/heads/master: a6d70980602e6f1869ebcdcbfaf55a0a5941583e
16 changes: 8 additions & 8 deletions trunk/kernel/power/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ static int software_resume(void)
{
int error;

down(&pm_sem);
mutex_lock(&pm_mutex);
if (!swsusp_resume_device) {
if (!strlen(resume_file)) {
up(&pm_sem);
mutex_unlock(&pm_mutex);
return -ENOENT;
}
swsusp_resume_device = name_to_dev_t(resume_file);
Expand All @@ -231,7 +231,7 @@ static int software_resume(void)
* FIXME: If noresume is specified, we need to find the partition
* and reset it back to normal swap space.
*/
up(&pm_sem);
mutex_unlock(&pm_mutex);
return 0;
}

Expand Down Expand Up @@ -275,7 +275,7 @@ static int software_resume(void)
unprepare_processes();
Done:
/* For success case, the suspend path will release the lock */
up(&pm_sem);
mutex_unlock(&pm_mutex);
pr_debug("PM: Resume from disk failed.\n");
return 0;
}
Expand Down Expand Up @@ -336,7 +336,7 @@ static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n)
p = memchr(buf, '\n', n);
len = p ? p - buf : n;

down(&pm_sem);
mutex_lock(&pm_mutex);
for (i = PM_DISK_FIRMWARE; i < PM_DISK_MAX; i++) {
if (!strncmp(buf, pm_disk_modes[i], len)) {
mode = i;
Expand All @@ -360,7 +360,7 @@ static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n)

pr_debug("PM: suspend-to-disk mode set to '%s'\n",
pm_disk_modes[mode]);
up(&pm_sem);
mutex_unlock(&pm_mutex);
return error ? error : n;
}

Expand All @@ -385,9 +385,9 @@ static ssize_t resume_store(struct subsystem *subsys, const char *buf, size_t n)
if (maj != MAJOR(res) || min != MINOR(res))
goto out;

down(&pm_sem);
mutex_lock(&pm_mutex);
swsusp_resume_device = res;
up(&pm_sem);
mutex_unlock(&pm_mutex);
printk("Attempting manual resume\n");
noresume = 0;
software_resume();
Expand Down
10 changes: 5 additions & 5 deletions trunk/kernel/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/*This is just an arbitrary number */
#define FREE_PAGE_NUMBER (100)

DECLARE_MUTEX(pm_sem);
DEFINE_MUTEX(pm_mutex);

struct pm_ops *pm_ops;
suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;
Expand All @@ -37,9 +37,9 @@ suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;

void pm_set_ops(struct pm_ops * ops)
{
down(&pm_sem);
mutex_lock(&pm_mutex);
pm_ops = ops;
up(&pm_sem);
mutex_unlock(&pm_mutex);
}


Expand Down Expand Up @@ -183,7 +183,7 @@ static int enter_state(suspend_state_t state)

if (!valid_state(state))
return -ENODEV;
if (down_trylock(&pm_sem))
if (!mutex_trylock(&pm_mutex))
return -EBUSY;

if (state == PM_SUSPEND_DISK) {
Expand All @@ -201,7 +201,7 @@ static int enter_state(suspend_state_t state)
pr_debug("PM: Finishing wakeup.\n");
suspend_finish(state);
Unlock:
up(&pm_sem);
mutex_unlock(&pm_mutex);
return error;
}

Expand Down
4 changes: 3 additions & 1 deletion trunk/kernel/power/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ static inline int pm_suspend_disk(void)
return -EPERM;
}
#endif
extern struct semaphore pm_sem;

extern struct mutex pm_mutex;

#define power_attr(_name) \
static struct subsys_attribute _name##_attr = { \
.attr = { \
Expand Down
24 changes: 12 additions & 12 deletions trunk/kernel/power/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ static int snapshot_release(struct inode *inode, struct file *filp)
free_all_swap_pages(data->swap, data->bitmap);
free_bitmap(data->bitmap);
if (data->frozen) {
down(&pm_sem);
mutex_lock(&pm_mutex);
thaw_processes();
enable_nonboot_cpus();
up(&pm_sem);
mutex_unlock(&pm_mutex);
}
atomic_inc(&device_available);
return 0;
Expand Down Expand Up @@ -144,7 +144,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
case SNAPSHOT_FREEZE:
if (data->frozen)
break;
down(&pm_sem);
mutex_lock(&pm_mutex);
error = disable_nonboot_cpus();
if (!error) {
error = freeze_processes();
Expand All @@ -154,18 +154,18 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
error = -EBUSY;
}
}
up(&pm_sem);
mutex_unlock(&pm_mutex);
if (!error)
data->frozen = 1;
break;

case SNAPSHOT_UNFREEZE:
if (!data->frozen)
break;
down(&pm_sem);
mutex_lock(&pm_mutex);
thaw_processes();
enable_nonboot_cpus();
up(&pm_sem);
mutex_unlock(&pm_mutex);
data->frozen = 0;
break;

Expand All @@ -174,7 +174,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
error = -EPERM;
break;
}
down(&pm_sem);
mutex_lock(&pm_mutex);
/* Free memory before shutting down devices. */
error = swsusp_shrink_memory();
if (!error) {
Expand All @@ -187,7 +187,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
}
resume_console();
}
up(&pm_sem);
mutex_unlock(&pm_mutex);
if (!error)
error = put_user(in_suspend, (unsigned int __user *)arg);
if (!error)
Expand All @@ -201,7 +201,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
error = -EPERM;
break;
}
down(&pm_sem);
mutex_lock(&pm_mutex);
pm_prepare_console();
suspend_console();
error = device_suspend(PMSG_PRETHAW);
Expand All @@ -211,7 +211,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
}
resume_console();
pm_restore_console();
up(&pm_sem);
mutex_unlock(&pm_mutex);
break;

case SNAPSHOT_FREE:
Expand Down Expand Up @@ -286,7 +286,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
break;
}

if (down_trylock(&pm_sem)) {
if (!mutex_trylock(&pm_mutex)) {
error = -EBUSY;
break;
}
Expand Down Expand Up @@ -314,7 +314,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
pm_ops->finish(PM_SUSPEND_MEM);

OutS3:
up(&pm_sem);
mutex_unlock(&pm_mutex);
break;

case SNAPSHOT_PMOPS:
Expand Down

0 comments on commit e8c207e

Please sign in to comment.