diff options
author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2019-01-29 15:20:01 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-03-08 23:11:13 +1100 |
commit | 2ed2ec1711b13dd9a28bdc29ce8cba13ca7d503f (patch) | |
tree | acc9f03becdd6c0099dc48e745c2d105e6a62d44 | |
parent | 89ff506513d52c0c415b2cf45335d60cefac527d (diff) |
drivers/memory/spiflash: Rework wait_sr to fix uninit'd variable 'sr'.
-rw-r--r-- | drivers/memory/spiflash.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/memory/spiflash.c b/drivers/memory/spiflash.c index c0b55591b..22775d541 100644 --- a/drivers/memory/spiflash.c +++ b/drivers/memory/spiflash.c @@ -128,19 +128,14 @@ STATIC void mp_spiflash_write_cmd_addr(mp_spiflash_t *self, uint8_t cmd, uint32_ STATIC int mp_spiflash_wait_sr(mp_spiflash_t *self, uint8_t mask, uint8_t val, uint32_t timeout) { uint8_t sr; - for (; timeout; --timeout) { + do { sr = mp_spiflash_read_cmd(self, CMD_RDSR, 1); if ((sr & mask) == val) { - break; + return 0; // success } - } - if ((sr & mask) == val) { - return 0; // success - } else if (timeout == 0) { - return -MP_ETIMEDOUT; - } else { - return -MP_EIO; - } + } while (timeout--); + + return -MP_ETIMEDOUT; } STATIC int mp_spiflash_wait_wel1(mp_spiflash_t *self) { |