[U-Boot] [PATCH v2] Add 'sf update' command to do smart SPI flash update

Mike Frysinger vapier at gentoo.org
Fri Aug 19 21:03:47 CEST 2011


On Friday, August 19, 2011 14:19:42 Simon Glass wrote:
> +static const char *write_block(struct spi_flash *flash, u32 offset,
> +		size_t len, const char *buf, char *cmp_buf, size_t *skipped)

"spi_flash_update_block" is probably a better name.  after all, you're doing 
more (and sometimes less) than "writing a block".

> +		return"read";

need a space in the middle there

> +		printf("SPI flash %s failed\n", err_oper);

how about:
	SPI flash update failed in %s step
running 'sf update' on the command line would be obvious where the problem is 
coming from, but if you have a bunch of sf commands in a script and only see 
one error, it's probably confusing to quickly pick out where the error 
occurred.

> -	if (strcmp(argv[0], "read") == 0)
> +	if (strcmp(argv[0], "update") == 0)
> +		ret = spi_flash_update(flash, offset, len, buf);
> +	else if (strcmp(argv[0], "read") == 0)
>  		ret = spi_flash_read(flash, offset, len, buf);
> ...
> -	if (strcmp(cmd, "read") == 0 || strcmp(cmd, "write") == 0)
> +	if (strcmp(cmd, "read") == 0 || strcmp(cmd, "write") == 0 ||
> +			strcmp(cmd, "update") == 0)
>  		ret = do_spi_flash_read_write(argc, argv);
>  	else if (strcmp(cmd, "erase") == 0)
>  		ret = do_spi_flash_erase(argc, argv);

these duplicate strcmp's make me wonder if a follow up patch should turn these 
into a tokenize step first and then later code works off that

rest looks fine
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110819/d9738178/attachment.pgp 


More information about the U-Boot mailing list