[U-Boot] [PATCH 2/2] disk: part: use common api to lookup part driver

Dr. Philipp Tomsich philipp.tomsich at theobroma-systems.com
Thu Dec 14 09:53:41 UTC 2017


Kever,

> On 14 Dec 2017, at 07:39, Kever Yang <kever.yang at rock-chips.com> wrote:
> 
> Do not need to scan disk every time when we get part info
> by name.

How does this interact with USB devices?
I.e.: what happens, when you get the partition-info for a usb drive, then change
the attached usb drive (with only a single one attached, but a different one) and
do a ‘usb rescan’?

Regards,
Philipp.

> 
> Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
> ---
> 
> disk/part.c | 29 +++++++++++++----------------
> 1 file changed, 13 insertions(+), 16 deletions(-)
> 
> diff --git a/disk/part.c b/disk/part.c
> index b007138..96c2858 100644
> --- a/disk/part.c
> +++ b/disk/part.c
> @@ -638,26 +638,23 @@ cleanup:
> int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
> 	disk_partition_t *info)
> {
> -	struct part_driver *first_drv =
> -		ll_entry_start(struct part_driver, part_driver);
> -	const int n_drvs = ll_entry_count(struct part_driver, part_driver);
> 	struct part_driver *part_drv;
> +	int ret;
> +	int i;
> 
> -	for (part_drv = first_drv; part_drv != first_drv + n_drvs; part_drv++) {
> -		int ret;
> -		int i;
> -		for (i = 1; i < part_drv->max_entries; i++) {
> -			ret = part_drv->get_info(dev_desc, i, info);
> -			if (ret != 0) {
> -				/* no more entries in table */
> -				break;
> -			}
> -			if (strcmp(name, (const char *)info->name) == 0) {
> -				/* matched */
> -				return i;
> -			}
> +	part_drv = part_driver_lookup_type(dev_desc);
> +	for (i = 1; i < part_drv->max_entries; i++) {
> +		ret = part_drv->get_info(dev_desc, i, info);
> +		if (ret != 0) {
> +			/* no more entries in table */
> +			break;
> +		}
> +		if (strcmp(name, (const char *)info->name) == 0) {
> +			/* matched */
> +			return i;
> 		}
> 	}
> +
> 	return -1;
> }
> 
> -- 
> 1.9.1
> 



More information about the U-Boot mailing list