All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 01/27] dm: core: Allow uclass to set up a device's child after it is probed
Date: Thu, 27 Sep 2018 06:41:59 -0700	[thread overview]
Message-ID: <CAPnjgZ1MgTnZwFgS6TQfyE5L=bmq9iCpbY2DOtcywhMUufm1DA@mail.gmail.com> (raw)
In-Reply-To: <1537710145-1888-2-git-send-email-bmeng.cn@gmail.com>

Hi Bin,

On 23 September 2018 at 06:41, 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>
> ---
>
>  drivers/core/uclass.c | 13 ++++++++++++-
>  include/dm/uclass.h   |  4 +++-
>  2 files changed, 15 insertions(+), 2 deletions(-)

Another option, perhaps not quite as elegant, is for the driver to
call into the uclass in its probe() method. We need to balance
elegance with the cost of adding a new field to the uclass which is
rarely used. What do you think?

Also, this does need some sort of use in sandbox, so can you update
the test driver to use it?

>
> 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 6e7c1cd..610c68d 100644
> --- a/include/dm/uclass.h
> +++ b/include/dm/uclass.h
> @@ -58,7 +58,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
> @@ -91,6 +92,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;
> --
> 2.7.4
>

Regards,
Simon

  reply	other threads:[~2018-09-27 13:41 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-23 13:41 [U-Boot] [PATCH 00/27] virtio: Introduce VirtIO driver support Bin Meng
2018-09-23 13:41 ` [U-Boot] [PATCH 01/27] dm: core: Allow uclass to set up a device's child after it is probed Bin Meng
2018-09-27 13:41   ` Simon Glass [this message]
2018-10-11  5:14     ` Bin Meng
2018-09-23 13:42 ` [U-Boot] [PATCH 02/27] dm: Add a new uclass driver for VirtIO transport devices Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-10-11  9:08     ` Bin Meng
2018-09-27 22:10   ` Tuomas Tynkkynen
2018-10-11  9:09     ` Bin Meng
2018-09-23 13:42 ` [U-Boot] [PATCH 03/27] virtio: Add codes for virtual queue/ring management Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-10-11  9:50     ` Bin Meng
2018-10-12  0:00       ` Simon Glass
2018-09-27 22:11   ` Tuomas Tynkkynen
2018-10-02 15:46     ` Bin Meng
2018-09-23 13:42 ` [U-Boot] [PATCH 04/27] virtio: Add virtio over mmio transport driver Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 05/27] virtio: Add net driver support Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-27 22:12   ` Tuomas Tynkkynen
2018-10-02 16:10     ` Bin Meng
2018-10-22 23:09   ` Joe Hershberger
2018-09-23 13:42 ` [U-Boot] [PATCH 06/27] test: dm: blk: Correct blk_base test case Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 07/27] sandbox: blk: Switch to use platdata_auto_alloc_size for the driver data Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 08/27] efi_driver: " Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 09/27] blk: Call part_init() in the post_probe() method Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 10/27] blk: Drop blk_prepare_device() Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 11/27] blk: Make blk_next_free_devnum() public Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 12/27] blk: Introduce IF_TYPE_VIRTIO Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 13/27] virtio: Add block driver support Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-27 22:12     ` Tuomas Tynkkynen
2018-09-23 13:42 ` [U-Boot] [PATCH 14/27] virtio: cmd: Add virtio command for virtio block devices Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 15/27] arm: qemu: Add a Kconfig in the board directory Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 16/27] arm: qemu: Enumerate virtio bus during early boot Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-10-11 13:21     ` Bin Meng
2018-09-27 22:13   ` Tuomas Tynkkynen
2018-10-11 13:28     ` Bin Meng
2018-09-23 13:42 ` [U-Boot] [PATCH 17/27] riscv: " Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 18/27] riscv: qemu: Include some useful commands Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-27 22:14   ` Tuomas Tynkkynen
2018-10-02 16:03     ` Bin Meng
2018-09-23 13:42 ` [U-Boot] [PATCH 19/27] kconfig: Introduce HAVE_ARCH_IOMAP Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 20/27] x86: Implement arch-specific io accessor routines Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-10-11 13:33     ` Bin Meng
2018-09-23 13:42 ` [U-Boot] [PATCH 21/27] virtio: Add virtio over pci transport driver Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-10-11 13:39     ` Bin Meng
2018-09-23 13:42 ` [U-Boot] [PATCH 22/27] x86: qemu: Imply virtio PCI transport and device drivers Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 23/27] dm: pci: Add APIs to find next capability and extended capability Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 24/27] test: dm: pci: Add cases for finding next PCI capability APIs Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-09-23 13:42 ` [U-Boot] [PATCH 25/27] virtio: pci: Support non-legacy PCI transport device Bin Meng
2018-09-27 13:42   ` Simon Glass
2018-10-11 13:41     ` Bin Meng
2018-09-23 13:42 ` [U-Boot] [PATCH 26/27] virtio: net: Support non-legacy device Bin Meng
2018-09-27 13:43   ` Simon Glass
2018-10-15 21:59   ` Joe Hershberger
2018-09-23 13:42 ` [U-Boot] [PATCH 27/27] doc: Document virtio support Bin Meng
2018-09-27 13:43   ` Simon Glass
2018-09-27 13:43 ` [U-Boot] [PATCH 00/27] virtio: Introduce VirtIO driver support Simon Glass
2018-09-27 22:19   ` Tuomas Tynkkynen
2018-10-02 11:21     ` Simon Glass
2018-10-04  7:00       ` Bin Meng
2018-10-09 16:20         ` Simon Glass
2018-10-10 15:35           ` Bin Meng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPnjgZ1MgTnZwFgS6TQfyE5L=bmq9iCpbY2DOtcywhMUufm1DA@mail.gmail.com' \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.