From c841acb0647bafed95ef1433477f996db4ba0f18 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Wed, 20 Aug 2003 22:48:57 -0700 Subject: [PATCH] [power] Fix locking in device_{suspend,resume} We don't need to protect against multiple suspend calls, since subsequent ones will happen on an empty (or at worst - short) list. --- drivers/base/power/resume.c | 4 +++- drivers/base/power/suspend.c | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/base/power/resume.c b/drivers/base/power/resume.c index 19c6387fec408..9db84a9e41e3e 100644 --- a/drivers/base/power/resume.c +++ b/drivers/base/power/resume.c @@ -31,11 +31,13 @@ int resume_device(struct device * dev) /** * device_resume - Restore state of each device in system. * - * Restore normal device state and release the dpm_sem. + * Walk the dpm_off list, remove each entry, resume the device, + * then add it to the dpm_active list. */ void device_resume(void) { + down(&dpm_sem); while(!list_empty(&dpm_off)) { struct list_head * entry = dpm_off.next; struct device * dev = to_device(entry); diff --git a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c index e9ca633fc1290..6da8cdd69dce0 100644 --- a/drivers/base/power/suspend.c +++ b/drivers/base/power/suspend.c @@ -71,9 +71,6 @@ int suspend_device(struct device * dev, u32 state) * b) prevent other PM operations from happening after we've begun. * c) make sure we're exclusive when we disable interrupts. * - * device_resume() will release dpm_sem after restoring state to - * all devices (as will this on error). You must call it once you've - * called device_suspend(). */ int device_suspend(u32 state) @@ -88,6 +85,7 @@ int device_suspend(u32 state) goto Error; } Done: + up(&dpm_sem); return error; Error: device_resume(); -- 2.53.0