From dae409a27788774adb810f7cdb771ba7cce7af8a Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sat, 16 Apr 2005 15:25:54 -0700 Subject: [PATCH] add Big Endian variants of ioread/iowrite In the new io infrastructure, all of our operators are expecting the underlying device to be little endian (because the PCI bus, their main consumer, is LE). However, there are a fair few devices and busses in the world that are actually Big Endian. There's even evidence that some of these BE bus and chip types are attached to LE systems. Thus, there's a need for a BE equivalent of our io{read,write}{16,32} operations. The attached patch adds this as io{read,write}{16,32}be. When it's in, I'll add the first consume (the 53c700 SCSI chip driver). Signed-off-by: James Bottomley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- lib/iomap.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib') diff --git a/lib/iomap.c b/lib/iomap.c index 5e74390852b0..55689c5d3379 100644 --- a/lib/iomap.c +++ b/lib/iomap.c @@ -58,13 +58,23 @@ unsigned int fastcall ioread16(void __iomem *addr) { IO_COND(addr, return inw(port), return readw(addr)); } +unsigned int fastcall ioread16be(void __iomem *addr) +{ + IO_COND(addr, return inw(port), return be16_to_cpu(__raw_readw(addr))); +} unsigned int fastcall ioread32(void __iomem *addr) { IO_COND(addr, return inl(port), return readl(addr)); } +unsigned int fastcall ioread32be(void __iomem *addr) +{ + IO_COND(addr, return inl(port), return be32_to_cpu(__raw_readl(addr))); +} EXPORT_SYMBOL(ioread8); EXPORT_SYMBOL(ioread16); +EXPORT_SYMBOL(ioread16be); EXPORT_SYMBOL(ioread32); +EXPORT_SYMBOL(ioread32be); void fastcall iowrite8(u8 val, void __iomem *addr) { @@ -74,13 +84,23 @@ void fastcall iowrite16(u16 val, void __iomem *addr) { IO_COND(addr, outw(val,port), writew(val, addr)); } +void fastcall iowrite16be(u16 val, void __iomem *addr) +{ + IO_COND(addr, outw(val,port), __raw_writew(cpu_to_be16(val), addr)); +} void fastcall iowrite32(u32 val, void __iomem *addr) { IO_COND(addr, outl(val,port), writel(val, addr)); } +void fastcall iowrite32be(u32 val, void __iomem *addr) +{ + IO_COND(addr, outl(val,port), __raw_writel(cpu_to_be32(val), addr)); +} EXPORT_SYMBOL(iowrite8); EXPORT_SYMBOL(iowrite16); +EXPORT_SYMBOL(iowrite16be); EXPORT_SYMBOL(iowrite32); +EXPORT_SYMBOL(iowrite32be); /* * These are the "repeat MMIO read/write" functions. -- cgit v1.2.3-70-g09d2