[PATCH 05/12] add cpu native ordered io accessors

Sascha Hauer s.hauer at pengutronix.de
Fri Sep 23 05:24:13 EDT 2011


There are no generic native ordered io accessors. This sometimes
leads to

	v = in_be32(a);
	v = readl(a);

in generic drivers. Instead, use io accessors which are explicitely
native ordered.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 include/io.h |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/include/io.h b/include/io.h
index 8eb56b0..39b5e61 100644
--- a/include/io.h
+++ b/include/io.h
@@ -3,4 +3,21 @@
 
 #include <asm/io.h>
 
+/* cpu_read/cpu_write: cpu native io accessors */
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define cpu_readb(a)		readb(a)
+#define cpu_readw(a)		in_be16(a)
+#define cpu_readl(a)		in_be32(a)
+#define cpu_writeb(v, a)	writeb((v), (a))
+#define cpu_writew(v, a)	out_be16((a), (v))
+#define cpu_writel(v, a)	out_be32((a), (v))
+#else
+#define cpu_readb(a)		readb(a)
+#define cpu_readw(a)		readw(a)
+#define cpu_readl(a)		readl(a)
+#define cpu_writeb(v, a)	writeb((v), (a))
+#define cpu_writew(v, a)	writew((v), (a))
+#define cpu_writel(v, a)	writel((v), (a))
+#endif
+
 #endif /* __IO_H */
-- 
1.7.6.3




More information about the barebox mailing list