diff mbox series

[2/2] board: st: common: simplify MTD device parsing

Message ID 20231117170107.1147598-2-patrice.chotard@foss.st.com
State Accepted
Commit ec29c07a4096bfa0f3856697def57190a81386df
Delegated to: Patrice Chotard
Headers show
Series [1/2] board: st: common: Fix board_get_alt_info_mtd() | expand

Commit Message

Patrice CHOTARD Nov. 17, 2023, 5:01 p.m. UTC
Simplify the way all MTD devices are parsed.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---

 board/st/common/stm32mp_dfu.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

Comments

Patrick DELAUNAY Dec. 15, 2023, 11:53 a.m. UTC | #1
Hi,

On 11/17/23 18:01, Patrice Chotard wrote:
> Simplify the way all MTD devices are parsed.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
>   board/st/common/stm32mp_dfu.c | 19 ++-----------------
>   1 file changed, 2 insertions(+), 17 deletions(-)
>
> diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
> index ded3bf81961..77edb86e78c 100644
> --- a/board/st/common/stm32mp_dfu.c
> +++ b/board/st/common/stm32mp_dfu.c
> @@ -123,24 +123,9 @@ void set_dfu_alt_info(char *interface, char *devstr)
>   		/* probe all MTD devices */
>   		mtd_probe_devices();
>   
> -		/* probe SPI flash device on a bus */
> -		if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) {
> -			mtd = get_mtd_device_nm("nor0");
> -			if (!IS_ERR_OR_NULL(mtd))
> +		mtd_for_each_device(mtd)
> +			if (!mtd_is_partition(mtd))
>   				board_get_alt_info_mtd(mtd, buf);
> -
> -			mtd = get_mtd_device_nm("nor1");
> -			if (!IS_ERR_OR_NULL(mtd))
> -				board_get_alt_info_mtd(mtd, buf);
> -		}
> -
> -		mtd = get_mtd_device_nm("nand0");
> -		if (!IS_ERR_OR_NULL(mtd))
> -			board_get_alt_info_mtd(mtd, buf);
> -
> -		mtd = get_mtd_device_nm("spi-nand0");
> -		if (!IS_ERR_OR_NULL(mtd))
> -			board_get_alt_info_mtd(mtd, buf);
>   	}
>   
>   	if (IS_ENABLED(CONFIG_DFU_VIRT)) {



Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick
Patrice CHOTARD Dec. 15, 2023, 2:12 p.m. UTC | #2
On 12/15/23 12:53, Patrick DELAUNAY wrote:
> Hi,
> 
> On 11/17/23 18:01, Patrice Chotard wrote:
>> Simplify the way all MTD devices are parsed.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>>   board/st/common/stm32mp_dfu.c | 19 ++-----------------
>>   1 file changed, 2 insertions(+), 17 deletions(-)
>>
>> diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
>> index ded3bf81961..77edb86e78c 100644
>> --- a/board/st/common/stm32mp_dfu.c
>> +++ b/board/st/common/stm32mp_dfu.c
>> @@ -123,24 +123,9 @@ void set_dfu_alt_info(char *interface, char *devstr)
>>           /* probe all MTD devices */
>>           mtd_probe_devices();
>>   -        /* probe SPI flash device on a bus */
>> -        if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) {
>> -            mtd = get_mtd_device_nm("nor0");
>> -            if (!IS_ERR_OR_NULL(mtd))
>> +        mtd_for_each_device(mtd)
>> +            if (!mtd_is_partition(mtd))
>>                   board_get_alt_info_mtd(mtd, buf);
>> -
>> -            mtd = get_mtd_device_nm("nor1");
>> -            if (!IS_ERR_OR_NULL(mtd))
>> -                board_get_alt_info_mtd(mtd, buf);
>> -        }
>> -
>> -        mtd = get_mtd_device_nm("nand0");
>> -        if (!IS_ERR_OR_NULL(mtd))
>> -            board_get_alt_info_mtd(mtd, buf);
>> -
>> -        mtd = get_mtd_device_nm("spi-nand0");
>> -        if (!IS_ERR_OR_NULL(mtd))
>> -            board_get_alt_info_mtd(mtd, buf);
>>       }
>>         if (IS_ENABLED(CONFIG_DFU_VIRT)) {
> 
> 
> 
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> 
> Thanks
> Patrick
> 
Applied to u-boot-stm32/next

Thanks
Patrice
diff mbox series

Patch

diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
index ded3bf81961..77edb86e78c 100644
--- a/board/st/common/stm32mp_dfu.c
+++ b/board/st/common/stm32mp_dfu.c
@@ -123,24 +123,9 @@  void set_dfu_alt_info(char *interface, char *devstr)
 		/* probe all MTD devices */
 		mtd_probe_devices();
 
-		/* probe SPI flash device on a bus */
-		if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) {
-			mtd = get_mtd_device_nm("nor0");
-			if (!IS_ERR_OR_NULL(mtd))
+		mtd_for_each_device(mtd)
+			if (!mtd_is_partition(mtd))
 				board_get_alt_info_mtd(mtd, buf);
-
-			mtd = get_mtd_device_nm("nor1");
-			if (!IS_ERR_OR_NULL(mtd))
-				board_get_alt_info_mtd(mtd, buf);
-		}
-
-		mtd = get_mtd_device_nm("nand0");
-		if (!IS_ERR_OR_NULL(mtd))
-			board_get_alt_info_mtd(mtd, buf);
-
-		mtd = get_mtd_device_nm("spi-nand0");
-		if (!IS_ERR_OR_NULL(mtd))
-			board_get_alt_info_mtd(mtd, buf);
 	}
 
 	if (IS_ENABLED(CONFIG_DFU_VIRT)) {