[RFC/PATCH 3/12] powerpc: Remove #ifdef ISERIES from readb/writeb etc. in io.h

Michael Ellerman michael at ellerman.id.au
Tue Jan 17 14:22:14 EST 2006


Convert readb/writeb etc. to be compilable on a combined kernel.

 include/asm-powerpc/io.h |   74 ++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 57 insertions(+), 17 deletions(-)

Index: linux/include/asm-powerpc/io.h
===================================================================
--- linux.orig/include/asm-powerpc/io.h
+++ linux/include/asm-powerpc/io.h
@@ -45,12 +45,6 @@ extern unsigned long io_page_mask;
 			    & io_page_mask)
 
 #ifdef CONFIG_PPC_ISERIES
-#define readb(addr)		iSeries_Read_Byte(addr)
-#define readw(addr)		iSeries_Read_Word(addr)
-#define readl(addr)		iSeries_Read_Long(addr)
-#define writeb(data, addr)	iSeries_Write_Byte((data),(addr))
-#define writew(data, addr)	iSeries_Write_Word((data),(addr))
-#define writel(data, addr)	iSeries_Write_Long((data),(addr))
 #define memset_io(a,b,c)	iSeries_memset_io((a),(b),(c))
 #define memcpy_fromio(a,b,c)	iSeries_memcpy_fromio((a), (b), (c))
 #define memcpy_toio(a,b,c)	iSeries_memcpy_toio((a), (b), (c))
@@ -69,14 +63,6 @@ extern unsigned long io_page_mask;
 #define insw_ns(port, buf, ns)	_insw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns))
 #define insl_ns(port, buf, nl)	_insl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl))
 #else
-#define readb(addr)		eeh_readb(addr)
-#define readw(addr)		eeh_readw(addr)
-#define readl(addr)		eeh_readl(addr)
-#define readq(addr)		eeh_readq(addr)
-#define writeb(data, addr)	eeh_writeb((data), (addr))
-#define writew(data, addr)	eeh_writew((data), (addr))
-#define writel(data, addr)	eeh_writel((data), (addr))
-#define writeq(data, addr)	eeh_writeq((data), (addr))
 #define memset_io(a,b,c)	eeh_memset_io((a),(b),(c))
 #define memcpy_fromio(a,b,c)	eeh_memcpy_fromio((a),(b),(c))
 #define memcpy_toio(a,b,c)	eeh_memcpy_toio((a),(b),(c))
@@ -167,7 +153,6 @@ static inline void __raw_writeq(unsigned
 
 	*(volatile unsigned long __force *)addr = v;
 }
-
 #define readb_relaxed(addr) readb(addr)
 #define readw_relaxed(addr) readw(addr)
 #define readl_relaxed(addr) readl(addr)
@@ -421,9 +406,64 @@ static inline void out_be64(volatile uns
 	__asm__ __volatile__("std%U0%X0 %1,%0; sync" : "=m" (*addr) : "r" (val));
 }
 
-#ifndef CONFIG_PPC_ISERIES 
 #include <asm/eeh.h>
-#endif
+
+static inline u8 readb(const volatile void __iomem *addr)
+{
+	if (firmware_has_feature(FW_FEATURE_ISERIES))
+		return iSeries_Read_Byte(addr);
+	else
+		return eeh_readb(addr);
+}
+
+static inline u16 readw(const volatile void __iomem *addr)
+{
+	if (firmware_has_feature(FW_FEATURE_ISERIES))
+		return iSeries_Read_Word(addr);
+	else
+		return eeh_readw(addr);
+}
+
+static inline u32 readl(const volatile void __iomem *addr)
+{
+	if (firmware_has_feature(FW_FEATURE_ISERIES))
+		return iSeries_Read_Long(addr);
+	else
+		return eeh_readb(addr);
+}
+
+static inline void writeb(u8 val, volatile void __iomem *addr)
+{
+	if (firmware_has_feature(FW_FEATURE_ISERIES))
+		iSeries_Write_Byte(val, addr);
+	else
+		eeh_writeb(val, addr);
+}
+
+static inline void writew(u16 val, volatile void __iomem *addr)
+{
+	if (firmware_has_feature(FW_FEATURE_ISERIES))
+		iSeries_Write_Word(val, addr);
+	else
+		eeh_writew(val, addr);
+}
+
+static inline void writel(u32 val, volatile void __iomem *addr)
+{
+	if (firmware_has_feature(FW_FEATURE_ISERIES))
+		iSeries_Write_Long(val, addr);
+	else
+		eeh_writel(val, addr);
+}
+
+#define writeq writeq	/* For dodgy drivers */
+static inline void writeq(u16 val, volatile void __iomem *addr)
+{
+	if (firmware_has_feature(FW_FEATURE_ISERIES))
+		BUG();	/* doesn't exist on iSeries ?? */
+	else
+		eeh_writeq(val, addr);
+}
 
 /**
  *	check_signature		-	find BIOS signatures



More information about the Linuxppc64-dev mailing list