Re: [PATCH u-boot-dm + u-boot-spi v2 7/7] mtd: probe SPI NOR devices in mtd_probe_devices()

2021-02-10 Thread Pali Rohár
On Tuesday 09 February 2021 15:44:52 Marek Behún wrote:
> In order for `mtd list` U-Boot command to list SPI NOR devices without
> the need to run `sf probe` before, we have to probe SPI NOR devices in
> mtd_probe_devices().
> 
> Signed-off-by: Marek Behún 
> Cc: Jagan Teki 
> Cc: Priyanka Jain 
> Cc: Simon Glass 
> Cc: Heiko Schocher 
> Cc: Jagan Teki 

Reviewed-by: Pali Rohár 

> ---
>  drivers/mtd/mtd_uboot.c | 14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/mtd/mtd_uboot.c b/drivers/mtd/mtd_uboot.c
> index 865e9ae4cb..4f5b2fd91d 100644
> --- a/drivers/mtd/mtd_uboot.c
> +++ b/drivers/mtd/mtd_uboot.c
> @@ -114,6 +114,18 @@ static void mtd_probe_uclass_mtd_devs(void)
>  static void mtd_probe_uclass_mtd_devs(void) { }
>  #endif
>  
> +#if IS_ENABLED(CONFIG_DM_SPI_FLASH) && IS_ENABLED(CONFIG_SPI_FLASH_MTD)
> +static void mtd_probe_uclass_spi_nor_devs(void)
> +{
> + struct udevice *dev;
> +
> + uclass_foreach_dev_probe(UCLASS_SPI_FLASH, dev)
> + ;
> +}
> +#else
> +static void mtd_probe_uclass_spi_nor_devs(void) { }
> +#endif
> +
>  #if defined(CONFIG_MTD_PARTITIONS)
>  
>  #define MTDPARTS_MAXLEN 512
> @@ -309,6 +321,7 @@ int mtd_probe_devices(void)
>   struct mtd_info *mtd;
>  
>   mtd_probe_uclass_mtd_devs();
> + mtd_probe_uclass_spi_nor_devs();
>  
>   /*
>* Check if mtdparts/mtdids changed, if the MTD dev list was updated
> @@ -369,6 +382,7 @@ int mtd_probe_devices(void)
>  int mtd_probe_devices(void)
>  {
>   mtd_probe_uclass_mtd_devs();
> + mtd_probe_uclass_spi_nor_devs();
>  
>   return 0;
>  }
> -- 
> 2.26.2
> 


[PATCH u-boot-dm + u-boot-spi v2 7/7] mtd: probe SPI NOR devices in mtd_probe_devices()

2021-02-09 Thread Marek Behún
In order for `mtd list` U-Boot command to list SPI NOR devices without
the need to run `sf probe` before, we have to probe SPI NOR devices in
mtd_probe_devices().

Signed-off-by: Marek Behún 
Cc: Jagan Teki 
Cc: Priyanka Jain 
Cc: Simon Glass 
Cc: Heiko Schocher 
Cc: Jagan Teki 
---
 drivers/mtd/mtd_uboot.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/mtd/mtd_uboot.c b/drivers/mtd/mtd_uboot.c
index 865e9ae4cb..4f5b2fd91d 100644
--- a/drivers/mtd/mtd_uboot.c
+++ b/drivers/mtd/mtd_uboot.c
@@ -114,6 +114,18 @@ static void mtd_probe_uclass_mtd_devs(void)
 static void mtd_probe_uclass_mtd_devs(void) { }
 #endif
 
+#if IS_ENABLED(CONFIG_DM_SPI_FLASH) && IS_ENABLED(CONFIG_SPI_FLASH_MTD)
+static void mtd_probe_uclass_spi_nor_devs(void)
+{
+   struct udevice *dev;
+
+   uclass_foreach_dev_probe(UCLASS_SPI_FLASH, dev)
+   ;
+}
+#else
+static void mtd_probe_uclass_spi_nor_devs(void) { }
+#endif
+
 #if defined(CONFIG_MTD_PARTITIONS)
 
 #define MTDPARTS_MAXLEN 512
@@ -309,6 +321,7 @@ int mtd_probe_devices(void)
struct mtd_info *mtd;
 
mtd_probe_uclass_mtd_devs();
+   mtd_probe_uclass_spi_nor_devs();
 
/*
 * Check if mtdparts/mtdids changed, if the MTD dev list was updated
@@ -369,6 +382,7 @@ int mtd_probe_devices(void)
 int mtd_probe_devices(void)
 {
mtd_probe_uclass_mtd_devs();
+   mtd_probe_uclass_spi_nor_devs();
 
return 0;
 }
-- 
2.26.2