[PATCH] Avoid adding the same dataflash for the second time

Jakub Frackowiak jakub at mikronika.com.pl
Fri Jun 18 10:48:19 CEST 2021


The spi_dataflash_probe function should return after jedec_probe
if it finds any serial flash.
This functions adds the same SPI device two times without this
path.
Serial output when reading environment:

Loading Environment from SPIFlash... SPI DataFlash: Detected at45db321d 
with page size 512 Bytes, erase size 512 Bytes, total 4 MiB, revision d
SPI DataFlash: Detected AT45DB321x with page size 528 Bytes, erase size 
528 Bytes, total 4.1 MiB, revision
*** Warning - bad CRC, using default environment

When this patch is applied:

Loading Environment from SPIFlash... SPI DataFlash: Detected at45db321d 
with page size 512 Bytes, erase size 512 Bytes, total 4 MiB, revision d
OK
---
  drivers/mtd/spi/sf_dataflash.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/spi/sf_dataflash.c b/drivers/mtd/spi/sf_dataflash.c
index b59edd152c..7040f21eb2 100644
--- a/drivers/mtd/spi/sf_dataflash.c
+++ b/drivers/mtd/spi/sf_dataflash.c
@@ -630,6 +630,9 @@ static int spi_dataflash_probe(struct udevice *dev)
          if (status == 0 || status == 0xff)
              status = -ENODEV;
          goto err_jedec_probe;
+
+        if (!status)
+            return 0;
      }

         /*
-- 
2.17.1



More information about the U-Boot mailing list