Skip to contentSkip to conversation

cfi_flash: make the command u32 only

PATCH Superseded Sebastian Siewior 2 participants 4 messages Jul 15, 2008 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cfi_flash: make the command u32 only

This got change by commit 93c56f212c
[cfi_flash: support of long cmd in U-boot.]

Long is the wrong type because it will behave differently on 64bit machnines in a way that is probably not expected. u32 should be enough.

Cc Alexey Korolev <[email protected]>
Cc Vasiliy Leonenko <[email protected]>
---
 drivers/mtd/cfi_flash.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/mtd/cfi_flash.c +5 -5
index c0ea97b..799db71 100644
@@ -301,7 +301,7 @@ static inline void flash_unmap(flash_info_t *info, flash_sect_t sect,
 /*-----------------------------------------------------------------------
  * make a proper sized command based on the port and chip widths
  */
-static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf)
+static void flash_make_cmd (flash_info_t * info, uint cmd, void *cmdbuf)
 {
 	int i;
 	int cword_offset;
@@ -316,9 +316,9 @@ static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf)
 		val = *((uchar*)&cmd + cword_offset);
 #else
 		cp_offset = i - 1;
-		val = *((uchar*)&cmd + sizeof(ulong) - cword_offset - 1);
+		val = *((uchar*)&cmd + sizeof(uint) - cword_offset - 1);
 #endif
-		cp[cp_offset] = (cword_offset >= sizeof(ulong)) ? 0x00 : val;
+		cp[cp_offset] = (cword_offset >= sizeof(uint)) ? 0x00 : val;
 	}
 }
 
@@ -329,7 +329,7 @@ static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf)
 static void print_longlong (char *str, unsigned long long data)
 {
 	int i;
-	char *cp;
+	unsigned char *cp;
 
 	cp = (unsigned char *) &data;
 	for (i = 0; i < 8; i++)
@@ -433,7 +433,7 @@ static ulong flash_read_long (flash_info_t * info, flash_sect_t sect,
  * Write a proper sized command to the correct address
  */
 static void flash_write_cmd (flash_info_t * info, flash_sect_t sect,
-			     uint offset, ulong cmd)
+			     uint offset, uint cmd)
 {
 
 	void *addr;
Signature · 1 line
1.5.5.2
#1 lore raw

PATCH 1/1 cfi_flash: make the command u32 only

Quoted 6 lines · In message <[email protected]> you wrote:

This got change by commit 93c56f212c
[cfi_flash: support of long cmd in U-boot.]

Long is the wrong type because it will behave differently on 64bit machnines in a way that is probably not expected. u32 should be enough.

Well, if you write "u32" in the commit message...

Quoted 6 lines
drivers/mtd/cfi_flash.c +1 -1
-static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf)
+static void flash_make_cmd (flash_info_t * info, uint cmd, void *cmdbuf)
 {
 	int i;
 	int cword_offset;

drivers/mtd/cfi_flash.c static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf) · line 321

Quoted 8 lines
drivers/mtd/cfi_flash.c +2 -2
@@ -316,9 +316,9 @@ static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf)
 		val = *((uchar*)&cmd + cword_offset);
 #else
 		cp_offset = i - 1;
-		val = *((uchar*)&cmd + sizeof(ulong) - cword_offset - 1);
+		val = *((uchar*)&cmd + sizeof(uint) - cword_offset - 1);
 #endif
-		cp[cp_offset] = (cword_offset >= sizeof(ulong)) ? 0x00 : val;
+		cp[cp_offset] = (cword_offset >= sizeof(uint)) ? 0x00 : val;

...

...you should also use "u32" (and not uint) in the patch.

Please fix.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I have yet to add the ESP-driver to the kernel to read  the  mind  of
the user...                                       - Linus Torvalds in
      <[email protected]>
#2 lore raw

PATCH v2 1/1 cfi_flash: make the command u32 only

This got change by commit 93c56f212c
[cfi_flash: support of long cmd in U-boot.]

Long is the wrong type because it will behave differently on 64bit machnines in a way that is probably not expected. u32 should be enough.

Cc Alexey Korolev <[email protected]>
Cc Vasiliy Leonenko <[email protected]>
---
 drivers/mtd/cfi_flash.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/cfi_flash.c +4 -4
index c0ea97b..4340b1b 100644
@@ -301,7 +301,7 @@ static inline void flash_unmap(flash_info_t *info, flash_sect_t sect,
 /*-----------------------------------------------------------------------
  * make a proper sized command based on the port and chip widths
  */
-static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf)
+static void flash_make_cmd(flash_info_t *info, u32 cmd, void *cmdbuf)
 {
 	int i;
 	int cword_offset;
@@ -316,9 +316,9 @@ static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf)
 		val = *((uchar*)&cmd + cword_offset);
 #else
 		cp_offset = i - 1;
-		val = *((uchar*)&cmd + sizeof(ulong) - cword_offset - 1);
+		val = *((uchar*)&cmd + sizeof(u32) - cword_offset - 1);
 #endif
-		cp[cp_offset] = (cword_offset >= sizeof(ulong)) ? 0x00 : val;
+		cp[cp_offset] = (cword_offset >= sizeof(u32)) ? 0x00 : val;
 	}
 }
 
@@ -433,7 +433,7 @@ static ulong flash_read_long (flash_info_t * info, flash_sect_t sect,
  * Write a proper sized command to the correct address
  */
 static void flash_write_cmd (flash_info_t * info, flash_sect_t sect,
-			     uint offset, ulong cmd)
+			     uint offset, u32 cmd)
 {
 
 	void *addr;
Signature · 1 line
1.5.5.2
#3 lore raw

PATCH v2 1/1 cfi_flash: make the command u32 only

Quoted 7 lines · In message <[email protected]> you wrote:

This got change by commit 93c56f212c
[cfi_flash: support of long cmd in U-boot.]

Long is the wrong type because it will behave differently on 64bit machnines in a way that is probably not expected. u32 should be enough.

Quoted 6 lines
Cc Alexey Korolev <[email protected]>
Cc Vasiliy Leonenko <[email protected]>
---
 drivers/mtd/cfi_flash.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I have a theory that it's impossible to prove anything, but  I  can't
prove it.