summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-01-25 08:27:08 -0700
committerSimon Glass <sjg@chromium.org>2015-01-29 17:09:56 -0700
commit081f2fcbd9a95ba10677065359791f8fea3f8c58 (patch)
treeed8312d3d54e07e659a64f5b59657a147317130f /drivers
parent19a25f672c6aa1a9a9b94c0ffbfda3e8246d1a19 (diff)
downloadu-boot-imx-081f2fcbd9a95ba10677065359791f8fea3f8c58.zip
u-boot-imx-081f2fcbd9a95ba10677065359791f8fea3f8c58.tar.gz
u-boot-imx-081f2fcbd9a95ba10677065359791f8fea3f8c58.tar.bz2
dm: core: Allow the uclass to set up a device's child after binding
For buses, after a child is bound, allow the uclass to perform some processing. This can be used to figure out the address of the child (e.g. the chip select for SPI slaves) so that it is ready to be probed. This avoids bus drivers having to repeat the same process, which really should be done by the uclass, since it is common. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/uclass.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 901b06e..a544551 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -319,18 +319,29 @@ int uclass_bind_device(struct udevice *dev)
int ret;
uc = dev->uclass;
-
list_add_tail(&dev->uclass_node, &uc->dev_head);
+ if (dev->parent) {
+ struct uclass_driver *uc_drv = dev->parent->uclass->uc_drv;
+
+ if (uc_drv->child_post_bind) {
+ ret = uc_drv->child_post_bind(dev);
+ if (ret)
+ goto err;
+ }
+ }
if (uc->uc_drv->post_bind) {
ret = uc->uc_drv->post_bind(dev);
- if (ret) {
- list_del(&dev->uclass_node);
- return ret;
- }
+ if (ret)
+ goto err;
}
return 0;
+err:
+ /* There is no need to undo the parent's post_bind call */
+ list_del(&dev->uclass_node);
+
+ return ret;
}
int uclass_unbind_device(struct udevice *dev)