From: Tim Harvey <tharvey@gateworks.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [U-boot] [PATCH] env_nand: simplify readenv()
Date: Thu, 14 May 2015 11:48:40 -0700 [thread overview]
Message-ID: <1431629320-1538-1-git-send-email-tharvey@gateworks.com> (raw)
nand_read_skip_bad() already loops over blocks and handles bad block check
so eliminate this redundant logic.
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
common/env_nand.c | 32 ++++++--------------------------
1 file changed, 6 insertions(+), 26 deletions(-)
diff --git a/common/env_nand.c b/common/env_nand.c
index bab89fd..2036a0e 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -268,35 +268,15 @@ static int readenv(size_t offset, u_char *buf)
#else
static int readenv(size_t offset, u_char *buf)
{
- size_t end = offset + CONFIG_ENV_RANGE;
- size_t amount_loaded = 0;
- size_t blocksize, len;
- u_char *char_ptr;
+ nand_info_t *nand = &nand_info[0];
+ size_t len;
- blocksize = nand_info[0].erasesize;
- if (!blocksize)
+ len = CONFIG_ENV_SIZE;
+ debug("%s: offset=0x%08x len=0x%08x\n", __func__, offset, len);
+ if (nand_read_skip_bad(nand, offset, &len, NULL, nand->size, buf))
return 1;
- len = min(blocksize, (size_t)CONFIG_ENV_SIZE);
- debug("%s: offset=0x%08x blocksize=0x%08x len=0x%08x\n",
- __func__, offset, blocksize, len);
-
- while (amount_loaded < CONFIG_ENV_SIZE && offset < end) {
- if (nand_block_isbad(&nand_info[0], offset)) {
- offset += blocksize;
- } else {
- char_ptr = &buf[amount_loaded];
- if (nand_read_skip_bad(&nand_info[0], offset,
- &len, NULL,
- nand_info[0].size, char_ptr))
- return 1;
-
- offset += blocksize;
- amount_loaded += len;
- }
- }
-
- if (amount_loaded != CONFIG_ENV_SIZE)
+ if (len != CONFIG_ENV_SIZE)
return 1;
return 0;
--
1.9.1
next reply other threads:[~2015-05-14 18:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-14 18:48 Tim Harvey [this message]
2015-05-14 19:11 ` [U-Boot] [U-boot] [PATCH] env_nand: simplify readenv() 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=1431629320-1538-1-git-send-email-tharvey@gateworks.com \
--to=tharvey@gateworks.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