[PATCH] asm-generic/io.h: convert readX defines to functions

From: Heiko Carstens
Date: Mon Jan 07 2013 - 08:17:23 EST

E.g. readl is defined like this

#define readl(addr) __le32_to_cpu(__raw_readl(addr))

If there is a readl() call that doesn't check the return value
this will cause a compile warning on big endian machines due to
the __le32_to_cpu macro magic.

E.g. code like this:


will generate the following compile warning:

warning: value computed is not used [-Wunused-value]

Convert the defines to functions so we get rid of these warnings.
With this patch we get rid of dozens of compile warnings on s390.

Signed-off-by: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
include/asm-generic/io.h | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 9e0ebe0..2d30764 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -54,8 +54,18 @@ static inline u32 __raw_readl(const volatile void __iomem *addr)

#define readb __raw_readb
-#define readw(addr) __le16_to_cpu(__raw_readw(addr))
-#define readl(addr) __le32_to_cpu(__raw_readl(addr))
+#define readw readw
+static inline u16 readw(const volatile void __iomem *addr)
+ return __le16_to_cpu(__raw_readw(addr));
+#define readl readl
+static inline u32 __raw_readl(const volatile void __iomem *addr)
+ return __le32_to_cpu(__raw_readl(addr));

#ifndef __raw_writeb
static inline void __raw_writeb(u8 b, volatile void __iomem *addr)
@@ -90,7 +100,11 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)

-#define readq(addr) __le64_to_cpu(__raw_readq(addr))
+#define readq readq
+static inline u64 readq(const volatile void __iomem *addr)
+ return __le64_to_cpu(__raw_readq(addr));

#ifndef __raw_writeq
static inline void __raw_writeq(u64 b, volatile void __iomem *addr)

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/