Message ID | 1539595287-31378-2-git-send-email-bmeng.cn@gmail.com |
---|---|
State | Accepted |
Delegated to: | Simon Glass |
Headers | show |
Series | virtio: Introduce VirtIO driver support | expand |
On 15 October 2018 at 03:20, Bin Meng <bmeng.cn@gmail.com> wrote: > 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> > --- > > Changes in v3: None > Changes in v2: None > > drivers/core/uclass.c | 13 ++++++++++++- > include/dm/uclass.h | 4 +++- > 2 files changed, 15 insertions(+), 2 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org>
On 15 October 2018 at 03:20, Bin Meng <bmeng.cn@gmail.com> wrote: > 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> > --- > > Changes in v3: None > Changes in v2: None > > drivers/core/uclass.c | 13 ++++++++++++- > include/dm/uclass.h | 4 +++- > 2 files changed, 15 insertions(+), 2 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org> Applied to u-boot-dm/next, thanks!
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 3113d6a..3c7b9cf 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -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); diff --git a/include/dm/uclass.h b/include/dm/uclass.h index eebf2d5..4ef0d0f 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -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;
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> --- Changes in v3: None Changes in v2: None drivers/core/uclass.c | 13 ++++++++++++- include/dm/uclass.h | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-)