Driver core: Fix device_move() vs. dpm list ordering, v2
[deliverable/linux.git] / drivers / base / power / main.c
index 2d14f4ae6c01da28be636629db5e50b9205b5699..e255341682c88d4a0955f1151595c1334e005dd5 100644 (file)
@@ -106,6 +106,50 @@ void device_pm_remove(struct device *dev)
        mutex_unlock(&dpm_list_mtx);
 }
 
+/**
+ *     device_pm_move_before - move device in dpm_list
+ *     @deva:  Device to move in dpm_list
+ *     @devb:  Device @deva should come before
+ */
+void device_pm_move_before(struct device *deva, struct device *devb)
+{
+       pr_debug("PM: Moving %s:%s before %s:%s\n",
+                deva->bus ? deva->bus->name : "No Bus",
+                kobject_name(&deva->kobj),
+                devb->bus ? devb->bus->name : "No Bus",
+                kobject_name(&devb->kobj));
+       /* Delete deva from dpm_list and reinsert before devb. */
+       list_move_tail(&deva->power.entry, &devb->power.entry);
+}
+
+/**
+ *     device_pm_move_after - move device in dpm_list
+ *     @deva:  Device to move in dpm_list
+ *     @devb:  Device @deva should come after
+ */
+void device_pm_move_after(struct device *deva, struct device *devb)
+{
+       pr_debug("PM: Moving %s:%s after %s:%s\n",
+                deva->bus ? deva->bus->name : "No Bus",
+                kobject_name(&deva->kobj),
+                devb->bus ? devb->bus->name : "No Bus",
+                kobject_name(&devb->kobj));
+       /* Delete deva from dpm_list and reinsert after devb. */
+       list_move(&deva->power.entry, &devb->power.entry);
+}
+
+/**
+ *     device_pm_move_last - move device to end of dpm_list
+ *     @dev:   Device to move in dpm_list
+ */
+void device_pm_move_last(struct device *dev)
+{
+       pr_debug("PM: Moving %s:%s to end of list\n",
+                dev->bus ? dev->bus->name : "No Bus",
+                kobject_name(&dev->kobj));
+       list_move_tail(&dev->power.entry, &dpm_list);
+}
+
 /**
  *     pm_op - execute the PM operation appropiate for given PM event
  *     @dev:   Device.
This page took 0.039915 seconds and 5 git commands to generate.