Driver core: Fix device_move() vs. dpm list ordering, v2
dpm_list currently relies on the fact that child devices will be registered after their parents to get a correct suspend order. Using device_move() however destroys this assumption, as an already registered device may be moved under a newly registered one. This patch adds a new argument to device_move(), allowing callers to specify how dpm_list should be adapted. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
60530afe1e
commit
ffa6a7054d
@@ -1561,8 +1561,10 @@ out:
|
||||
* device_move - moves a device to a new parent
|
||||
* @dev: the pointer to the struct device to be moved
|
||||
* @new_parent: the new parent of the device (can by NULL)
|
||||
* @dpm_order: how to reorder the dpm_list
|
||||
*/
|
||||
int device_move(struct device *dev, struct device *new_parent)
|
||||
int device_move(struct device *dev, struct device *new_parent,
|
||||
enum dpm_order dpm_order)
|
||||
{
|
||||
int error;
|
||||
struct device *old_parent;
|
||||
@@ -1572,6 +1574,7 @@ int device_move(struct device *dev, struct device *new_parent)
|
||||
if (!dev)
|
||||
return -EINVAL;
|
||||
|
||||
device_pm_lock();
|
||||
new_parent = get_device(new_parent);
|
||||
new_parent_kobj = get_device_parent(dev, new_parent);
|
||||
|
||||
@@ -1613,9 +1616,23 @@ int device_move(struct device *dev, struct device *new_parent)
|
||||
put_device(new_parent);
|
||||
goto out;
|
||||
}
|
||||
switch (dpm_order) {
|
||||
case DPM_ORDER_NONE:
|
||||
break;
|
||||
case DPM_ORDER_DEV_AFTER_PARENT:
|
||||
device_pm_move_after(dev, new_parent);
|
||||
break;
|
||||
case DPM_ORDER_PARENT_BEFORE_DEV:
|
||||
device_pm_move_before(new_parent, dev);
|
||||
break;
|
||||
case DPM_ORDER_DEV_LAST:
|
||||
device_pm_move_last(dev);
|
||||
break;
|
||||
}
|
||||
out_put:
|
||||
put_device(old_parent);
|
||||
out:
|
||||
device_pm_unlock();
|
||||
put_device(dev);
|
||||
return error;
|
||||
}
|
||||
|
Reference in New Issue
Block a user