mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
drivers: core: device: set new parent when old parent is NULL
The current logic does not update the new parent in device_reparent() if
old parent is NULL. The behavior is not desired. Fix it by setting the
parent in this case.
Fixes: cfecbaf4e7 ("dm: core: add support for device re-parenting")
Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
This commit is contained in:
@@ -285,6 +285,14 @@ int device_reparent(struct udevice *dev, struct udevice *new_parent)
|
||||
assert(dev);
|
||||
assert(new_parent);
|
||||
|
||||
if (!dev->parent) {
|
||||
assert(list_empty(&dev->sibling_node));
|
||||
|
||||
list_add_tail(&dev->sibling_node, &new_parent->child_head);
|
||||
dev->parent = new_parent;
|
||||
return 0;
|
||||
}
|
||||
|
||||
device_foreach_child_safe(pos, n, dev->parent) {
|
||||
if (pos->driver != dev->driver)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user