diff options
author | Claudiu Beznea <claudiu.beznea@microchip.com> | 2020-09-07 17:46:33 +0300 |
---|---|---|
committer | Eugen Hristev <eugen.hristev@microchip.com> | 2020-09-22 11:27:18 +0300 |
commit | cfecbaf4e768991056a88d3a7a3daf4b4baf8038 (patch) | |
tree | 5f3b366650bcddfce7ee3462417a6de3669ca57b /drivers/core/device.c | |
parent | b04da9fcf78e233e70ea5ace757c0b8b95bb2459 (diff) | |
download | u-boot-cfecbaf4e768991056a88d3a7a3daf4b4baf8038.tar.gz u-boot-cfecbaf4e768991056a88d3a7a3daf4b4baf8038.tar.xz u-boot-cfecbaf4e768991056a88d3a7a3daf4b4baf8038.zip |
dm: core: add support for device re-parenting
In common clock framework the relation b/w parent and child clocks is
determined based on the udevice parent/child information. A clock
parent could be changed based on devices needs. In case this is happen
the functionalities for clock who's parent is changed are broken. Add
a function that reparent a device. This will be used in clk-uclass.c
to reparent a clock device.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/device.c')
-rw-r--r-- | drivers/core/device.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c index 355dbd147a..e90d70101c 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -276,6 +276,28 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only, return ret; } +int device_reparent(struct udevice *dev, struct udevice *new_parent) +{ + struct udevice *pos, *n; + + assert(dev); + assert(new_parent); + + list_for_each_entry_safe(pos, n, &dev->parent->child_head, + sibling_node) { + if (pos->driver != dev->driver) + continue; + + list_del(&dev->sibling_node); + list_add_tail(&dev->sibling_node, &new_parent->child_head); + dev->parent = new_parent; + + break; + } + + return 0; +} + static void *alloc_priv(int size, uint flags) { void *priv; |