summaryrefslogtreecommitdiff
path: root/spi.c
diff options
context:
space:
mode:
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2008-11-27 22:48:48 +0000
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2008-11-27 22:48:48 +0000
commit6d91d11921bbd855ff9b2c7c53a9b6eeef83c662 (patch)
tree873b9b570fd7b47fd5ff1aefea826c55e422ac71 /spi.c
parent154015ad900fafe174acd7781ce11ffc8ad2a075 (diff)
downloadflashrom-6d91d11921bbd855ff9b2c7c53a9b6eeef83c662.tar.gz
Original v2 revision: 3774
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. Even if a command is supported by the controller, it may be unavailable if the controller is locked down. The new logic checks if RDID could be issued and its return values made sense (not 0xff 0xff 0xff). In that case, RES probing is not performed. Otherwise, we try RES. There is one drawback: If RDID returned unexpected values, we don't issue a RES probe. However, in that case we should try to match RDID anyway. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: FENG yu ning <fengyuning1984@gmail.com> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@348 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'spi.c')
-rw-r--r--spi.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/spi.c b/spi.c
index f676857..a5b85f4 100644
--- a/spi.c
+++ b/spi.c
@@ -160,13 +160,11 @@ int probe_spi_res(struct flashchip *flash)
unsigned char readarr[3];
uint32_t model_id;
- if (spi_rdid(readarr, 3))
- /* We couldn't issue RDID, it's pointless to try RES. */
- return 0;
-
- /* Check if RDID returns 0xff 0xff 0xff, then we use RES. */
- if ((readarr[0] != 0xff) || (readarr[1] != 0xff) ||
- (readarr[2] != 0xff))
+ /* 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;
if (spi_res(readarr))