The existing check in probe_spi_res() was right for SPI controllers
which support all commands, but may not exist.
For controllers which support only a subset of commands, it will fail in
unexpected ways.

The new logic checks if RDID could be issued and its return values made
sense. In that case, RES probing is not performed. Otherwise, we try RES.

Signed-off-by: Carl-Daniel Hailfinger <[EMAIL PROTECTED]>

Index: flashrom-spi_res_rdid_failover/spi.c
===================================================================
--- flashrom-spi_res_rdid_failover/spi.c        (revision 3773)
+++ flashrom-spi_res_rdid_failover/spi.c        (working copy)
@@ -160,15 +160,13 @@
        unsigned char readarr[3];
        uint32_t model_id;
 
-       if (spi_rdid(readarr, 3))
-               /* We couldn't issue RDID, it's pointless to try RES. */
+       /* Check if RDID was successful and did not return 0xff 0xff 0xff.
+        * In that case, RES is pointless.
+        */
+       if (!spi_rdid(readarr, 3) && ((readarr[0] != 0xff) ||
+           (readarr[1] != 0xff) || (readarr[2] != 0xff)))
                return 0;
 
-       /* Check if RDID returns 0xff 0xff 0xff, then we use RES. */
-       if ((readarr[0] != 0xff) || (readarr[1] != 0xff) ||
-           (readarr[2] != 0xff))
-               return 0;
-
        if (spi_res(readarr))
                return 0;
 


-- 
http://www.hailfinger.org/


--
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to