[U-Boot-Users] [PATCH] Optimize flash_make_cmd for LE
Ladislav Michl
ladis at linux-mips.org
Tue Jan 4 23:23:53 CET 2005
Hi,
patch below fixes ""WARNING: flash_make_cmd: unsuppported
LittleEndian mode" message when probing for nonexistent flash
in little endian mode. As a side effect more efficient and smaller
code is generated, which is always a Good Thing (TM).
CHANGELOG
* Optimize flash_make_cmd for little endian
Index: drivers/cfi_flash.c
===================================================================
RCS file: /cvsroot/u-boot/u-boot/drivers/cfi_flash.c,v
retrieving revision 1.15
diff -u -r1.15 cfi_flash.c
--- drivers/cfi_flash.c 18 Dec 2004 22:35:45 -0000 1.15
+++ drivers/cfi_flash.c 4 Jan 2005 22:13:45 -0000
@@ -47,7 +47,6 @@
#include <common.h>
#include <asm/processor.h>
#include <asm/byteorder.h>
-#include <linux/byteorder/swab.h>
#ifdef CFG_FLASH_CFI_DRIVER
/*
@@ -327,7 +326,7 @@
int i;
/* Init: no FLASHes known */
- for (i = 0; i < CFG_MAX_FLASH_BANKS; ++i) {
+ for (i = 0; i < CFG_MAX_FLASH_BANKS; i++) {
flash_info[i].flash_id = FLASH_UNKNOWN;
size += flash_info[i].size = flash_get_size (bank_base[i], i);
if (flash_info[i].flash_id == FLASH_UNKNOWN) {
@@ -778,32 +777,14 @@
static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf)
{
int i;
-
-#if defined(__LITTLE_ENDIAN)
- ushort stmpw;
- uint stmpi;
-#endif
uchar *cp = (uchar *) cmdbuf;
- for (i = 0; i < info->portwidth; i++)
- *cp++ = ((i + 1) % info->chipwidth) ? '\0' : cmd;
#if defined(__LITTLE_ENDIAN)
- switch (info->portwidth) {
- case FLASH_CFI_8BIT:
- break;
- case FLASH_CFI_16BIT:
- stmpw = *(ushort *) cmdbuf;
- *(ushort *) cmdbuf = __swab16 (stmpw);
- break;
- case FLASH_CFI_32BIT:
- stmpi = *(uint *) cmdbuf;
- *(uint *) cmdbuf = __swab32 (stmpi);
- break;
- default:
- puts ("WARNING: flash_make_cmd: unsuppported LittleEndian mode\n");
- break;
- }
+ for (i = info->portwidth; i > 0; i--)
+#else
+ for (i = 1; i <= info->portwidth; i++)
#endif
+ *cp++ = (i % info->chipwidth) ? 0 : cmd;
}
/*
More information about the U-Boot
mailing list