aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/power/main.c30
-rw-r--r--drivers/base/power/resume.c7
-rw-r--r--drivers/base/power/suspend.c7
3 files changed, 10 insertions, 34 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 7b3cc3c15b9d..eb9f38d0aa58 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -33,28 +33,7 @@ DEFINE_MUTEX(dpm_list_mtx);
33 33
34int (*platform_enable_wakeup)(struct device *dev, int is_on); 34int (*platform_enable_wakeup)(struct device *dev, int is_on);
35 35
36 36int device_pm_add(struct device *dev)
37/**
38 * device_pm_set_parent - Specify power dependency.
39 * @dev: Device who needs power.
40 * @parent: Device that supplies power.
41 *
42 * This function is used to manually describe a power-dependency
43 * relationship. It may be used to specify a transversal relationship
44 * (where the power supplier is not the physical (or electrical)
45 * ancestor of a specific device.
46 * The effect of this is that the supplier will not be powered down
47 * before the power dependent.
48 */
49
50void device_pm_set_parent(struct device * dev, struct device * parent)
51{
52 put_device(dev->power.pm_parent);
53 dev->power.pm_parent = get_device(parent);
54}
55EXPORT_SYMBOL_GPL(device_pm_set_parent);
56
57int device_pm_add(struct device * dev)
58{ 37{
59 int error; 38 int error;
60 39
@@ -63,21 +42,20 @@ int device_pm_add(struct device * dev)
63 kobject_name(&dev->kobj)); 42 kobject_name(&dev->kobj));
64 mutex_lock(&dpm_list_mtx); 43 mutex_lock(&dpm_list_mtx);
65 list_add_tail(&dev->power.entry, &dpm_active); 44 list_add_tail(&dev->power.entry, &dpm_active);
66 device_pm_set_parent(dev, dev->parent); 45 error = dpm_sysfs_add(dev);
67 if ((error = dpm_sysfs_add(dev))) 46 if (error)
68 list_del(&dev->power.entry); 47 list_del(&dev->power.entry);
69 mutex_unlock(&dpm_list_mtx); 48 mutex_unlock(&dpm_list_mtx);
70 return error; 49 return error;
71} 50}
72 51
73void device_pm_remove(struct device * dev) 52void device_pm_remove(struct device *dev)
74{ 53{
75 pr_debug("PM: Removing info for %s:%s\n", 54 pr_debug("PM: Removing info for %s:%s\n",
76 dev->bus ? dev->bus->name : "No Bus", 55 dev->bus ? dev->bus->name : "No Bus",
77 kobject_name(&dev->kobj)); 56 kobject_name(&dev->kobj));
78 mutex_lock(&dpm_list_mtx); 57 mutex_lock(&dpm_list_mtx);
79 dpm_sysfs_remove(dev); 58 dpm_sysfs_remove(dev);
80 put_device(dev->power.pm_parent);
81 list_del_init(&dev->power.entry); 59 list_del_init(&dev->power.entry);
82 mutex_unlock(&dpm_list_mtx); 60 mutex_unlock(&dpm_list_mtx);
83} 61}
diff --git a/drivers/base/power/resume.c b/drivers/base/power/resume.c
index f6cfea496ea0..99679e7a6cc6 100644
--- a/drivers/base/power/resume.c
+++ b/drivers/base/power/resume.c
@@ -29,12 +29,11 @@ int resume_device(struct device * dev)
29 29
30 down(&dev->sem); 30 down(&dev->sem);
31 31
32 if (dev->power.pm_parent 32 if (dev->parent && dev->parent->power.power_state.event) {
33 && dev->power.pm_parent->power.power_state.event) {
34 dev_err(dev, "PM: resume from %d, parent %s still %d\n", 33 dev_err(dev, "PM: resume from %d, parent %s still %d\n",
35 dev->power.power_state.event, 34 dev->power.power_state.event,
36 dev->power.pm_parent->bus_id, 35 dev->parent->bus_id,
37 dev->power.pm_parent->power.power_state.event); 36 dev->parent->power.power_state.event);
38 } 37 }
39 38
40 if (dev->bus && dev->bus->resume) { 39 if (dev->bus && dev->bus->resume) {
diff --git a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c
index 9d6701cd7f10..19fae88de7b3 100644
--- a/drivers/base/power/suspend.c
+++ b/drivers/base/power/suspend.c
@@ -55,13 +55,12 @@ int suspend_device(struct device * dev, pm_message_t state)
55 dev_dbg(dev, "PM: suspend %d-->%d\n", 55 dev_dbg(dev, "PM: suspend %d-->%d\n",
56 dev->power.power_state.event, state.event); 56 dev->power.power_state.event, state.event);
57 } 57 }
58 if (dev->power.pm_parent 58 if (dev->parent && dev->parent->power.power_state.event) {
59 && dev->power.pm_parent->power.power_state.event) {
60 dev_err(dev, 59 dev_err(dev,
61 "PM: suspend %d->%d, parent %s already %d\n", 60 "PM: suspend %d->%d, parent %s already %d\n",
62 dev->power.power_state.event, state.event, 61 dev->power.power_state.event, state.event,
63 dev->power.pm_parent->bus_id, 62 dev->parent->bus_id,
64 dev->power.pm_parent->power.power_state.event); 63 dev->parent->power.power_state.event);
65 } 64 }
66 65
67 dev->power.prev_state = dev->power.power_state; 66 dev->power.prev_state = dev->power.power_state;