Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 453c9abd authored by Sam Ravnborg's avatar Sam Ravnborg Committed by David S. Miller
Browse files

sparc64: avoid code duplication in io_64.h



Several of the small IO functions ended up having the same implementation.
Use __raw_{read,write}* + {read,write}* as base for the others.

Continue to use static inline functions to get full type check.
The size of vmlinux for a defconfig build was the same when
using static inline and macros for the functions - so there
was no size win when using macros.

This was tested with gcc 4.8.2 + binutils 2.24.
For such simple constructs I assume older gcc's will
do the same job.

Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent add79d68
Loading
Loading
Loading
Loading
+15 −85
Original line number Original line Diff line number Diff line
@@ -187,67 +187,37 @@ static inline void writeq(u64 q, volatile void __iomem *addr)
#define inb inb
#define inb inb
static inline u8 inb(unsigned long addr)
static inline u8 inb(unsigned long addr)
{
{
	u8 ret;
	return readb((volatile void __iomem *)addr);

	__asm__ __volatile__("lduba\t[%1] %2, %0\t/* pci_inb */"
			     : "=r" (ret)
			     : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
			     : "memory");

	return ret;
}
}


#define inw inw
#define inw inw
static inline u16 inw(unsigned long addr)
static inline u16 inw(unsigned long addr)
{
{
	u16 ret;
	return readw((volatile void __iomem *)addr);

	__asm__ __volatile__("lduha\t[%1] %2, %0\t/* pci_inw */"
			     : "=r" (ret)
			     : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
			     : "memory");

	return ret;
}
}


#define inl inl
#define inl inl
static inline u32 inl(unsigned long addr)
static inline u32 inl(unsigned long addr)
{
{
	u32 ret;
	return readl((volatile void __iomem *)addr);

	__asm__ __volatile__("lduwa\t[%1] %2, %0\t/* pci_inl */"
			     : "=r" (ret)
			     : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
			     : "memory");

	return ret;
}
}


#define outb outb
#define outb outb
static inline void outb(u8 b, unsigned long addr)
static inline void outb(u8 b, unsigned long addr)
{
{
	__asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_outb */"
	writeb(b, (volatile void __iomem *)addr);
			     : /* no outputs */
			     : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
			     : "memory");
}
}


#define outw outw
#define outw outw
static inline void outw(u16 w, unsigned long addr)
static inline void outw(u16 w, unsigned long addr)
{
{
	__asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_outw */"
	writew(w, (volatile void __iomem *)addr);
			     : /* no outputs */
			     : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
			     : "memory");
}
}


#define outl outl
#define outl outl
static inline void outl(u32 l, unsigned long addr)
static inline void outl(u32 l, unsigned long addr)
{
{
	__asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_outl */"
	writel(l, (volatile void __iomem *)addr);
			     : /* no outputs */
			     : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
			     : "memory");
}
}




@@ -309,82 +279,42 @@ static inline void iowrite32_rep(void __iomem *port, const void *buf, unsigned l
 */
 */
static inline u8 sbus_readb(const volatile void __iomem *addr)
static inline u8 sbus_readb(const volatile void __iomem *addr)
{
{
	u8 ret;
	return __raw_readb(addr);

	__asm__ __volatile__("lduba\t[%1] %2, %0\t/* sbus_readb */"
			     : "=r" (ret)
			     : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
			     : "memory");

	return ret;
}
}


static inline u16 sbus_readw(const volatile void __iomem *addr)
static inline u16 sbus_readw(const volatile void __iomem *addr)
{
{
	u16 ret;
	return __raw_readw(addr);

	__asm__ __volatile__("lduha\t[%1] %2, %0\t/* sbus_readw */"
			     : "=r" (ret)
			     : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
			     : "memory");

	return ret;
}
}


static inline u32 sbus_readl(const volatile void __iomem *addr)
static inline u32 sbus_readl(const volatile void __iomem *addr)
{
{
	u32 ret;
	return __raw_readl(addr);

	__asm__ __volatile__("lduwa\t[%1] %2, %0\t/* sbus_readl */"
			     : "=r" (ret)
			     : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
			     : "memory");

	return ret;
}
}


static inline u64 sbus_readq(const volatile void __iomem *addr)
static inline u64 sbus_readq(const volatile void __iomem *addr)
{
{
	u64 ret;
	return __raw_readq(addr);

	__asm__ __volatile__("ldxa\t[%1] %2, %0\t/* sbus_readq */"
			     : "=r" (ret)
			     : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
			     : "memory");

	return ret;
}
}


static inline void sbus_writeb(u8 b, volatile void __iomem *addr)
static inline void sbus_writeb(u8 b, volatile void __iomem *addr)
{
{
	__asm__ __volatile__("stba\t%r0, [%1] %2\t/* sbus_writeb */"
	__raw_writeb(b, addr);
			     : /* no outputs */
			     : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
			     : "memory");
}
}


static inline void sbus_writew(u16 w, volatile void __iomem *addr)
static inline void sbus_writew(u16 w, volatile void __iomem *addr)
{
{
	__asm__ __volatile__("stha\t%r0, [%1] %2\t/* sbus_writew */"
	__raw_writew(w, addr);
			     : /* no outputs */
			     : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
			     : "memory");
}
}


static inline void sbus_writel(u32 l, volatile void __iomem *addr)
static inline void sbus_writel(u32 l, volatile void __iomem *addr)
{
{
	__asm__ __volatile__("stwa\t%r0, [%1] %2\t/* sbus_writel */"
	__raw_writel(l, addr);
			     : /* no outputs */
			     : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
			     : "memory");
}
}


static inline void sbus_writeq(u64 l, volatile void __iomem *addr)
static inline void sbus_writeq(u64 q, volatile void __iomem *addr)
{
{
	__asm__ __volatile__("stxa\t%r0, [%1] %2\t/* sbus_writeq */"
	__raw_writeq(q, addr);
			     : /* no outputs */
			     : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)
			     : "memory");
}
}


static inline void sbus_memset_io(volatile void __iomem *dst, int c, __kernel_size_t n)
static inline void sbus_memset_io(volatile void __iomem *dst, int c, __kernel_size_t n)