public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yoshinori Sato <ysato@users.sourceforge.jp>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] H8/300 update (2/3) io.h cleanup
Date: Thu, 17 Jun 2004 21:28:54 +0900	[thread overview]
Message-ID: <m2isdqwepl.wl%ysato@users.sourceforge.jp> (raw)

- optimize byteswap
- add noswap io mode
- cleanup var type

-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>

diff -ru -X .exclude-diff linux-2.6.7/include/asm-h8300/io.h linux-2.6.7-h8300/include/asm-h8300/io.h
--- linux-2.6.7/include/asm-h8300/io.h	2004-06-16 14:19:36.000000000 +0900
+++ linux-2.6.7-h8300/include/asm-h8300/io.h	2004-06-17 19:31:01.000000000 +0900
@@ -35,27 +35,38 @@
 
 static inline unsigned short _swapw(volatile unsigned short v)
 {
-	unsigned short r,t;
-	__asm__("mov.b %w2,%x1\n\t"
-		"mov.b %x2,%w1\n\t"
-		"mov.w %1,%0"
-		:"=r"(r),"=r"(t)
-		:"r"(v));
+#ifndef H8300_IO_NOSWAP
+	unsigned short r;
+	__asm__("xor.b %w0,%x0\n\t"
+		"xor.b %x0,%w0\n\t"
+		"xor.b %w0,%x0"
+		:"=r"(r)
+		:"0"(v));
 	return r;
-}
-
-static inline unsigned int _swapl(volatile unsigned long v)
-{
-	unsigned int r,t;
-	__asm__("mov.b %w2,%x1\n\t"
-		"mov.b %x2,%w1\n\t"
-		"mov.w %f1,%e0\n\t"
-		"mov.w %e2,%f1\n\t"
-		"mov.b %w1,%x0\n\t"
-		"mov.b %x1,%w0"
-		:"=r"(r),"=r"(t)
-		:"r"(v));
+#else
+	return v;
+#endif
+}
+
+static inline unsigned long _swapl(volatile unsigned long v)
+{
+#ifndef H8300_IO_NOSWAP
+	unsigned long r;
+	__asm__("xor.b %w0,%x0\n\t"
+		"xor.b %x0,%w0\n\t"
+		"xor.b %w0,%x0\n\t"
+		"xor.w %e0,%f0\n\t"
+		"xor.w %f0,%e0\n\t"
+		"xor.w %e0,%f0\n\t"
+		"xor.b %w0,%x0\n\t"
+		"xor.b %x0,%w0\n\t"
+		"xor.b %w0,%x0"
+		:"=r"(r)
+		:"0"(v));
 	return r;
+#else
+	return v;
+#endif
 }
 
 #define readb(addr) \
@@ -109,12 +120,28 @@
 
 static inline void io_outsl(unsigned int addr, const void *buf, int len)
 {
-	volatile unsigned int *ap = (volatile unsigned int *) addr;
+	volatile unsigned long *ap = (volatile unsigned long *) addr;
 	unsigned long *bp = (unsigned long *) buf;
 	while (len--)
 		*ap = _swapl(*bp++);
 }
 
+static inline void io_outsw_noswap(unsigned int addr, const void *buf, int len)
+{
+	volatile unsigned short *ap = (volatile unsigned short *) addr;
+	unsigned short *bp = (unsigned short *) buf;
+	while (len--)
+		*ap = *bp++;
+}
+
+static inline void io_outsl_noswap(unsigned int addr, const void *buf, int len)
+{
+	volatile unsigned long *ap = (volatile unsigned long *) addr;
+	unsigned long *bp = (unsigned long *) buf;
+	while (len--)
+		*ap = *bp++;
+}
+
 static inline void io_insb(unsigned int addr, void *buf, int len)
 {
 	volatile unsigned char  *ap_b;
@@ -142,12 +169,28 @@
 
 static inline void io_insl(unsigned int addr, void *buf, int len)
 {
-	volatile unsigned int *ap = (volatile unsigned int *) addr;
+	volatile unsigned long *ap = (volatile unsigned long *) addr;
 	unsigned long *bp = (unsigned long *) buf;
 	while (len--)
 		*bp++ = _swapl(*ap);
 }
 
+static inline void io_insw_noswap(unsigned int addr, void *buf, int len)
+{
+	volatile unsigned short *ap = (volatile unsigned short *) addr;
+	unsigned short *bp = (unsigned short *) buf;
+	while (len--)
+		*bp++ = *ap;
+}
+
+static inline void io_insl_noswap(unsigned int addr, void *buf, int len)
+{
+	volatile unsigned long *ap = (volatile unsigned long *) addr;
+	unsigned long *bp = (unsigned long *) buf;
+	while (len--)
+		*bp++ = *ap;
+}
+
 /*
  *	make the short names macros so specific devices
  *	can override them as required
@@ -160,7 +203,8 @@
 #define inb(addr)    ((h8300_buswidth(addr))?readw((addr) & ~1) & 0xff:readb(addr))
 #define inw(addr)    _swapw(readw(addr))
 #define inl(addr)    _swapl(readl(addr))
-#define outb(x,addr) ((void)((h8300_buswidth(addr) && ((addr) & 1))?writew(x,(addr) & ~1):writeb(x,addr)))
+#define outb(x,addr) ((void)((h8300_buswidth(addr) && \
+                      ((addr) & 1))?writew(x,(addr) & ~1):writeb(x,addr)))
 #define outw(x,addr) ((void) writew(_swapw(x),addr))
 #define outl(x,addr) ((void) writel(_swapl(x),addr))
 
@@ -227,7 +271,7 @@
 	return *(volatile unsigned short*)addr;
 }
 
-static __inline__ unsigned int ctrl_inl(unsigned long addr)
+static __inline__ unsigned long ctrl_inl(unsigned long addr)
 {
 	return *(volatile unsigned long*)addr;
 }
@@ -242,7 +286,7 @@
 	*(volatile unsigned short*)addr = b;
 }
 
-static __inline__ void ctrl_outl(unsigned int b, unsigned long addr)
+static __inline__ void ctrl_outl(unsigned long b, unsigned long addr)
 {
         *(volatile unsigned long*)addr = b;
 }

                 reply	other threads:[~2004-06-17 12:29 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=m2isdqwepl.wl%ysato@users.sourceforge.jp \
    --to=ysato@users.sourceforge.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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