aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/power/main.c')
-rw-r--r--drivers/base/power/main.c30
1 files changed, 4 insertions, 26 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}