From: Conke Hu <conke.hu@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] "nand lock status" bug fix
Date: Thu, 19 Jul 2007 04:32:15 +0800 [thread overview]
Message-ID: <5767b9100707181332o7edd5993nccc1132cdb421939@mail.gmail.com> (raw)
there are 2 bugs in the code of nand command "nand lock status"
(function do_nand() in common/cmd_nand.c):
1. "last_status" defined but never step forward.
2. the last page never be printed
the following patch fixes them.
----------------------------------------
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index cb62661..7e00c97 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -388,7 +388,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc,
char *argv[])
if (status) {
ulong block_start = 0;
ulong off;
- int last_status = -1;
+ int last_status;
struct nand_chip *nand_chip = nand->priv;
/* check the WP bit */
@@ -396,16 +396,15 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int
argc, char *argv[])
printf("device is %swrite protected\n",
(nand_chip->read_byte(nand) & 0x80 ?
"NOT " : "" ) );
-
- for (off = 0; off < nand->size; off += nand->oobblock) {
- int s = nand_get_lock_status(nand, off);
+
+ last_status = nand_get_lock_status(nand, 0);
+ for (off = nand->oobblock; off < nand->size; off += nand->oobblock) {
+ int cur_status = nand_get_lock_status(nand, off);
/* print message only if status has changed
* or at end of chip
*/
- if (off == nand->size - nand->oobblock
- || (s != last_status && off != 0)) {
-
+ if (cur_status != last_status) {
printf("%08x - %08x: %8d pages %s%s%s\n",
block_start,
off-1,
@@ -413,10 +412,20 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int
argc, char *argv[])
((last_status & NAND_LOCK_STATUS_TIGHT) ? "TIGHT " : ""),
((last_status & NAND_LOCK_STATUS_LOCK) ? "LOCK " : ""),
((last_status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : ""));
+
+ last_status = cur_status;
+ block_start = off;
}
+ }
+
+ printf("%08x - %08x: %8d pages %s%s%s\n",
+ block_start,
+ off-1,
+ (off-block_start)/nand->oobblock,
+ ((last_status & NAND_LOCK_STATUS_TIGHT) ? "TIGHT " : ""),
+ ((last_status & NAND_LOCK_STATUS_LOCK) ? "LOCK " : ""),
+ ((last_status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : ""));
- last_status = s;
- }
} else {
if (!nand_lock(nand, tight)) {
puts("NAND flash successfully locked\n");
next reply other threads:[~2007-07-18 20:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-18 20:32 Conke Hu [this message]
2007-07-18 20:36 ` [U-Boot-Users] [PATCH] "nand lock status" bug fix Conke Hu
2007-07-22 4:19 ` Conke Hu
2007-07-22 11:28 ` Stefan Roese
2007-07-23 15:09 ` Conke Hu
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=5767b9100707181332o7edd5993nccc1132cdb421939@mail.gmail.com \
--to=conke.hu@gmail.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