All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v5 1/2] dm: core: add function uclass_probe_all() to probe all devices
Date: Wed, 16 Dec 2020 10:19:18 -0500	[thread overview]
Message-ID: <c6242561-ca27-3a7c-6a48-ac5cb92da2f2@gmail.com> (raw)
In-Reply-To: <1607490724-6447-2-git-send-email-vabhav.sharma@oss.nxp.com>

On 12/9/20 12:12 AM, Vabhav Sharma wrote:
> From: Vabhav Sharma <vabhav.sharma@nxp.com>
> 
> Support a common method to probe all devices associated with uclass.
> 
> This includes data structures and code for finding the first device and
> looping for remaining devices associated with uclasses (groups of devices
> with the same purpose, e.g. all SERIAL ports will be in the same uclass).
> 
> An example is SBSA compliant PL011 UART IP, where firmware does the serial
> port initialization and prepare uart device to let the kernel use it for
> sending and reveiving the characters.SERIAL uclass will use this function
> to initialize PL011 UART ports.
> 
> The feature is enabled with CONFIG_DM.
> 
> Signed-off-by: Vabhav Sharma <vabhav.sharma@nxp.com>
> Reviewed-by: Stefan Roese <sr@denx.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> --
>    v5:
>    Incorporated review comments of Sean Anderson
>    Replace for loop with while loop
>    Error check added
>    Function description updated
> 
>    v4:
>    Incorporated review comments of Simon
>    Removed if (dev)..  conditional check
> 
>    v3:
>    Incorporated review comments of Stephan,Simon
>    Related discussion https://patchwork.ozlabs.org/project/uboot/patch/1601400
> 385-11854-1-git-send-email-vabhav.sharma at oss.nxp.com/
> ---
>   drivers/core/uclass.c | 19 +++++++++++++++++++
>   include/dm/uclass.h   | 11 +++++++++++
>   2 files changed, 30 insertions(+)
> 
> diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
> index c3f1b73..27972ef 100644
> --- a/drivers/core/uclass.c
> +++ b/drivers/core/uclass.c
> @@ -792,6 +792,25 @@ int uclass_pre_remove_device(struct udevice *dev)
>   }
>   #endif
>   
> +int uclass_probe_all(enum uclass_id id)
> +{
> +	struct udevice *dev;
> +	int ret;
> +
> +	ret = uclass_first_device(id, &dev);
> +	if (ret || !dev)
> +		return ret;
> +
> +	/* Scanning uclass to probe all devices */
> +	while (dev) {
> +		ret = uclass_next_device(&dev);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	return 0;
> +}
> +
>   UCLASS_DRIVER(nop) = {
>   	.id		= UCLASS_NOP,
>   	.name		= "nop",
> diff --git a/include/dm/uclass.h b/include/dm/uclass.h
> index 7188304..6bd33d4 100644
> --- a/include/dm/uclass.h
> +++ b/include/dm/uclass.h
> @@ -381,6 +381,17 @@ int uclass_first_device_drvdata(enum uclass_id id, ulong driver_data,
>   int uclass_resolve_seq(struct udevice *dev);
>   
>   /**
> + * uclass_probe_all() - Probe all devices based on an uclass ID
> + *
> + * This function probes all devices associated with a uclass by
> + * looking for its ID.
> + *
> + * @id: uclass ID to look up
> + * @return 0 if OK, other -ve on error
> + */
> +int uclass_probe_all(enum uclass_id id);
> +
> +/**
>    * uclass_id_foreach_dev() - Helper function to iteration through devices
>    *
>    * This creates a for() loop which works through the available devices in
> 

Reviewed-by: Sean Anderson <seanga2@gmail.com>

  reply	other threads:[~2020-12-16 15:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09  5:12 [PATCH v5 0/2] dm: core: drivers: add function uclass_probe_all() Vabhav Sharma
2020-12-09  5:12 ` [PATCH v5 1/2] dm: core: add function uclass_probe_all() to probe all devices Vabhav Sharma
2020-12-16 15:19   ` Sean Anderson [this message]
2021-01-18 13:01   ` Tom Rini
2020-12-09  5:12 ` [PATCH v5 2/2] drivers: serial: probe all uart devices Vabhav Sharma
2020-12-16 15:22   ` Sean Anderson
2021-01-18 13:01   ` Tom Rini
2020-12-16 10:31 ` [PATCH v5 0/2] dm: core: drivers: add function uclass_probe_all() Vabhav Sharma

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=c6242561-ca27-3a7c-6a48-ac5cb92da2f2@gmail.com \
    --to=seanga2@gmail.com \
    --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.