"nand lock status" bug fix
PATCH 1/1 "nand lock status" bug fix
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.
----------------------------------------
common/cmd_nand.c +0 -0
@@ -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");
PATCH 1/1 "nand lock status" bug fix
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.
Signed-off-by: conke.hu at gmail.com
----------------------------------------
common/cmd_nand.c +0 -0
@@ -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");PATCH 1/1 "nand lock status" bug fix
Quoted 13 lines · Conke Hu
there are 2 bugs in the code of nand command "nand lock status" (function
do_nand()incommon/cmd_nand.c):
1. "last_status" defined but never step forward.
2. the last page never be printed
the following patch fixes them.Signed-off-by: conke.hu at gmail.com
----------------------------------------common/cmd_nand.c +0
-0
common/cmd_nand.c int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, · line 393
Quoted 8 lines
common/cmd_nand.c +1
-1@@ -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;
I am sorry but, anybody could tell me how to submit a patch pls? I am looking forward to any kind reply about this patch, but it seems nobody pays attention to it :(
Conke
PATCH 1/1 "nand lock status" bug fix
Hi Conke,
Quoted 3 lines · Conke Hu
I am sorry but, anybody could tell me how to submit a patch pls? I am looking forward to any kind reply about this patch, but it seems nobody pays attention to it :(
I am paying attention and it's on my list.
OK, here a quick note: Your patch is line wrapped. Please fix this problem in your mailer and resubmit this patch.
Thanks.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 1/1 "nand lock status" bug fix
Hi Stefan,
Quoted 12 lines · Stefan Roese
Hi Conke,
Quoted 3 lines · Conke Hu
I am sorry but, anybody could tell me how to submit a patch pls? I am looking forward to any kind reply about this patch, but it seems nobody pays attention to it :(
I am paying attention and it's on my list.
OK, here a quick note: Your patch is line wrapped. Please fix this problem in your mailer and resubmit this patch.
re-sent, pls see the attachment.
thanks!
Conke
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nand_lock_status.patch.gz
Type: application/x-gzip
Size: 773 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20070723/abe1ae9c/attachment.bin