On Fri, May 30, 2008 at 11:14:10AM -0400, Stuart Wood wrote:
> +int writeenv(size_t offset, u_char * buf)

No space after '*'.

> +                     char_ptr = &buf[amount_saved];
> +                     if (nand_write(&nand_info[0], offset, &blocksize, 
> char_ptr)) {

Wrap long line.

> +                             return 1;
> +                     } else {

The "else" is superfluous.

> +             puts ("Erasing redundant Nand...\n");
> +             nand_erase(&nand_info[0], CFG_ENV_OFFSET_REDUND, CFG_ENV_RANGE);
> +

If erasing fails for reasons other than a bad block, we should abort.

If erasing fails due to a bad block, we should skip past it; however,
the current erase code fails and does not try to erase any further
blocks.  Use nand_erase_opts() instead.

> -     if (ret || total != CFG_ENV_SIZE)
> +     if (ret || total != CFG_ENV_SIZE) {
> +             puts("FAILED!\n");
>               return 1;
> +     }

total is no longer referenced anywhere but here and the initialization;
remove it.

> +     while (amount_loaded < CFG_ENV_SIZE && offset < end) {
> +             if (nand_block_isbad(&nand_info[0], offset)) {
> +                     offset += blocksize;
> +             } else {
> +                     char_ptr = &buf[amount_loaded];
> +                     nand_read(&nand_info[0], offset, &blocksize, char_ptr);

Please check the return value of nand_read.

-Scott

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users

Reply via email to