public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH]env_nand.c Added bad block management	for environment variables
Date: Fri, 30 May 2008 12:28:42 -0500	[thread overview]
Message-ID: <20080530172842.GA2950@loki.buserror.net> (raw)
In-Reply-To: <c13b1cfc0805300814l77dec881w7f7fe32ff774baa6@mail.gmail.com>

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

  reply	other threads:[~2008-05-30 17:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-27 14:01 [U-Boot-Users] [PATCH]env_nand.c Added bad block management for environment variables Stuart Wood
2008-05-28 17:57 ` Scott Wood
2008-05-29 17:14   ` Stuart Wood
2008-05-29 17:30     ` Scott Wood
2008-05-29 17:32       ` Scott Wood
2008-05-30 15:14         ` Stuart Wood
2008-05-30 17:28           ` Scott Wood [this message]
2008-05-30 20:05             ` Stuart Wood
2008-06-02 20:03               ` Scott Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080530172842.GA2950@loki.buserror.net \
    --to=scottwood@freescale.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox