aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBin Meng2018-10-15 04:20:57 -0500
committerSimon Glass2018-11-14 11:16:27 -0600
commit651d0c019a428ca8b14352210c1ce7804dd51fae (patch)
tree899f50340f961295b0b7e4cfac051e9d823d20d4
parenta6d4b0608b79023c703ca2ad1cbdfa784160449b (diff)
downloadu-boot-651d0c019a428ca8b14352210c1ce7804dd51fae.tar.gz
u-boot-651d0c019a428ca8b14352210c1ce7804dd51fae.tar.xz
u-boot-651d0c019a428ca8b14352210c1ce7804dd51fae.zip
dm: core: Allow uclass to set up a device's child after it is probed
Some buses need to set up their child devices after they are probed. Support a common child_post_probe() method for the uclass. With this change, the two APIs uclass_pre_probe_device() and uclass_post_probe_device() become symmetric. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/core/uclass.c13
-rw-r--r--include/dm/uclass.h4
2 files changed, 15 insertions, 2 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 3113d6a56b..3c7b9cf0ad 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -687,8 +687,19 @@ int uclass_pre_probe_device(struct udevice *dev)
687 687
688int uclass_post_probe_device(struct udevice *dev) 688int uclass_post_probe_device(struct udevice *dev)
689{ 689{
690 struct uclass_driver *uc_drv = dev->uclass->uc_drv; 690 struct uclass_driver *uc_drv;
691 int ret;
692
693 if (dev->parent) {
694 uc_drv = dev->parent->uclass->uc_drv;
695 if (uc_drv->child_post_probe) {
696 ret = uc_drv->child_post_probe(dev);
697 if (ret)
698 return ret;
699 }
700 }
691 701
702 uc_drv = dev->uclass->uc_drv;
692 if (uc_drv->post_probe) 703 if (uc_drv->post_probe)
693 return uc_drv->post_probe(dev); 704 return uc_drv->post_probe(dev);
694 705
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index eebf2d5614..4ef0d0f0c0 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -61,7 +61,8 @@ struct udevice;
61 * @post_probe: Called after a new device is probed 61 * @post_probe: Called after a new device is probed
62 * @pre_remove: Called before a device is removed 62 * @pre_remove: Called before a device is removed
63 * @child_post_bind: Called after a child is bound to a device in this uclass 63 * @child_post_bind: Called after a child is bound to a device in this uclass
64 * @child_pre_probe: Called before a child is probed in this uclass 64 * @child_pre_probe: Called before a child in this uclass is probed
65 * @child_post_probe: Called after a child in this uclass is probed
65 * @init: Called to set up the uclass 66 * @init: Called to set up the uclass
66 * @destroy: Called to destroy the uclass 67 * @destroy: Called to destroy the uclass
67 * @priv_auto_alloc_size: If non-zero this is the size of the private data 68 * @priv_auto_alloc_size: If non-zero this is the size of the private data
@@ -94,6 +95,7 @@ struct uclass_driver {
94 int (*pre_remove)(struct udevice *dev); 95 int (*pre_remove)(struct udevice *dev);
95 int (*child_post_bind)(struct udevice *dev); 96 int (*child_post_bind)(struct udevice *dev);
96 int (*child_pre_probe)(struct udevice *dev); 97 int (*child_pre_probe)(struct udevice *dev);
98 int (*child_post_probe)(struct udevice *dev);
97 int (*init)(struct uclass *class); 99 int (*init)(struct uclass *class);
98 int (*destroy)(struct uclass *class); 100 int (*destroy)(struct uclass *class);
99 int priv_auto_alloc_size; 101 int priv_auto_alloc_size;