[PATCH v3 05/31] dm: core: Rename uclass_get_by_name_len()

Heinrich Schuchardt xypron.glpk at gmx.de
Wed Jan 19 12:28:02 CET 2022


On 1/19/22 02:42, Simon Glass wrote:
> It seems that namelen is more common in U-Boot. Rename this function to
> fit in better.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> Changes in v3:
> - Add new patch to rename uclass_get_by_name_len()
>
>   drivers/core/uclass.c | 7 ++++---
>   include/dm/uclass.h   | 8 ++++----
>   2 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
> index 336ea8d243d..563ff9b2856 100644
> --- a/drivers/core/uclass.c
> +++ b/drivers/core/uclass.c
> @@ -180,14 +180,15 @@ void uclass_set_priv(struct uclass *uc, void *priv)
>   	uc->priv_ = priv;
>   }
>
> -enum uclass_id uclass_get_by_name_len(const char *name, int len)
> +enum uclass_id uclass_get_by_namelen(const char *name, int len)
>   {
>   	int i;
>
>   	for (i = 0; i < UCLASS_COUNT; i++) {
>   		struct uclass_driver *uc_drv = lists_uclass_lookup(i);
>
> -		if (uc_drv && !strncmp(uc_drv->name, name, len))
> +		if (uc_drv && !strncmp(uc_drv->name, name, len) &&
> +		    strlen(uc_drv->name) == len)
>   			return i;
>   	}
>
> @@ -196,7 +197,7 @@ enum uclass_id uclass_get_by_name_len(const char *name, int len)
>
>   enum uclass_id uclass_get_by_name(const char *name)
>   {
> -	return uclass_get_by_name_len(name, strlen(name));
> +	return uclass_get_by_namelen(name, strlen(name));
>   }
>
>   int dev_get_uclass_index(struct udevice *dev, struct uclass **ucp)
> diff --git a/include/dm/uclass.h b/include/dm/uclass.h
> index 7f33c34214e..7876e9175e7 100644
> --- a/include/dm/uclass.h
> +++ b/include/dm/uclass.h
> @@ -173,13 +173,13 @@ int uclass_get(enum uclass_id key, struct uclass **ucp);
>   const char *uclass_get_name(enum uclass_id id);
>
>   /**
> - * uclass_get_by_name_len() - Look up a uclass by its partial driver name
> + * uclass_get_by_namelen() - Look up a uclass by its driver name
>    *
>    * @name: Name to look up
> - * @len: Length of the partial name
> - * Return: the associated uclass ID, or UCLASS_INVALID if not found
> + * @len: Length of @name (the uclass driver name must have the same length)
> + * @returns the associated uclass ID, or UCLASS_INVALID if not found

Return:
Cf.
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation

Best regards

Heinrich

>    */
> -enum uclass_id uclass_get_by_name_len(const char *name, int len);
> +enum uclass_id uclass_get_by_namelen(const char *name, int len);
>
>   /**
>    * uclass_get_by_name() - Look up a uclass by its driver name



More information about the U-Boot mailing list