diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2008-08-07 13:06:12 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-08-21 13:15:36 -0400 |
commit | 3b98aeaf3a75f544dc945694f4fcf6e1c4bab89d (patch) | |
tree | bebaa8c3353ba9e7d5142dc73c767dc030bca7e3 /drivers/base | |
parent | 7c2250352e11bf956c4cfa20b01ae6ba72882788 (diff) |
PM: don't skip device PM init when CONFIG_PM_SLEEP isn't set and CONFIG_PM is set
This patch (as1124) fixes a couple of bugs in the PM core. The new
dev->power.status field should be initialized regardless of whether
CONFIG_PM_SLEEP is enabled, and similarly dpm_sysfs_add() should be
called whenever CONFIG_PM is enabled.
The patch separates out the call to dpm_sysfs_add() from the call to
device_pm_add(). As a result device_pm_add() can no longer return an
error, so its return type is changed to void.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Romit Dasgupta <romit@ti.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/core.c | 9 | ||||
-rw-r--r-- | drivers/base/power/main.c | 13 | ||||
-rw-r--r-- | drivers/base/power/power.h | 9 |
3 files changed, 16 insertions, 15 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 44bad73d8192..40041319657d 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -541,6 +541,7 @@ void device_initialize(struct device *dev) | |||
541 | spin_lock_init(&dev->devres_lock); | 541 | spin_lock_init(&dev->devres_lock); |
542 | INIT_LIST_HEAD(&dev->devres_head); | 542 | INIT_LIST_HEAD(&dev->devres_head); |
543 | device_init_wakeup(dev, 0); | 543 | device_init_wakeup(dev, 0); |
544 | device_pm_init(dev); | ||
544 | set_dev_node(dev, -1); | 545 | set_dev_node(dev, -1); |
545 | } | 546 | } |
546 | 547 | ||
@@ -897,9 +898,10 @@ int device_add(struct device *dev) | |||
897 | error = bus_add_device(dev); | 898 | error = bus_add_device(dev); |
898 | if (error) | 899 | if (error) |
899 | goto BusError; | 900 | goto BusError; |
900 | error = device_pm_add(dev); | 901 | error = dpm_sysfs_add(dev); |
901 | if (error) | 902 | if (error) |
902 | goto PMError; | 903 | goto DPMError; |
904 | device_pm_add(dev); | ||
903 | kobject_uevent(&dev->kobj, KOBJ_ADD); | 905 | kobject_uevent(&dev->kobj, KOBJ_ADD); |
904 | bus_attach_device(dev); | 906 | bus_attach_device(dev); |
905 | if (parent) | 907 | if (parent) |
@@ -920,7 +922,7 @@ int device_add(struct device *dev) | |||
920 | Done: | 922 | Done: |
921 | put_device(dev); | 923 | put_device(dev); |
922 | return error; | 924 | return error; |
923 | PMError: | 925 | DPMError: |
924 | bus_remove_device(dev); | 926 | bus_remove_device(dev); |
925 | BusError: | 927 | BusError: |
926 | if (dev->bus) | 928 | if (dev->bus) |
@@ -1007,6 +1009,7 @@ void device_del(struct device *dev) | |||
1007 | struct class_interface *class_intf; | 1009 | struct class_interface *class_intf; |
1008 | 1010 | ||
1009 | device_pm_remove(dev); | 1011 | device_pm_remove(dev); |
1012 | dpm_sysfs_remove(dev); | ||
1010 | if (parent) | 1013 | if (parent) |
1011 | klist_del(&dev->knode_parent); | 1014 | klist_del(&dev->knode_parent); |
1012 | if (MAJOR(dev->devt)) { | 1015 | if (MAJOR(dev->devt)) { |
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 3250c5257b74..284f564bb12b 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -67,10 +67,8 @@ void device_pm_unlock(void) | |||
67 | * device_pm_add - add a device to the list of active devices | 67 | * device_pm_add - add a device to the list of active devices |
68 | * @dev: Device to be added to the list | 68 | * @dev: Device to be added to the list |
69 | */ | 69 | */ |
70 | int device_pm_add(struct device *dev) | 70 | void device_pm_add(struct device *dev) |
71 | { | 71 | { |
72 | int error; | ||
73 | |||
74 | pr_debug("PM: Adding info for %s:%s\n", | 72 | pr_debug("PM: Adding info for %s:%s\n", |
75 | dev->bus ? dev->bus->name : "No Bus", | 73 | dev->bus ? dev->bus->name : "No Bus", |
76 | kobject_name(&dev->kobj)); | 74 | kobject_name(&dev->kobj)); |
@@ -89,13 +87,9 @@ int device_pm_add(struct device *dev) | |||
89 | */ | 87 | */ |
90 | WARN_ON(true); | 88 | WARN_ON(true); |
91 | } | 89 | } |
92 | error = dpm_sysfs_add(dev); | 90 | |
93 | if (!error) { | 91 | list_add_tail(&dev->power.entry, &dpm_list); |
94 | dev->power.status = DPM_ON; | ||
95 | list_add_tail(&dev->power.entry, &dpm_list); | ||
96 | } | ||
97 | mutex_unlock(&dpm_list_mtx); | 92 | mutex_unlock(&dpm_list_mtx); |
98 | return error; | ||
99 | } | 93 | } |
100 | 94 | ||
101 | /** | 95 | /** |
@@ -110,7 +104,6 @@ void device_pm_remove(struct device *dev) | |||
110 | dev->bus ? dev->bus->name : "No Bus", | 104 | dev->bus ? dev->bus->name : "No Bus", |
111 | kobject_name(&dev->kobj)); | 105 | kobject_name(&dev->kobj)); |
112 | mutex_lock(&dpm_list_mtx); | 106 | mutex_lock(&dpm_list_mtx); |
113 | dpm_sysfs_remove(dev); | ||
114 | list_del_init(&dev->power.entry); | 107 | list_del_init(&dev->power.entry); |
115 | mutex_unlock(&dpm_list_mtx); | 108 | mutex_unlock(&dpm_list_mtx); |
116 | } | 109 | } |
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index a3252c0e2887..41f51fae042f 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h | |||
@@ -1,3 +1,8 @@ | |||
1 | static inline void device_pm_init(struct device *dev) | ||
2 | { | ||
3 | dev->power.status = DPM_ON; | ||
4 | } | ||
5 | |||
1 | #ifdef CONFIG_PM_SLEEP | 6 | #ifdef CONFIG_PM_SLEEP |
2 | 7 | ||
3 | /* | 8 | /* |
@@ -11,12 +16,12 @@ static inline struct device *to_device(struct list_head *entry) | |||
11 | return container_of(entry, struct device, power.entry); | 16 | return container_of(entry, struct device, power.entry); |
12 | } | 17 | } |
13 | 18 | ||
14 | extern int device_pm_add(struct device *); | 19 | extern void device_pm_add(struct device *); |
15 | extern void device_pm_remove(struct device *); | 20 | extern void device_pm_remove(struct device *); |
16 | 21 | ||
17 | #else /* CONFIG_PM_SLEEP */ | 22 | #else /* CONFIG_PM_SLEEP */ |
18 | 23 | ||
19 | static inline int device_pm_add(struct device *dev) { return 0; } | 24 | static inline void device_pm_add(struct device *dev) {} |
20 | static inline void device_pm_remove(struct device *dev) {} | 25 | static inline void device_pm_remove(struct device *dev) {} |
21 | 26 | ||
22 | #endif | 27 | #endif |