aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/power/main.c26
-rw-r--r--include/linux/pm.h1
2 files changed, 3 insertions, 24 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 15e6a8f951f1..0d2e101e4f15 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -30,23 +30,6 @@ LIST_HEAD(dpm_off_irq);
30DECLARE_MUTEX(dpm_sem); 30DECLARE_MUTEX(dpm_sem);
31DECLARE_MUTEX(dpm_list_sem); 31DECLARE_MUTEX(dpm_list_sem);
32 32
33/*
34 * PM Reference Counting.
35 */
36
37static inline void device_pm_hold(struct device * dev)
38{
39 if (dev)
40 atomic_inc(&dev->power.pm_users);
41}
42
43static inline void device_pm_release(struct device * dev)
44{
45 if (dev)
46 atomic_dec(&dev->power.pm_users);
47}
48
49
50/** 33/**
51 * device_pm_set_parent - Specify power dependency. 34 * device_pm_set_parent - Specify power dependency.
52 * @dev: Device who needs power. 35 * @dev: Device who needs power.
@@ -62,10 +45,8 @@ static inline void device_pm_release(struct device * dev)
62 45
63void device_pm_set_parent(struct device * dev, struct device * parent) 46void device_pm_set_parent(struct device * dev, struct device * parent)
64{ 47{
65 struct device * old_parent = dev->power.pm_parent; 48 put_device(dev->power.pm_parent);
66 device_pm_release(old_parent); 49 dev->power.pm_parent = get_device(parent);
67 dev->power.pm_parent = parent;
68 device_pm_hold(parent);
69} 50}
70EXPORT_SYMBOL_GPL(device_pm_set_parent); 51EXPORT_SYMBOL_GPL(device_pm_set_parent);
71 52
@@ -75,7 +56,6 @@ int device_pm_add(struct device * dev)
75 56
76 pr_debug("PM: Adding info for %s:%s\n", 57 pr_debug("PM: Adding info for %s:%s\n",
77 dev->bus ? dev->bus->name : "No Bus", dev->kobj.name); 58 dev->bus ? dev->bus->name : "No Bus", dev->kobj.name);
78 atomic_set(&dev->power.pm_users, 0);
79 down(&dpm_list_sem); 59 down(&dpm_list_sem);
80 list_add_tail(&dev->power.entry, &dpm_active); 60 list_add_tail(&dev->power.entry, &dpm_active);
81 device_pm_set_parent(dev, dev->parent); 61 device_pm_set_parent(dev, dev->parent);
@@ -91,7 +71,7 @@ void device_pm_remove(struct device * dev)
91 dev->bus ? dev->bus->name : "No Bus", dev->kobj.name); 71 dev->bus ? dev->bus->name : "No Bus", dev->kobj.name);
92 down(&dpm_list_sem); 72 down(&dpm_list_sem);
93 dpm_sysfs_remove(dev); 73 dpm_sysfs_remove(dev);
94 device_pm_release(dev->power.pm_parent); 74 put_device(dev->power.pm_parent);
95 list_del_init(&dev->power.entry); 75 list_del_init(&dev->power.entry);
96 up(&dpm_list_sem); 76 up(&dpm_list_sem);
97} 77}
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 7897cf500c51..83bae1cbe55b 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -224,7 +224,6 @@ struct dev_pm_info {
224 unsigned should_wakeup:1; 224 unsigned should_wakeup:1;
225 pm_message_t prev_state; 225 pm_message_t prev_state;
226 void * saved_state; 226 void * saved_state;
227 atomic_t pm_users;
228 struct device * pm_parent; 227 struct device * pm_parent;
229 struct list_head entry; 228 struct list_head entry;
230#endif 229#endif