[U-Boot] [PATCH v6 30/31] cmd: mtdparts: try to probe the MTD devices as a fallback

Boris Brezillon boris.brezillon at bootlin.com
Thu Aug 16 17:11:33 UTC 2018


On Thu, 16 Aug 2018 17:30:28 +0200
Miquel Raynal <miquel.raynal at bootlin.com> wrote:

> Current implementation of mtdparts command errors out if the desired MTD
> device is not found. Fallback to the new probe function in this case
> before erroring out.
> 
> This will the save the user the need to call something like 'mtd list'
> before mtdparts.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
> Acked-by: Jagan Teki <jagan at openedev.com>
> ---
>  cmd/mtdparts.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
> index 33becb86e8..fb6424d72a 100644
> --- a/cmd/mtdparts.c
> +++ b/cmd/mtdparts.c
> @@ -308,9 +308,15 @@ static int get_mtd_info(u8 type, u8 num, struct mtd_info **mtd)
>  
>  	sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(type), num);
>  	*mtd = get_mtd_device_nm(mtd_dev);
> -	if (IS_ERR(*mtd)) {
> -		printf("Device %s not found!\n", mtd_dev);
> -		return 1;
> +	if (IS_ERR_OR_NULL(*mtd)) {
> +#ifdef CONFIG_CMD_MTD
> +		mtd_probe_devices();
> +		*mtd = get_mtd_device_nm(mtd_dev);

Hm, just like for mtdparts_parse_part(), maybe we should have
mtd_probe_devices() defined in drivers/mtd/mtd-uclass.c and selected
with CONFIG_MTD, not CMD_MTD.

> +#endif
> +		if (IS_ERR_OR_NULL(*mtd)) {
> +			printf("Device %s not found!\n", mtd_dev);
> +			return 1;
> +		}
>  	}
>  	put_mtd_device(*mtd);
>  



More information about the U-Boot mailing list