public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ladislav Michl <ladis@linux-mips.org>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] Optimize flash_make_cmd for LE
Date: Tue, 4 Jan 2005 23:23:53 +0100	[thread overview]
Message-ID: <20050104222353.GA3969@orphique> (raw)

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;
 }
 
 /*

                 reply	other threads:[~2005-01-04 22:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050104222353.GA3969@orphique \
    --to=ladis@linux-mips.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox