diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-07-14 10:26:56 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-07-14 10:26:56 +0000 |
commit | 142e30fcaa1c3a63a1f0baf0b802ef888a0c250b (patch) | |
tree | c286d89dadacecee2e68b84ce5606467e9ae33e8 /ichspi.c | |
parent | 78e4e127129398454813d1552b516638837c423e (diff) | |
download | flashrom-142e30fcaa1c3a63a1f0baf0b802ef888a0c250b.tar.gz flashrom-142e30fcaa1c3a63a1f0baf0b802ef888a0c250b.tar.bz2 flashrom-142e30fcaa1c3a63a1f0baf0b802ef888a0c250b.zip |
Use a distinct return code for SPI commands with unsupported/invalid length
Some drivers support only a few combinations of read/write length and
return error otherwise. Having a distinct return code for this error
means we can handle it in upper layers.
Corresponding to flashrom svn r653.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
Diffstat (limited to 'ichspi.c')
-rw-r--r-- | ichspi.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -599,10 +599,16 @@ static int run_opcode(OPCODE op, uint32_t offset, { switch (spi_controller) { case SPI_CONTROLLER_VIA: + if (datalength > 16) + return SPI_INVALID_LENGTH; return ich7_run_opcode(op, offset, datalength, data, 16); case SPI_CONTROLLER_ICH7: + if (datalength > 64) + return SPI_INVALID_LENGTH; return ich7_run_opcode(op, offset, datalength, data, 64); case SPI_CONTROLLER_ICH9: + if (datalength > 64) + return SPI_INVALID_LENGTH; return ich9_run_opcode(op, offset, datalength, data); default: printf_debug("%s: unsupported chipset\n", __FUNCTION__); @@ -686,6 +692,7 @@ int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr) { int a; + int result; int opcode_index = -1; const unsigned char cmd = *writearr; OPCODE *opcode; @@ -728,10 +735,10 @@ int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt, count = readcnt; } - if (run_opcode(*opcode, addr, count, data) != 0) { + result = run_opcode(*opcode, addr, count, data); + if (result) { printf_debug("run OPCODE 0x%02x failed\n", opcode->opcode); - return 1; } - return 0; + return result; } |