summaryrefslogtreecommitdiff
path: root/ichspi.c
diff options
context:
space:
mode:
authorstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2012-05-06 15:11:26 +0000
committerstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2012-05-06 15:11:26 +0000
commit5822735a95c43cdf7292f455b674c0649abebd94 (patch)
tree5f844aeb34346307f2b6dd7693bd6388a057ed5b /ichspi.c
parent001ddd97db568c272d532e0d9845e1bb15504724 (diff)
downloadflashrom-5822735a95c43cdf7292f455b674c0649abebd94.tar.gz
Refine reprogram_opcode_on_the_fly to indicate wrong readcnt/writecnt combinations.
Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1531 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'ichspi.c')
-rw-r--r--ichspi.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/ichspi.c b/ichspi.c
index 403d763..b7d312c 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -405,18 +405,16 @@ static int reprogram_opcode_on_the_fly(uint8_t opcode, unsigned int writecnt, un
spi_type = SPI_OPCODE_TYPE_READ_NO_ADDRESS;
else if (writecnt == 4) // and readcnt is > 0
spi_type = SPI_OPCODE_TYPE_READ_WITH_ADDRESS;
- // else we have an invalid case, will be handled below
- }
- 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_pdbg ("on-the-fly OPCODE (0x%02X) re-programmed, op-pos=%d\n", opcode, oppos);
- return oppos;
- }
- return -1;
+ 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_pdbg ("on-the-fly OPCODE (0x%02X) re-programmed, op-pos=%d\n", opcode, oppos);
+ return oppos;
}
static int find_opcode(OPCODES *op, uint8_t opcode)
@@ -1001,7 +999,10 @@ static int ich_spi_send_command(struct flashctx *flash, unsigned int writecnt,
if (opcode_index == -1) {
if (!ichspi_lock)
opcode_index = reprogram_opcode_on_the_fly(cmd, writecnt, readcnt);
- if (opcode_index == -1) {
+ if (opcode_index == SPI_INVALID_LENGTH) {
+ msg_pdbg("OPCODE 0x%02x has unsupported length, will not execute.\n", cmd);
+ return SPI_INVALID_LENGTH;
+ } else if (opcode_index == -1) {
msg_pdbg("Invalid OPCODE 0x%02x, will not execute.\n",
cmd);
return SPI_INVALID_OPCODE;