aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2010-12-15 18:51:21 -0500
committerRafael J. Wysocki <rjw@sisk.pl>2010-12-24 09:02:44 -0500
commitb8c76f6aed0ab7df73a6410f3f82de2c831bb144 (patch)
tree1194ded4c23f62ab253a2e0712cfdd436aa2365b /drivers/base
parent5b219a51fdceaf76e0e18da57c7efb9e5586e567 (diff)
PM: Replace the device power.status field with a bit field
The device power.status field is too complicated for its purpose (storing the information about whether or not the device is in the "active" state from the PM core's point of view), so replace it with a bit field and modify all of its users accordingly. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/power/main.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index bb5c8cb64174..a90480baa850 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -63,7 +63,7 @@ static int async_error;
63 */ 63 */
64void device_pm_init(struct device *dev) 64void device_pm_init(struct device *dev)
65{ 65{
66 dev->power.status = DPM_ON; 66 dev->power.in_suspend = false;
67 init_completion(&dev->power.completion); 67 init_completion(&dev->power.completion);
68 complete_all(&dev->power.completion); 68 complete_all(&dev->power.completion);
69 dev->power.wakeup = NULL; 69 dev->power.wakeup = NULL;
@@ -98,7 +98,7 @@ void device_pm_add(struct device *dev)
98 kobject_name(&dev->kobj)); 98 kobject_name(&dev->kobj));
99 mutex_lock(&dpm_list_mtx); 99 mutex_lock(&dpm_list_mtx);
100 if (dev->parent) { 100 if (dev->parent) {
101 if (dev->parent->power.status >= DPM_SUSPENDING) 101 if (dev->parent->power.in_suspend)
102 dev_warn(dev, "parent %s should not be sleeping\n", 102 dev_warn(dev, "parent %s should not be sleeping\n",
103 dev_name(dev->parent)); 103 dev_name(dev->parent));
104 } else if (transition_started) { 104 } else if (transition_started) {
@@ -488,7 +488,6 @@ void dpm_resume_noirq(pm_message_t state)
488 int error; 488 int error;
489 489
490 get_device(dev); 490 get_device(dev);
491 dev->power.status = DPM_OFF;
492 list_move_tail(&dev->power.entry, &dpm_suspended_list); 491 list_move_tail(&dev->power.entry, &dpm_suspended_list);
493 mutex_unlock(&dpm_list_mtx); 492 mutex_unlock(&dpm_list_mtx);
494 493
@@ -541,7 +540,7 @@ static int device_resume(struct device *dev, pm_message_t state, bool async)
541 dpm_wait(dev->parent, async); 540 dpm_wait(dev->parent, async);
542 device_lock(dev); 541 device_lock(dev);
543 542
544 dev->power.status = DPM_RESUMING; 543 dev->power.in_suspend = false;
545 544
546 if (dev->bus) { 545 if (dev->bus) {
547 if (dev->bus->pm) { 546 if (dev->bus->pm) {
@@ -690,7 +689,7 @@ static void dpm_complete(pm_message_t state)
690 struct device *dev = to_device(dpm_prepared_list.prev); 689 struct device *dev = to_device(dpm_prepared_list.prev);
691 690
692 get_device(dev); 691 get_device(dev);
693 dev->power.status = DPM_ON; 692 dev->power.in_suspend = false;
694 list_move(&dev->power.entry, &list); 693 list_move(&dev->power.entry, &list);
695 mutex_unlock(&dpm_list_mtx); 694 mutex_unlock(&dpm_list_mtx);
696 695
@@ -806,7 +805,6 @@ int dpm_suspend_noirq(pm_message_t state)
806 put_device(dev); 805 put_device(dev);
807 break; 806 break;
808 } 807 }
809 dev->power.status = DPM_OFF_IRQ;
810 if (!list_empty(&dev->power.entry)) 808 if (!list_empty(&dev->power.entry))
811 list_move(&dev->power.entry, &dpm_noirq_list); 809 list_move(&dev->power.entry, &dpm_noirq_list);
812 put_device(dev); 810 put_device(dev);
@@ -894,9 +892,6 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
894 } 892 }
895 } 893 }
896 894
897 if (!error)
898 dev->power.status = DPM_OFF;
899
900 End: 895 End:
901 device_unlock(dev); 896 device_unlock(dev);
902 complete_all(&dev->power.completion); 897 complete_all(&dev->power.completion);
@@ -1030,7 +1025,6 @@ static int dpm_prepare(pm_message_t state)
1030 struct device *dev = to_device(dpm_list.next); 1025 struct device *dev = to_device(dpm_list.next);
1031 1026
1032 get_device(dev); 1027 get_device(dev);
1033 dev->power.status = DPM_PREPARING;
1034 mutex_unlock(&dpm_list_mtx); 1028 mutex_unlock(&dpm_list_mtx);
1035 1029
1036 pm_runtime_get_noresume(dev); 1030 pm_runtime_get_noresume(dev);
@@ -1046,7 +1040,6 @@ static int dpm_prepare(pm_message_t state)
1046 1040
1047 mutex_lock(&dpm_list_mtx); 1041 mutex_lock(&dpm_list_mtx);
1048 if (error) { 1042 if (error) {
1049 dev->power.status = DPM_ON;
1050 if (error == -EAGAIN) { 1043 if (error == -EAGAIN) {
1051 put_device(dev); 1044 put_device(dev);
1052 error = 0; 1045 error = 0;
@@ -1058,7 +1051,7 @@ static int dpm_prepare(pm_message_t state)
1058 put_device(dev); 1051 put_device(dev);
1059 break; 1052 break;
1060 } 1053 }
1061 dev->power.status = DPM_SUSPENDING; 1054 dev->power.in_suspend = true;
1062 if (!list_empty(&dev->power.entry)) 1055 if (!list_empty(&dev->power.entry))
1063 list_move_tail(&dev->power.entry, &dpm_prepared_list); 1056 list_move_tail(&dev->power.entry, &dpm_prepared_list);
1064 put_device(dev); 1057 put_device(dev);