PM: Remove redundant checks from core device resume routines

Since a separate list of devices is used to link devices that have
completed each stage of suspend (or resume), it is not necessary to
check dev->power.status in the core device resume routines any more.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
This commit is contained in:
Rafael J. Wysocki 2010-12-16 00:51:08 +01:00
parent 8a43a9ab7b
commit 5b219a51fd
1 changed files with 17 additions and 27 deletions

View File

@ -485,22 +485,18 @@ void dpm_resume_noirq(pm_message_t state)
transition_started = false; transition_started = false;
while (!list_empty(&dpm_noirq_list)) { while (!list_empty(&dpm_noirq_list)) {
struct device *dev = to_device(dpm_noirq_list.next); struct device *dev = to_device(dpm_noirq_list.next);
int error;
get_device(dev); get_device(dev);
if (dev->power.status > DPM_OFF) { dev->power.status = DPM_OFF;
int error; list_move_tail(&dev->power.entry, &dpm_suspended_list);
mutex_unlock(&dpm_list_mtx);
dev->power.status = DPM_OFF; error = device_resume_noirq(dev, state);
mutex_unlock(&dpm_list_mtx); if (error)
pm_dev_err(dev, state, " early", error);
error = device_resume_noirq(dev, state); mutex_lock(&dpm_list_mtx);
mutex_lock(&dpm_list_mtx);
if (error)
pm_dev_err(dev, state, " early", error);
}
if (!list_empty(&dev->power.entry))
list_move_tail(&dev->power.entry, &dpm_suspended_list);
put_device(dev); put_device(dev);
} }
mutex_unlock(&dpm_list_mtx); mutex_unlock(&dpm_list_mtx);
@ -619,9 +615,6 @@ static void dpm_resume(pm_message_t state)
async_error = 0; async_error = 0;
list_for_each_entry(dev, &dpm_suspended_list, power.entry) { list_for_each_entry(dev, &dpm_suspended_list, power.entry) {
if (dev->power.status < DPM_OFF)
continue;
INIT_COMPLETION(dev->power.completion); INIT_COMPLETION(dev->power.completion);
if (is_async(dev)) { if (is_async(dev)) {
get_device(dev); get_device(dev);
@ -632,16 +625,16 @@ static void dpm_resume(pm_message_t state)
while (!list_empty(&dpm_suspended_list)) { while (!list_empty(&dpm_suspended_list)) {
dev = to_device(dpm_suspended_list.next); dev = to_device(dpm_suspended_list.next);
get_device(dev); get_device(dev);
if (dev->power.status >= DPM_OFF && !is_async(dev)) { if (!is_async(dev)) {
int error; int error;
mutex_unlock(&dpm_list_mtx); mutex_unlock(&dpm_list_mtx);
error = device_resume(dev, state, false); error = device_resume(dev, state, false);
mutex_lock(&dpm_list_mtx);
if (error) if (error)
pm_dev_err(dev, state, "", error); pm_dev_err(dev, state, "", error);
mutex_lock(&dpm_list_mtx);
} }
if (!list_empty(&dev->power.entry)) if (!list_empty(&dev->power.entry))
list_move_tail(&dev->power.entry, &dpm_prepared_list); list_move_tail(&dev->power.entry, &dpm_prepared_list);
@ -697,17 +690,14 @@ static void dpm_complete(pm_message_t state)
struct device *dev = to_device(dpm_prepared_list.prev); struct device *dev = to_device(dpm_prepared_list.prev);
get_device(dev); get_device(dev);
if (dev->power.status > DPM_ON) { dev->power.status = DPM_ON;
dev->power.status = DPM_ON; list_move(&dev->power.entry, &list);
mutex_unlock(&dpm_list_mtx); mutex_unlock(&dpm_list_mtx);
device_complete(dev, state); device_complete(dev, state);
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
mutex_lock(&dpm_list_mtx); mutex_lock(&dpm_list_mtx);
}
if (!list_empty(&dev->power.entry))
list_move(&dev->power.entry, &list);
put_device(dev); put_device(dev);
} }
list_splice(&list, &dpm_list); list_splice(&list, &dpm_list);