Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at --- spi25.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/spi25.c b/spi25.c index 5d73411..c4cd6b2 100644 --- a/spi25.c +++ b/spi25.c @@ -31,17 +31,17 @@
void spi_prettyprint_status_register(struct flashchip *flash);
-static int spi_rdid(unsigned char *readarr, int bytes) +static int spi_rdid(unsigned char *readarr, int bytes_in, unsigned char rdid_opcode) { - static const unsigned char cmd[JEDEC_RDID_OUTSIZE] = { JEDEC_RDID }; + unsigned char cmd[] = { rdid_opcode }; int ret; int i;
- ret = spi_send_command(sizeof(cmd), bytes, cmd, readarr); + ret = spi_send_command(sizeof(cmd), bytes_in, cmd, readarr); if (ret) return ret; msg_cspew("RDID returned"); - for (i = 0; i < bytes; i++) + for (i = 0; i < bytes_in; i++) msg_cspew(" 0x%02x", readarr[i]); msg_cspew(". "); return 0; @@ -115,13 +115,13 @@ int spi_write_disable(void) return spi_send_command(sizeof(cmd), 0, cmd, NULL); }
-static int probe_spi_rdid_generic(struct flashchip *flash, int bytes) +static int probe_spi_rdid_generic(struct flashchip *flash, int bytes_in, unsigned char rdid_opcode) { - unsigned char readarr[4]; + unsigned char readarr[bytes_in]; uint32_t id1; uint32_t id2;
- if (spi_rdid(readarr, bytes)) + if (spi_rdid(readarr, bytes_in, rdid_opcode)) return 0;
if (!oddparity(readarr[0])) @@ -135,7 +135,7 @@ static int probe_spi_rdid_generic(struct flashchip *flash, int bytes) msg_cdbg("RDID byte 1 parity violation. "); id1 = (readarr[0] << 8) | readarr[1]; id2 = readarr[2]; - if (bytes > 3) { + if (bytes_in > 3) { id2 <<= 8; id2 |= readarr[3]; } @@ -170,7 +170,7 @@ static int probe_spi_rdid_generic(struct flashchip *flash, int bytes)
int probe_spi_rdid(struct flashchip *flash) { - return probe_spi_rdid_generic(flash, 3); + return probe_spi_rdid_generic(flash, JEDEC_RDID_INSIZE, JEDEC_RDID); }
int probe_spi_rdid4(struct flashchip *flash) @@ -189,7 +189,7 @@ int probe_spi_rdid4(struct flashchip *flash) #endif #endif default: - return probe_spi_rdid_generic(flash, 4); + return probe_spi_rdid_generic(flash, 4, JEDEC_RDID); }
return 0; @@ -242,8 +242,8 @@ int probe_spi_res1(struct flashchip *flash) /* Check if RDID is usable and does not return 0xff 0xff 0xff or * 0x00 0x00 0x00. In that case, RES is pointless. */ - if (!spi_rdid(readarr, 3) && memcmp(readarr, allff, 3) && - memcmp(readarr, all00, 3)) { + if (!spi_rdid(readarr, JEDEC_RDID_INSIZE, JEDEC_RDID) && memcmp(readarr, allff, 3) && + memcmp(readarr, all00, JEDEC_RDID_INSIZE)) { msg_cdbg("Ignoring RES in favour of RDID.\n"); return 0; }