[flashrom] [PATCH] ichspi: reprogram_opcode_on_the_fly return code fix.
Stefan Tauner
stefan.tauner at student.tuwien.ac.at
Wed Sep 12 16:29:44 CEST 2012
From: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
by carldani, found in our paste service history
---
ichspi.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/ichspi.c b/ichspi.c
index ce9c553..fbc6ea7 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -409,13 +409,19 @@ static int reprogram_opcode_on_the_fly(uint8_t opcode, unsigned int writecnt, un
else // we have an invalid case
return SPI_INVALID_LENGTH;
}
- int oppos = 2; // use original JEDEC_BE_D8 offset
- curopcodes->opcode[oppos].opcode = opcode;
- curopcodes->opcode[oppos].spi_type = spi_type;
- program_opcodes(curopcodes, 0);
- oppos = find_opcode(curopcodes, opcode);
- msg_pdbg2("on-the-fly OPCODE (0x%02X) re-programmed, op-pos=%d\n", opcode, oppos);
- return oppos;
+ if (spi_type <= 3) {
+ int oppos = 2; // use original JEDEC_BE_D8 offset
+ curopcodes->opcode[oppos].opcode = opcode;
+ curopcodes->opcode[oppos].spi_type = spi_type;
+ program_opcodes(curopcodes, 0);
+ oppos = find_opcode(curopcodes, opcode);
+ msg_pdbg2("on-the-fly OPCODE (0x%02X) re-programmed, op-pos=%d\n", opcode, oppos);
+ return oppos;
+ }
+ /* This case only happens if the writecnt/readcnt combination is
+ * impossible to achieve on ICH SPI.
+ */
+ return SPI_INVALID_LENGTH;
}
static int find_opcode(OPCODES *op, uint8_t opcode)
--
Kind regards, Stefan Tauner
More information about the flashrom
mailing list