Commit 00afcdcf authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Linus Torvalds

[PATCH] ppc64: annotate remaining IO accessors

This patch adds proper __iomem annotations to the remaning IO macros on
ppc64, and removes now useless casts from eeh.h. This fixes the sparse
warnings in mpic.c among others.

I need to do an equivalent things for ppc32 (though I think viro did
some of it already) and fix users.
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 9b981f82
...@@ -110,114 +110,116 @@ int eeh_unregister_notifier(struct notifier_block *nb); ...@@ -110,114 +110,116 @@ int eeh_unregister_notifier(struct notifier_block *nb);
/* /*
* MMIO read/write operations with EEH support. * MMIO read/write operations with EEH support.
*/ */
static inline u8 eeh_readb(const volatile void __iomem *addr) { static inline u8 eeh_readb(const volatile void __iomem *addr)
volatile u8 *vaddr = (volatile u8 __force *) addr; {
u8 val = in_8(vaddr); u8 val = in_8(addr);
if (EEH_POSSIBLE_ERROR(val, u8)) if (EEH_POSSIBLE_ERROR(val, u8))
return eeh_check_failure(addr, val); return eeh_check_failure(addr, val);
return val; return val;
} }
static inline void eeh_writeb(u8 val, volatile void __iomem *addr) { static inline void eeh_writeb(u8 val, volatile void __iomem *addr)
volatile u8 *vaddr = (volatile u8 __force *) addr; {
out_8(vaddr, val); out_8(addr, val);
} }
static inline u16 eeh_readw(const volatile void __iomem *addr) { static inline u16 eeh_readw(const volatile void __iomem *addr)
volatile u16 *vaddr = (volatile u16 __force *) addr; {
u16 val = in_le16(vaddr); u16 val = in_le16(addr);
if (EEH_POSSIBLE_ERROR(val, u16)) if (EEH_POSSIBLE_ERROR(val, u16))
return eeh_check_failure(addr, val); return eeh_check_failure(addr, val);
return val; return val;
} }
static inline void eeh_writew(u16 val, volatile void __iomem *addr) { static inline void eeh_writew(u16 val, volatile void __iomem *addr)
volatile u16 *vaddr = (volatile u16 __force *) addr; {
out_le16(vaddr, val); out_le16(addr, val);
} }
static inline u16 eeh_raw_readw(const volatile void __iomem *addr) { static inline u16 eeh_raw_readw(const volatile void __iomem *addr)
volatile u16 *vaddr = (volatile u16 __force *) addr; {
u16 val = in_be16(vaddr); u16 val = in_be16(addr);
if (EEH_POSSIBLE_ERROR(val, u16)) if (EEH_POSSIBLE_ERROR(val, u16))
return eeh_check_failure(addr, val); return eeh_check_failure(addr, val);
return val; return val;
} }
static inline void eeh_raw_writew(u16 val, volatile void __iomem *addr) { static inline void eeh_raw_writew(u16 val, volatile void __iomem *addr) {
volatile u16 *vaddr = (volatile u16 __force *) addr; volatile u16 __iomem *vaddr = (volatile u16 __iomem *) addr;
out_be16(vaddr, val); out_be16(vaddr, val);
} }
static inline u32 eeh_readl(const volatile void __iomem *addr) { static inline u32 eeh_readl(const volatile void __iomem *addr)
volatile u32 *vaddr = (volatile u32 __force *) addr; {
u32 val = in_le32(vaddr); u32 val = in_le32(addr);
if (EEH_POSSIBLE_ERROR(val, u32)) if (EEH_POSSIBLE_ERROR(val, u32))
return eeh_check_failure(addr, val); return eeh_check_failure(addr, val);
return val; return val;
} }
static inline void eeh_writel(u32 val, volatile void __iomem *addr) { static inline void eeh_writel(u32 val, volatile void __iomem *addr)
volatile u32 *vaddr = (volatile u32 __force *) addr; {
out_le32(vaddr, val); out_le32(addr, val);
} }
static inline u32 eeh_raw_readl(const volatile void __iomem *addr) { static inline u32 eeh_raw_readl(const volatile void __iomem *addr)
volatile u32 *vaddr = (volatile u32 __force *) addr; {
u32 val = in_be32(vaddr); u32 val = in_be32(addr);
if (EEH_POSSIBLE_ERROR(val, u32)) if (EEH_POSSIBLE_ERROR(val, u32))
return eeh_check_failure(addr, val); return eeh_check_failure(addr, val);
return val; return val;
} }
static inline void eeh_raw_writel(u32 val, volatile void __iomem *addr) { static inline void eeh_raw_writel(u32 val, volatile void __iomem *addr)
volatile u32 *vaddr = (volatile u32 __force *) addr; {
out_be32(vaddr, val); out_be32(addr, val);
} }
static inline u64 eeh_readq(const volatile void __iomem *addr) { static inline u64 eeh_readq(const volatile void __iomem *addr)
volatile u64 *vaddr = (volatile u64 __force *) addr; {
u64 val = in_le64(vaddr); u64 val = in_le64(addr);
if (EEH_POSSIBLE_ERROR(val, u64)) if (EEH_POSSIBLE_ERROR(val, u64))
return eeh_check_failure(addr, val); return eeh_check_failure(addr, val);
return val; return val;
} }
static inline void eeh_writeq(u64 val, volatile void __iomem *addr) { static inline void eeh_writeq(u64 val, volatile void __iomem *addr)
volatile u64 *vaddr = (volatile u64 __force *) addr; {
out_le64(vaddr, val); out_le64(addr, val);
} }
static inline u64 eeh_raw_readq(const volatile void __iomem *addr) { static inline u64 eeh_raw_readq(const volatile void __iomem *addr)
volatile u64 *vaddr = (volatile u64 __force *) addr; {
u64 val = in_be64(vaddr); u64 val = in_be64(addr);
if (EEH_POSSIBLE_ERROR(val, u64)) if (EEH_POSSIBLE_ERROR(val, u64))
return eeh_check_failure(addr, val); return eeh_check_failure(addr, val);
return val; return val;
} }
static inline void eeh_raw_writeq(u64 val, volatile void __iomem *addr) { static inline void eeh_raw_writeq(u64 val, volatile void __iomem *addr)
volatile u64 *vaddr = (volatile u64 __force *) addr; {
out_be64(vaddr, val); out_be64(addr, val);
} }
#define EEH_CHECK_ALIGN(v,a) \ #define EEH_CHECK_ALIGN(v,a) \
((((unsigned long)(v)) & ((a) - 1)) == 0) ((((unsigned long)(v)) & ((a) - 1)) == 0)
static inline void eeh_memset_io(volatile void __iomem *addr, int c, unsigned long n) { static inline void eeh_memset_io(volatile void __iomem *addr, int c, unsigned long n)
void *vaddr = (void __force *) addr; {
u32 lc = c; u32 lc = c;
lc |= lc << 8; lc |= lc << 8;
lc |= lc << 16; lc |= lc << 16;
while(n && !EEH_CHECK_ALIGN(vaddr, 4)) { while(n && !EEH_CHECK_ALIGN(addr, 4)) {
*((volatile u8 *)vaddr) = c; *((volatile u8 *)addr) = c;
vaddr = (void *)((unsigned long)vaddr + 1); addr = (void *)((unsigned long)addr + 1);
n--; n--;
} }
while(n >= 4) { while(n >= 4) {
*((volatile u32 *)vaddr) = lc; *((volatile u32 *)addr) = lc;
vaddr = (void *)((unsigned long)vaddr + 4); addr = (void *)((unsigned long)addr + 4);
n -= 4; n -= 4;
} }
while(n) { while(n) {
*((volatile u8 *)vaddr) = c; *((volatile u8 *)addr) = c;
vaddr = (void *)((unsigned long)vaddr + 1); addr = (void *)((unsigned long)addr + 1);
n--; n--;
} }
__asm__ __volatile__ ("sync" : : : "memory"); __asm__ __volatile__ ("sync" : : : "memory");
} }
static inline void eeh_memcpy_fromio(void *dest, const volatile void __iomem *src, unsigned long n) { static inline void eeh_memcpy_fromio(void *dest, const volatile void __iomem *src,
unsigned long n)
{
void *vsrc = (void __force *) src; void *vsrc = (void __force *) src;
void *destsave = dest; void *destsave = dest;
unsigned long nsave = n; unsigned long nsave = n;
...@@ -254,7 +256,9 @@ static inline void eeh_memcpy_fromio(void *dest, const volatile void __iomem *sr ...@@ -254,7 +256,9 @@ static inline void eeh_memcpy_fromio(void *dest, const volatile void __iomem *sr
} }
} }
static inline void eeh_memcpy_toio(volatile void __iomem *dest, const void *src, unsigned long n) { static inline void eeh_memcpy_toio(volatile void __iomem *dest, const void *src,
unsigned long n)
{
void *vdest = (void __force *) dest; void *vdest = (void __force *) dest;
while(n && (!EEH_CHECK_ALIGN(vdest, 4) || !EEH_CHECK_ALIGN(src, 4))) { while(n && (!EEH_CHECK_ALIGN(vdest, 4) || !EEH_CHECK_ALIGN(src, 4))) {
...@@ -280,66 +284,75 @@ static inline void eeh_memcpy_toio(volatile void __iomem *dest, const void *src, ...@@ -280,66 +284,75 @@ static inline void eeh_memcpy_toio(volatile void __iomem *dest, const void *src,
#undef EEH_CHECK_ALIGN #undef EEH_CHECK_ALIGN
static inline u8 eeh_inb(unsigned long port) { static inline u8 eeh_inb(unsigned long port)
{
u8 val; u8 val;
if (!_IO_IS_VALID(port)) if (!_IO_IS_VALID(port))
return ~0; return ~0;
val = in_8((u8 *)(port+pci_io_base)); val = in_8((u8 __iomem *)(port+pci_io_base));
if (EEH_POSSIBLE_ERROR(val, u8)) if (EEH_POSSIBLE_ERROR(val, u8))
return eeh_check_failure((void __iomem *)(port), val); return eeh_check_failure((void __iomem *)(port), val);
return val; return val;
} }
static inline void eeh_outb(u8 val, unsigned long port) { static inline void eeh_outb(u8 val, unsigned long port)
{
if (_IO_IS_VALID(port)) if (_IO_IS_VALID(port))
out_8((u8 *)(port+pci_io_base), val); out_8((u8 __iomem *)(port+pci_io_base), val);
} }
static inline u16 eeh_inw(unsigned long port) { static inline u16 eeh_inw(unsigned long port)
{
u16 val; u16 val;
if (!_IO_IS_VALID(port)) if (!_IO_IS_VALID(port))
return ~0; return ~0;
val = in_le16((u16 *)(port+pci_io_base)); val = in_le16((u16 __iomem *)(port+pci_io_base));
if (EEH_POSSIBLE_ERROR(val, u16)) if (EEH_POSSIBLE_ERROR(val, u16))
return eeh_check_failure((void __iomem *)(port), val); return eeh_check_failure((void __iomem *)(port), val);
return val; return val;
} }
static inline void eeh_outw(u16 val, unsigned long port) { static inline void eeh_outw(u16 val, unsigned long port)
{
if (_IO_IS_VALID(port)) if (_IO_IS_VALID(port))
out_le16((u16 *)(port+pci_io_base), val); out_le16((u16 __iomem *)(port+pci_io_base), val);
} }
static inline u32 eeh_inl(unsigned long port) { static inline u32 eeh_inl(unsigned long port)
{
u32 val; u32 val;
if (!_IO_IS_VALID(port)) if (!_IO_IS_VALID(port))
return ~0; return ~0;
val = in_le32((u32 *)(port+pci_io_base)); val = in_le32((u32 __iomem *)(port+pci_io_base));
if (EEH_POSSIBLE_ERROR(val, u32)) if (EEH_POSSIBLE_ERROR(val, u32))
return eeh_check_failure((void __iomem *)(port), val); return eeh_check_failure((void __iomem *)(port), val);
return val; return val;
} }
static inline void eeh_outl(u32 val, unsigned long port) { static inline void eeh_outl(u32 val, unsigned long port)
{
if (_IO_IS_VALID(port)) if (_IO_IS_VALID(port))
out_le32((u32 *)(port+pci_io_base), val); out_le32((u32 __iomem *)(port+pci_io_base), val);
} }
/* in-string eeh macros */ /* in-string eeh macros */
static inline void eeh_insb(unsigned long port, void * buf, int ns) { static inline void eeh_insb(unsigned long port, void * buf, int ns)
_insb((u8 *)(port+pci_io_base), buf, ns); {
_insb((u8 __iomem *)(port+pci_io_base), buf, ns);
if (EEH_POSSIBLE_ERROR((*(((u8*)buf)+ns-1)), u8)) if (EEH_POSSIBLE_ERROR((*(((u8*)buf)+ns-1)), u8))
eeh_check_failure((void __iomem *)(port), *(u8*)buf); eeh_check_failure((void __iomem *)(port), *(u8*)buf);
} }
static inline void eeh_insw_ns(unsigned long port, void * buf, int ns) { static inline void eeh_insw_ns(unsigned long port, void * buf, int ns)
_insw_ns((u16 *)(port+pci_io_base), buf, ns); {
_insw_ns((u16 __iomem *)(port+pci_io_base), buf, ns);
if (EEH_POSSIBLE_ERROR((*(((u16*)buf)+ns-1)), u16)) if (EEH_POSSIBLE_ERROR((*(((u16*)buf)+ns-1)), u16))
eeh_check_failure((void __iomem *)(port), *(u16*)buf); eeh_check_failure((void __iomem *)(port), *(u16*)buf);
} }
static inline void eeh_insl_ns(unsigned long port, void * buf, int nl) { static inline void eeh_insl_ns(unsigned long port, void * buf, int nl)
_insl_ns((u32 *)(port+pci_io_base), buf, nl); {
_insl_ns((u32 __iomem *)(port+pci_io_base), buf, nl);
if (EEH_POSSIBLE_ERROR((*(((u32*)buf)+nl-1)), u32)) if (EEH_POSSIBLE_ERROR((*(((u32*)buf)+nl-1)), u32))
eeh_check_failure((void __iomem *)(port), *(u32*)buf); eeh_check_failure((void __iomem *)(port), *(u32*)buf);
} }
......
...@@ -273,7 +273,7 @@ static inline void iosync(void) ...@@ -273,7 +273,7 @@ static inline void iosync(void)
* and should not be used directly by device drivers. Use inb/readb * and should not be used directly by device drivers. Use inb/readb
* instead. * instead.
*/ */
static inline int in_8(volatile unsigned char *addr) static inline int in_8(const volatile unsigned char __iomem *addr)
{ {
int ret; int ret;
...@@ -282,13 +282,13 @@ static inline int in_8(volatile unsigned char *addr) ...@@ -282,13 +282,13 @@ static inline int in_8(volatile unsigned char *addr)
return ret; return ret;
} }
static inline void out_8(volatile unsigned char *addr, int val) static inline void out_8(volatile unsigned char __iomem *addr, int val)
{ {
__asm__ __volatile__("stb%U0%X0 %1,%0; sync" __asm__ __volatile__("stb%U0%X0 %1,%0; sync"
: "=m" (*addr) : "r" (val)); : "=m" (*addr) : "r" (val));
} }
static inline int in_le16(volatile unsigned short *addr) static inline int in_le16(const volatile unsigned short __iomem *addr)
{ {
int ret; int ret;
...@@ -297,7 +297,7 @@ static inline int in_le16(volatile unsigned short *addr) ...@@ -297,7 +297,7 @@ static inline int in_le16(volatile unsigned short *addr)
return ret; return ret;
} }
static inline int in_be16(volatile unsigned short *addr) static inline int in_be16(const volatile unsigned short __iomem *addr)
{ {
int ret; int ret;
...@@ -306,19 +306,19 @@ static inline int in_be16(volatile unsigned short *addr) ...@@ -306,19 +306,19 @@ static inline int in_be16(volatile unsigned short *addr)
return ret; return ret;
} }
static inline void out_le16(volatile unsigned short *addr, int val) static inline void out_le16(volatile unsigned short __iomem *addr, int val)
{ {
__asm__ __volatile__("sthbrx %1,0,%2; sync" __asm__ __volatile__("sthbrx %1,0,%2; sync"
: "=m" (*addr) : "r" (val), "r" (addr)); : "=m" (*addr) : "r" (val), "r" (addr));
} }
static inline void out_be16(volatile unsigned short *addr, int val) static inline void out_be16(volatile unsigned short __iomem *addr, int val)
{ {
__asm__ __volatile__("sth%U0%X0 %1,%0; sync" __asm__ __volatile__("sth%U0%X0 %1,%0; sync"
: "=m" (*addr) : "r" (val)); : "=m" (*addr) : "r" (val));
} }
static inline unsigned in_le32(volatile unsigned *addr) static inline unsigned in_le32(const volatile unsigned __iomem *addr)
{ {
unsigned ret; unsigned ret;
...@@ -327,7 +327,7 @@ static inline unsigned in_le32(volatile unsigned *addr) ...@@ -327,7 +327,7 @@ static inline unsigned in_le32(volatile unsigned *addr)
return ret; return ret;
} }
static inline unsigned in_be32(volatile unsigned *addr) static inline unsigned in_be32(const volatile unsigned __iomem *addr)
{ {
unsigned ret; unsigned ret;
...@@ -336,19 +336,19 @@ static inline unsigned in_be32(volatile unsigned *addr) ...@@ -336,19 +336,19 @@ static inline unsigned in_be32(volatile unsigned *addr)
return ret; return ret;
} }
static inline void out_le32(volatile unsigned *addr, int val) static inline void out_le32(volatile unsigned __iomem *addr, int val)
{ {
__asm__ __volatile__("stwbrx %1,0,%2; sync" : "=m" (*addr) __asm__ __volatile__("stwbrx %1,0,%2; sync" : "=m" (*addr)
: "r" (val), "r" (addr)); : "r" (val), "r" (addr));
} }
static inline void out_be32(volatile unsigned *addr, int val) static inline void out_be32(volatile unsigned __iomem *addr, int val)
{ {
__asm__ __volatile__("stw%U0%X0 %1,%0; sync" __asm__ __volatile__("stw%U0%X0 %1,%0; sync"
: "=m" (*addr) : "r" (val)); : "=m" (*addr) : "r" (val));
} }
static inline unsigned long in_le64(volatile unsigned long *addr) static inline unsigned long in_le64(const volatile unsigned long __iomem *addr)
{ {
unsigned long tmp, ret; unsigned long tmp, ret;
...@@ -367,7 +367,7 @@ static inline unsigned long in_le64(volatile unsigned long *addr) ...@@ -367,7 +367,7 @@ static inline unsigned long in_le64(volatile unsigned long *addr)
return ret; return ret;
} }
static inline unsigned long in_be64(volatile unsigned long *addr) static inline unsigned long in_be64(const volatile unsigned long __iomem *addr)
{ {
unsigned long ret; unsigned long ret;
...@@ -376,7 +376,7 @@ static inline unsigned long in_be64(volatile unsigned long *addr) ...@@ -376,7 +376,7 @@ static inline unsigned long in_be64(volatile unsigned long *addr)
return ret; return ret;
} }
static inline void out_le64(volatile unsigned long *addr, unsigned long val) static inline void out_le64(volatile unsigned long __iomem *addr, unsigned long val)
{ {
unsigned long tmp; unsigned long tmp;
...@@ -393,7 +393,7 @@ static inline void out_le64(volatile unsigned long *addr, unsigned long val) ...@@ -393,7 +393,7 @@ static inline void out_le64(volatile unsigned long *addr, unsigned long val)
: "=&r" (tmp) , "=&r" (val) : "1" (val) , "b" (addr) , "m" (*addr)); : "=&r" (tmp) , "=&r" (val) : "1" (val) , "b" (addr) , "m" (*addr));
} }
static inline void out_be64(volatile unsigned long *addr, unsigned long val) static inline void out_be64(volatile unsigned long __iomem *addr, unsigned long val)
{ {
__asm__ __volatile__("std%U0%X0 %1,%0; sync" : "=m" (*addr) : "r" (val)); __asm__ __volatile__("std%U0%X0 %1,%0; sync" : "=m" (*addr) : "r" (val));
} }
......
...@@ -41,7 +41,7 @@ struct pci_controller { ...@@ -41,7 +41,7 @@ struct pci_controller {
int first_busno; int first_busno;
int last_busno; int last_busno;
void *io_base_virt; void __iomem *io_base_virt;
unsigned long io_base_phys; unsigned long io_base_phys;
/* Some machines have a non 1:1 mapping of /* Some machines have a non 1:1 mapping of
...@@ -51,8 +51,8 @@ struct pci_controller { ...@@ -51,8 +51,8 @@ struct pci_controller {
unsigned long pci_io_size; unsigned long pci_io_size;
struct pci_ops *ops; struct pci_ops *ops;
volatile unsigned int *cfg_addr; volatile unsigned int __iomem *cfg_addr;
volatile unsigned char *cfg_data; volatile unsigned char __iomem *cfg_data;
/* Currently, we limit ourselves to 1 IO range and 3 mem /* Currently, we limit ourselves to 1 IO range and 3 mem
* ranges since the common pci_bus structure can't handle more * ranges since the common pci_bus structure can't handle more
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment