public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] cfi_flash: fix flash on Big Endian machines.
@ 2008-07-10 12:35 Sebastian Siewior
  0 siblings, 0 replies; 12+ messages in thread
From: Sebastian Siewior @ 2008-07-10 12:35 UTC (permalink / raw)
  To: u-boot

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

That command seems to be access in a little endian way so
wrappers are required.
Long is the wrong type because it will behave differently on
64bit machnines in a way that is probably not expected.
int should be enough.

Cc: Alexey Korolev <akorolev@infradead.org>
Cc: Vasiliy Leonenko <vasiliy.leonenko@mail.ru>
Signed-off-by: Sebastian Siewior <bigeasy@linutronix.de>
---
 drivers/mtd/cfi_flash.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index c0ea97b..6770496 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -301,24 +301,26 @@ 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;
 	int cp_offset;
+	int cmd_le;
 	uchar val;
 	uchar *cp = (uchar *) cmdbuf;
 
+	cmd_le = cpu_to_le32(cmd);
 	for (i = info->portwidth; i > 0; i--){
 		cword_offset = (info->portwidth-i)%info->chipwidth;
 #if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA)
 		cp_offset = info->portwidth - i;
-		val = *((uchar*)&cmd + cword_offset);
+		val = *((uchar*)&cmd_le + cword_offset);
 #else
 		cp_offset = i - 1;
-		val = *((uchar*)&cmd + sizeof(ulong) - cword_offset - 1);
+		val = *((uchar*)&cmd_le + 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 +331,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 +435,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;
-- 
1.5.5.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-07-17 10:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20080714101829.GA11938@www.tglx.de>
2008-07-15  8:46 ` [U-Boot-Users] [PATCH] cfi_flash: fix flash on Big Endian machines Stefan Roese
2008-07-15  9:36   ` Sebastian Siewior
2008-07-15  9:48     ` Stefan Roese
2008-07-15  9:57       ` Sebastian Siewior
2008-07-15 12:57         ` Stefan Roese
2008-07-15 21:12           ` [U-Boot-Users] [PATCH] cfi_flash: fix flash on BE machines with CFG_WRITE_SWAPPED_DATA Sebastian Siewior
2008-07-15 22:05             ` Wolfgang Denk
2008-07-16  8:04               ` Sebastian Siewior
2008-07-16 18:04               ` [U-Boot-Users] [PATCH v2] " Sebastian Siewior
2008-07-17  9:46                 ` Stefan Roese
2008-07-17 10:41                   ` [U-Boot-Users] [PATCH v2] cfi_flash: fix flash on BE machineswith CFG_WRITE_SWAPPED_DATA Vasiliy Leoenenko
2008-07-10 12:35 [U-Boot-Users] [PATCH] cfi_flash: fix flash on Big Endian machines Sebastian Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox