diff mbox

[U-Boot,01/10] microblaze: Fix in/out_be8/16/32 functions

Message ID 1314779721-1113-2-git-send-email-monstr@monstr.eu
State Changes Requested
Headers show

Commit Message

Michal Simek Aug. 31, 2011, 8:35 a.m. UTC
Use inline functions instead of macros because
of typechecking.

Signed-off-by: Michal Simek <monstr@monstr.eu>
---
 arch/microblaze/include/asm/io.h |   33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

Comments

Wolfgang Denk Sept. 7, 2011, 8:59 p.m. UTC | #1
Dear Michal Simek,

In message <1314779721-1113-2-git-send-email-monstr@monstr.eu> you wrote:
> Use inline functions instead of macros because
> of typechecking.

I don't understand the rationale of this change.

> -#define in_8(addr)	readb (addr)
> -#define in_be16(addr)	readw (addr)
> -#define in_be32(addr)	readl (addr)
> +extern inline int in_8(volatile unsigned char *addr)
> +{
> +	return readb(addr);
> +}

What;s the difference wether the type checking occurs for the in_8()
call or for the readb() call?

> +extern inline int in_be16(volatile unsigned short *addr)

Also, checkpatch says:

WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
#106: FILE: arch/microblaze/include/asm/io.h:49:
+extern inline int in_8(volatile unsigned char *addr)

WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
#111: FILE: arch/microblaze/include/asm/io.h:54:
+extern inline int in_be16(volatile unsigned short *addr)

WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
#119: FILE: arch/microblaze/include/asm/io.h:59:
+extern inline int in_be32(volatile unsigned int *addr)

WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
#124: FILE: arch/microblaze/include/asm/io.h:64:
+extern inline void out_8(volatile unsigned char *addr, char val)

WARNING: space prohibited between function name and open parenthesis '('
#126: FILE: arch/microblaze/include/asm/io.h:66:
+	outb (val, addr);

WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
#129: FILE: arch/microblaze/include/asm/io.h:69:
+extern inline void out_be16(volatile unsigned short *addr, short val)

WARNING: space prohibited between function name and open parenthesis '('
#131: FILE: arch/microblaze/include/asm/io.h:71:
+	outw (val, addr);

WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
#134: FILE: arch/microblaze/include/asm/io.h:74:
+extern inline void out_be32(volatile unsigned int *addr, int val)

WARNING: space prohibited between function name and open parenthesis '('
#136: FILE: arch/microblaze/include/asm/io.h:76:
+	outl (val, addr);

total: 0 errors, 9 warnings, 41 lines checked

Please fix.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/arch/microblaze/include/asm/io.h b/arch/microblaze/include/asm/io.h
index 7e190d1..a35700e 100644
--- a/arch/microblaze/include/asm/io.h
+++ b/arch/microblaze/include/asm/io.h
@@ -46,14 +46,35 @@ 
 #define outl(x, addr)	((void) writel (x, addr))
 
 /* Some #definitions to keep strange Xilinx code happy */
-#define in_8(addr)	readb (addr)
-#define in_be16(addr)	readw (addr)
-#define in_be32(addr)	readl (addr)
+extern inline int in_8(volatile unsigned char *addr)
+{
+	return readb(addr);
+}
+
+extern inline int in_be16(volatile unsigned short *addr)
+{
+	return readw(addr);
+}
 
-#define out_8(addr,x )	outb (x,addr)
-#define out_be16(addr,x )	outw (x,addr)
-#define out_be32(addr,x )	outl (x,addr)
+extern inline int in_be32(volatile unsigned int *addr)
+{
+	return readl(addr);
+}
 
+extern inline void out_8(volatile unsigned char *addr, char val)
+{
+	outb (val, addr);
+}
+
+extern inline void out_be16(volatile unsigned short *addr, short val)
+{
+	outw (val, addr);
+}
+
+extern inline void out_be32(volatile unsigned int *addr, int val)
+{
+	outl (val, addr);
+}
 
 #define inb_p(port)		inb((port))
 #define outb_p(val, port)	outb((val), (port))