diff mbox series

Avoid adding the same dataflash for the second time

Message ID 35932af6-66b2-3c31-6592-904cce8f30c7@mikronika.com.pl
State Changes Requested
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series Avoid adding the same dataflash for the second time | expand

Commit Message

Jakub Frackowiak June 18, 2021, 8:48 a.m. UTC
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(+)

Comments

Jagan Teki Aug. 3, 2021, 6:18 a.m. UTC | #1
On Fri, Jun 18, 2021 at 8:26 PM Jakub Frackowiak <jakub@mikronika.com.pl> wrote:
>
> 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
> ---

Please send the patch properly, check it the guidelines - if you
aren't aware it before.
https://www.denx.de/wiki/view/U-Boot/Patches#General_Patch_Submission_Rules
diff mbox series

Patch

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;
      }

         /*