Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: "Bradley D. LaRonde" <brad@ltc.com>
To: ralf@oss.sgi.com
Cc: linux-mips@oss.sgi.com
Subject: PATCH: io.h remove detrimental do {...} whiles, add sequence points, add const modifiers
Date: Fri, 7 Dec 2001 12:14:16 -0500	[thread overview]
Message-ID: <20011207121416.A9583@dev1.ltc.com> (raw)

2001-12-07  Bradley D. LaRonde <brad@ltc.com>

* remove detrimental do {...} whiles
* add sequence point to in[b,w,l] to prevent compiler from reordering
* add const modifier to outs[b,w,l] (quiets some compiler warnings)


--- linux-oss-2.4-2001-12-04/include/asm-mips/io.h	Thu Dec  6 17:07:24 2001
+++ linux-patch/include/asm-mips/io.h	Thu Dec  6 16:47:20 2001
@@ -63,7 +63,7 @@
 extern const unsigned long mips_io_port_base;
 
 #define set_io_port_base(base)	\
-	do { * (unsigned long *) &mips_io_port_base = (base); } while (0)
+	*(unsigned long *)&mips_io_port_base = (base);
 
 /*
  * Thanks to James van Artsdalen for a better timing-fix than
@@ -215,41 +215,37 @@
 
 
 #define outb(val,port)							\
-do {									\
-	*(volatile u8 *)(mips_io_port_base + (port)) = __ioswab8(val);	\
-} while(0)
+	*(volatile u8 *)(mips_io_port_base + (port)) = __ioswab8(val)
 
 #define outw(val,port)							\
-do {									\
-	*(volatile u16 *)(mips_io_port_base + (port)) = __ioswab16(val);	\
-} while(0)
+	*(volatile u16 *)(mips_io_port_base + (port)) = __ioswab16(val)
 
 #define outl(val,port)							\
-do {									\
-	*(volatile u32 *)(mips_io_port_base + (port)) = __ioswab32(val);\
-} while(0)
+	*(volatile u32 *)(mips_io_port_base + (port)) = __ioswab32(val)
 
+/* Don't do {...} while(0) these. */
 #define outb_p(val,port)						\
-do {									\
+({									\
 	*(volatile u8 *)(mips_io_port_base + (port)) = __ioswab8(val);	\
 	SLOW_DOWN_IO;							\
-} while(0)
+})
 
 #define outw_p(val,port)						\
-do {									\
+{									\
 	*(volatile u16 *)(mips_io_port_base + (port)) = __ioswab16(val);\
 	SLOW_DOWN_IO;							\
-} while(0)
+}
 
 #define outl_p(val,port)						\
-do {									\
+{									\
 	*(volatile u32 *)(mips_io_port_base + (port)) = __ioswab32(val);\
 	SLOW_DOWN_IO;							\
-} while(0)
+}
 
-#define inb(port) (__ioswab8(*(volatile u8 *)(mips_io_port_base + (port))))
-#define inw(port) (__ioswab16(*(volatile u16 *)(mips_io_port_base + (port))))
-#define inl(port) (__ioswab32(*(volatile u32 *)(mips_io_port_base + (port))))
+/* As in include/asm-arm/io.h, introduce sequence points ({...}) to prevent gcc * from reordering. */
+#define inb(port) ({ unsigned int __v = __ioswab8(*(volatile u8 *)(mips_io_port_base + (port))); __v; })
+#define inw(port) ({ unsigned int __v = __ioswab16(*(volatile u16 *)(mips_io_port_base + (port))); __v; })
+#define inl(port) ({ unsigned int __v = __ioswab32(*(volatile u32 *)(mips_io_port_base + (port))); __v; })
 
 #define inb_p(port)							\
 ({									\
@@ -278,7 +274,7 @@
 	__ioswab32(__val);						\
 })
 
-static inline void outsb(unsigned long port, void *addr, unsigned int count)
+static inline void outsb(unsigned long port, const void *addr, unsigned int count)
 {
 	while (count--) {
 		outb(*(u8 *)addr, port);
@@ -294,7 +290,7 @@
 	}
 }
 
-static inline void outsw(unsigned long port, void *addr, unsigned int count)
+static inline void outsw(unsigned long port, const void *addr, unsigned int count)
 {
 	while (count--) {
 		outw(*(u16 *)addr, port);
@@ -310,7 +306,7 @@
 	}
 }
 
-static inline void outsl(unsigned long port, void *addr, unsigned int count)
+static inline void outsl(unsigned long port, const void *addr, unsigned int count)
 {
 	while (count--) {
 		outl(*(u32 *)addr, port);

             reply	other threads:[~2001-12-07 18:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-07 17:14 Bradley D. LaRonde [this message]
2001-12-07 17:30 ` PATCH: io.h remove detrimental do {...} whiles, add sequence points, add const modifiers Geert Uytterhoeven
2001-12-07 17:38   ` Daniel Jacobowitz
2001-12-07 18:04     ` Jim Paris
2001-12-07 18:06     ` Ralf Baechle
2001-12-07 18:15       ` Jim Paris
2001-12-07 19:36         ` Justin Carlson
2001-12-07 19:43           ` Jim Paris
2001-12-07 20:23             ` Bradley D. LaRonde
2001-12-07 20:23               ` Bradley D. LaRonde
2001-12-07 20:44               ` Justin Carlson

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=20011207121416.A9583@dev1.ltc.com \
    --to=brad@ltc.com \
    --cc=linux-mips@oss.sgi.com \
    --cc=ralf@oss.sgi.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