Author: stefanct
Date: Sun May  6 17:11:26 2012
New Revision: 1531
URL: http://flashrom.org/trac/flashrom/changeset/1531

Log:
Refine reprogram_opcode_on_the_fly to indicate wrong readcnt/writecnt 
combinations.

Signed-off-by: Stefan Tauner <[email protected]>
Acked-by: Carl-Daniel Hailfinger <[email protected]>

Modified:
   trunk/ichspi.c

Modified: trunk/ichspi.c
==============================================================================
--- trunk/ichspi.c      Sat May  5 22:53:59 2012        (r1530)
+++ trunk/ichspi.c      Sun May  6 17:11:26 2012        (r1531)
@@ -405,18 +405,16 @@
                        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
+               else // we have an invalid case
+                       return SPI_INVALID_LENGTH;
        }
-       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;
+       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 @@
        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;

_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to