diff options
author | Simon Glass <sjg@chromium.org> | 2014-07-23 06:55:21 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2014-07-23 14:08:37 +0100 |
commit | a327dee0f40bcdebaba1a3e47f2b9f1ceb970d2a (patch) | |
tree | 20ba09ee61b51416bc86808abf7315fe6266e1ed /drivers | |
parent | e59f458de6999b8a786da857e653db6777f675ca (diff) |
dm: Add child_pre_probe() and child_post_remove() methods
Some devices (particularly bus devices) must track their children, knowing
when a new child is added so that it can be set up for communication on the
bus.
Add a child_pre_probe() method to provide this feature, and a corresponding
child_post_remove() method.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/core/device.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c index 42d250f4a4..166b0732ab 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -291,6 +291,12 @@ int device_probe(struct udevice *dev) } dev->seq = seq; + if (dev->parent && dev->parent->driver->child_pre_probe) { + ret = dev->parent->driver->child_pre_probe(dev); + if (ret) + goto fail; + } + if (drv->ofdata_to_platdata && dev->of_offset >= 0) { ret = drv->ofdata_to_platdata(dev); if (ret) @@ -352,12 +358,20 @@ int device_remove(struct udevice *dev) goto err_remove; } + if (dev->parent && dev->parent->driver->child_post_remove) { + ret = dev->parent->driver->child_post_remove(dev); + if (ret) { + dm_warn("%s: Device '%s' failed child_post_remove()", + __func__, dev->name); + } + } + device_free(dev); dev->seq = -1; dev->flags &= ~DM_FLAG_ACTIVATED; - return 0; + return ret; err_remove: /* We can't put the children back */ |