[flashrom] [PATCH] ichspi reprogram_opcode_on_the_fly return code fix

Stefan Tauner stefan.tauner at student.tuwien.ac.at
Sun May 6 14:18:32 CEST 2012


On Sat, 05 May 2012 01:22:12 +0200
Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net> wrote:

> Fix ICH SPI reprogram_opcode_on_the_fly return code.

i wouldnt call this a fix.

> Helpful for SFDP debugging.
> 
> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
> 
> Index: flashrom-sfdp_read_dummy_reduce_param_chunksize/ichspi.c
> ===================================================================
> --- flashrom-ichspi_invalid_length_consistent/ichspi.c	(Revision 1528)
> +++ flashrom-ichspi_invalid_length_consistent/ichspi.c	(Arbeitskopie)
> @@ -416,7 +416,10 @@
>  		msg_pdbg ("on-the-fly OPCODE (0x%02X) re-programmed, op-pos=%d\n", opcode, oppos);
>  		return oppos;
>  	}
> -	return -1;
> +	/* This case only happens if the writecnt/readcnt combination is
> +	 * impossible to achieve on ICH SPI.
> +	 */
> +	return SPI_INVALID_LENGTH;
>  }

imho it would make more sense to have less comments + a cleaner code
flow instead ;) see attached patch.

>  static int find_opcode(OPCODES *op, uint8_t opcode)
> @@ -1001,7 +1004,11 @@
>  	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;
> 
> 


-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Refine-reprogram_opcode_on_the_fly-to-indicate-wrong.patch
Type: text/x-patch
Size: 2241 bytes
Desc: not available
URL: <http://www.flashrom.org/pipermail/flashrom/attachments/20120506/8b18f60d/attachment.patch>


More information about the flashrom mailing list