Skip to contentSkip to conversation

cfi: fix the incomplete erased status check in buffer write

PATCH Superseded htbegin 2 participants 3 messages Feb 19, 2012 – Mar 15, 2012 Memory technology devices (MTD)

lore
Share & tools
lore

htbegin

author
#0 lore raw

PATCH 1/1 cfi: fix the incomplete erased status check in buffer write

Without the fix, flash_write_cfibuffer will return timeout error instead of not-erased error when all bytes in the first word of a sector are 0xFF and other words are not.

Cc Stefan Roese <[email protected]>
---
 drivers/mtd/cfi_flash.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/cfi_flash.c +2 -2
index 722c3fc..35294bc 100644
@@ -873,7 +873,7 @@ static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp,
 	void *src = cp;
 	void *dst = (void *)dest;
 	void *dst2 = dst;
-	int flag = 0;
+	int flag = 1;
 	uint offset = 0;
 	unsigned int shift;
 	uchar write_cmd;
@@ -898,7 +898,7 @@ static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp,
 
 	cnt = len >> shift;
 
-	while ((cnt-- > 0) && (flag == 0)) {
+	while ((cnt-- > 0) && (flag == 1)) {
 		switch (info->portwidth) {
 		case FLASH_CFI_8BIT:
 			flag = ((flash_read8(dst2) & flash_read8(src)) ==
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/1 cfi: fix the incomplete erased status check in buffer write

Hi "htbegin",

first sorry for the late review.

Quoted 5 lines · On Sunday 19 February 2012 12:48:37 htbegin wrote:

Without the fix, flash_write_cfibuffer will return timeout error instead of not-erased error when all bytes in the first word of a sector are 0xFF and other words are not.

Please use your real name here in the s-o-b line.

Quoted 26 lines
---
 drivers/mtd/cfi_flash.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/cfi_flash.c +2 -2
index 722c3fc..35294bc 100644
@@ -873,7 +873,7 @@ static int flash_write_cfibuffer (flash_info_t * info,
 ulong dest, uchar * cp, void *src = cp;
 	void *dst = (void *)dest;
 	void *dst2 = dst;
-	int flag = 0;
+	int flag = 1;
 	uint offset = 0;
 	unsigned int shift;
 	uchar write_cmd;
@@ -898,7 +898,7 @@ static int flash_write_cfibuffer (flash_info_t * info,
 ulong dest, uchar * cp,
 
 	cnt = len >> shift;
 
-	while ((cnt-- > 0) && (flag == 0)) {
+	while ((cnt-- > 0) && (flag == 1)) {
 		switch (info->portwidth) {
 		case FLASH_CFI_8BIT:
Quoted 1 line

flag = ((flash_read8(dst2) & flash_read8(src)) ==

I checked your patch, and it seems to me that you have spotted a problem. But your problem description above doesn't seem to be totally correct. From my understanding, the loop checking for not erased flash aborts directly once 0xff is found. So that the check doesn't continue till the first non-0xff word as it should be.

Can you confirm this? Then please re-send you patch with a new patch description and a correct name in the Signed-off-by line.

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

author
#2 lore raw

PATCH v2 1/1 cfi: fix the incomplete erased status check in buffer write

Without the fix, flash_write_cfibuffer will terminate the erased status check once an all-0xFF word has been found instead of continuing the erased status check utill the first non-0xFF word.

Cc Stefan Roese <[email protected]>

---
Changes for v2:
- use my real name in the "Signed-off-by" line
- rewrite the patch description

---
 drivers/mtd/cfi_flash.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/cfi_flash.c +0 -0
index 722c3fc..35294bc 100644
@@ -873,7 +873,7 @@ static int flash_write_cfibuffer (flash_info_t *

info, ulong dest, uchar * cp,
void *src = cp;
void *dst = (void *)dest;
void *dst2 = dst;
- int flag = 0;
+ int flag = 1;
uint offset = 0;
unsigned int shift;
uchar write_cmd;
@@ -898,7 +898,7 @@ static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp,

cnt = len >> shift;

- while ((cnt-- > 0) && (flag == 0)) {
+ while ((cnt-- > 0) && (flag == 1)) {
switch (info->portwidth) {
case FLASH_CFI_8BIT:
flag = ((flash_read8(dst2) & flash_read8(src)) ==

Signature · 1 line
1.7.4.1