Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S266468AbUFQM3Q (ORCPT ); Thu, 17 Jun 2004 08:29:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S266471AbUFQM3P (ORCPT ); Thu, 17 Jun 2004 08:29:15 -0400 Received: from p060192.ppp.asahi-net.or.jp ([221.113.60.192]:20979 "EHLO mitou.ysato.dip.jp") by vger.kernel.org with ESMTP id S266468AbUFQM26 (ORCPT ); Thu, 17 Jun 2004 08:28:58 -0400 Date: Thu, 17 Jun 2004 21:28:54 +0900 Message-ID: From: Yoshinori Sato To: Linus Torvalds Cc: linux kernel Mailing List Subject: [PATCH] H8/300 update (2/3) io.h cleanup User-Agent: Wanderlust/2.11.24 (Wonderwall) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4453 Lines: 162 - optimize byteswap - add noswap io mode - cleanup var type -- Yoshinori Sato 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; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/