dm: core: Allow uclass to set up a device's child after it is probed
authorBin Meng <bmeng.cn@gmail.com>
Mon, 15 Oct 2018 09:20:57 +0000 (02:20 -0700)
committerSimon Glass <sjg@chromium.org>
Wed, 14 Nov 2018 17:16:27 +0000 (09:16 -0800)
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>
drivers/core/uclass.c
include/dm/uclass.h

index 3113d6a56ba334866f4f355fe65c9b25fafae1fa..3c7b9cf0ad81cec430a17a3bc4b969c4e64f751f 100644 (file)
@@ -687,8 +687,19 @@ int uclass_pre_probe_device(struct udevice *dev)
 
 int uclass_post_probe_device(struct udevice *dev)
 {
-       struct uclass_driver *uc_drv = dev->uclass->uc_drv;
+       struct uclass_driver *uc_drv;
+       int ret;
+
+       if (dev->parent) {
+               uc_drv = dev->parent->uclass->uc_drv;
+               if (uc_drv->child_post_probe) {
+                       ret = uc_drv->child_post_probe(dev);
+                       if (ret)
+                               return ret;
+               }
+       }
 
+       uc_drv = dev->uclass->uc_drv;
        if (uc_drv->post_probe)
                return uc_drv->post_probe(dev);
 
index eebf2d5614c40a1f360081f95aca499b6cfe9b83..4ef0d0f0c01285cb314473b9a883cd525deafc86 100644 (file)
@@ -61,7 +61,8 @@ struct udevice;
  * @post_probe: Called after a new device is probed
  * @pre_remove: Called before a device is removed
  * @child_post_bind: Called after a child is bound to a device in this uclass
- * @child_pre_probe: Called before a child is probed in this uclass
+ * @child_pre_probe: Called before a child in this uclass is probed
+ * @child_post_probe: Called after a child in this uclass is probed
  * @init: Called to set up the uclass
  * @destroy: Called to destroy the uclass
  * @priv_auto_alloc_size: If non-zero this is the size of the private data
@@ -94,6 +95,7 @@ struct uclass_driver {
        int (*pre_remove)(struct udevice *dev);
        int (*child_post_bind)(struct udevice *dev);
        int (*child_pre_probe)(struct udevice *dev);
+       int (*child_post_probe)(struct udevice *dev);
        int (*init)(struct uclass *class);
        int (*destroy)(struct uclass *class);
        int priv_auto_alloc_size;