diff options
author | Paul Mundt <lethal@linux-sh.org> | 2008-10-01 02:12:27 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-10-01 02:12:27 -0400 |
commit | 64c9627c2628bc3bd3291710b8ee6f8335883f8b (patch) | |
tree | fee0816511f68f687f500a7e7ae7c8adf92a0f45 | |
parent | bdeb3be7cc6911477b7169dad62a427d7a263d02 (diff) |
sh: Fix up the __raw_read/writeX() definitions.
These were doing largely bogus things and using the wrong typing for
the address. Bring these in line with the ARM definitions.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r-- | arch/sh/include/asm/io.h | 77 | ||||
-rw-r--r-- | arch/sh/lib/io.c | 8 |
2 files changed, 40 insertions, 45 deletions
diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h index 1857666136f2..d9e794eff830 100644 --- a/arch/sh/include/asm/io.h +++ b/arch/sh/include/asm/io.h | |||
@@ -101,44 +101,33 @@ | |||
101 | #define outsw __outsw | 101 | #define outsw __outsw |
102 | #define outsl __outsl | 102 | #define outsl __outsl |
103 | 103 | ||
104 | #define __raw_readb(a) __readb((void __iomem *)(a)) | 104 | #define __raw_writeb(v,a) (__chk_io_ptr(a), *(volatile unsigned char __force *)(a) = (v)) |
105 | #define __raw_readw(a) __readw((void __iomem *)(a)) | 105 | #define __raw_writew(v,a) (__chk_io_ptr(a), *(volatile unsigned short __force *)(a) = (v)) |
106 | #define __raw_readl(a) __readl((void __iomem *)(a)) | 106 | #define __raw_writel(v,a) (__chk_io_ptr(a), *(volatile unsigned int __force *)(a) = (v)) |
107 | #define __raw_writeb(v, a) __writeb(v, (void __iomem *)(a)) | ||
108 | #define __raw_writew(v, a) __writew(v, (void __iomem *)(a)) | ||
109 | #define __raw_writel(v, a) __writel(v, (void __iomem *)(a)) | ||
110 | 107 | ||
111 | void __raw_writesl(unsigned long addr, const void *data, int longlen); | 108 | #define __raw_readb(a) (__chk_io_ptr(a), *(volatile unsigned char __force *)(a)) |
112 | void __raw_readsl(unsigned long addr, void *data, int longlen); | 109 | #define __raw_readw(a) (__chk_io_ptr(a), *(volatile unsigned short __force *)(a)) |
110 | #define __raw_readl(a) (__chk_io_ptr(a), *(volatile unsigned int __force *)(a)) | ||
111 | |||
112 | void __raw_writesl(void __iomem *addr, const void *data, int longlen); | ||
113 | void __raw_readsl(const void __iomem *addr, void *data, int longlen); | ||
113 | 114 | ||
114 | /* | 115 | /* |
115 | * The platform header files may define some of these macros to use | 116 | * The platform header files may define some of these macros to use |
116 | * the inlined versions where appropriate. These macros may also be | 117 | * the inlined versions where appropriate. These macros may also be |
117 | * redefined by userlevel programs. | 118 | * redefined by userlevel programs. |
118 | */ | 119 | */ |
119 | #ifdef __readb | 120 | #define readb(a) ({ unsigned int r_ = __readb(a); mb(); r_; }) |
120 | # define readb(a) ({ unsigned int r_ = __raw_readb(a); mb(); r_; }) | 121 | #define readw(a) ({ unsigned int r_ = __readw(a); mb(); r_; }) |
121 | #endif | 122 | #define readl(a) ({ unsigned int r_ = __readl(a); mb(); r_; }) |
122 | #ifdef __raw_readw | ||
123 | # define readw(a) ({ unsigned int r_ = __raw_readw(a); mb(); r_; }) | ||
124 | #endif | ||
125 | #ifdef __raw_readl | ||
126 | # define readl(a) ({ unsigned int r_ = __raw_readl(a); mb(); r_; }) | ||
127 | #endif | ||
128 | 123 | ||
129 | #ifdef __raw_writeb | 124 | #define writeb(v,a) ({ __writeb((v),(a)); mb(); }) |
130 | # define writeb(v,a) ({ __raw_writeb((v),(a)); mb(); }) | 125 | #define writew(v,a) ({ __writew((v),(a)); mb(); }) |
131 | #endif | 126 | #define writel(v,a) ({ __writel((v),(a)); mb(); }) |
132 | #ifdef __raw_writew | ||
133 | # define writew(v,a) ({ __raw_writew((v),(a)); mb(); }) | ||
134 | #endif | ||
135 | #ifdef __raw_writel | ||
136 | # define writel(v,a) ({ __raw_writel((v),(a)); mb(); }) | ||
137 | #endif | ||
138 | 127 | ||
139 | #define __BUILD_MEMORY_STRING(bwlq, type) \ | 128 | #define __BUILD_MEMORY_STRING(bwlq, type) \ |
140 | \ | 129 | \ |
141 | static inline void writes##bwlq(volatile void __iomem *mem, \ | 130 | static inline void __raw_writes##bwlq(volatile void __iomem *mem, \ |
142 | const void *addr, unsigned int count) \ | 131 | const void *addr, unsigned int count) \ |
143 | { \ | 132 | { \ |
144 | const volatile type *__addr = addr; \ | 133 | const volatile type *__addr = addr; \ |
@@ -149,8 +138,8 @@ static inline void writes##bwlq(volatile void __iomem *mem, \ | |||
149 | } \ | 138 | } \ |
150 | } \ | 139 | } \ |
151 | \ | 140 | \ |
152 | static inline void reads##bwlq(volatile void __iomem *mem, void *addr, \ | 141 | static inline void __raw_reads##bwlq(volatile void __iomem *mem, \ |
153 | unsigned int count) \ | 142 | void *addr, unsigned int count) \ |
154 | { \ | 143 | { \ |
155 | volatile type *__addr = addr; \ | 144 | volatile type *__addr = addr; \ |
156 | \ | 145 | \ |
@@ -162,7 +151,13 @@ static inline void reads##bwlq(volatile void __iomem *mem, void *addr, \ | |||
162 | 151 | ||
163 | __BUILD_MEMORY_STRING(b, u8) | 152 | __BUILD_MEMORY_STRING(b, u8) |
164 | __BUILD_MEMORY_STRING(w, u16) | 153 | __BUILD_MEMORY_STRING(w, u16) |
154 | |||
155 | #define writesb __raw_writesb | ||
156 | #define writesw __raw_writesw | ||
165 | #define writesl __raw_writesl | 157 | #define writesl __raw_writesl |
158 | |||
159 | #define readsb __raw_readsb | ||
160 | #define readsw __raw_readsw | ||
166 | #define readsl __raw_readsl | 161 | #define readsl __raw_readsl |
167 | 162 | ||
168 | #define readb_relaxed(a) readb(a) | 163 | #define readb_relaxed(a) readb(a) |
@@ -170,25 +165,25 @@ __BUILD_MEMORY_STRING(w, u16) | |||
170 | #define readl_relaxed(a) readl(a) | 165 | #define readl_relaxed(a) readl(a) |
171 | 166 | ||
172 | /* Simple MMIO */ | 167 | /* Simple MMIO */ |
173 | #define ioread8(a) readb(a) | 168 | #define ioread8(a) __raw_readb(a) |
174 | #define ioread16(a) readw(a) | 169 | #define ioread16(a) __raw_readw(a) |
175 | #define ioread16be(a) be16_to_cpu(__raw_readw((a))) | 170 | #define ioread16be(a) be16_to_cpu(__raw_readw((a))) |
176 | #define ioread32(a) readl(a) | 171 | #define ioread32(a) __raw_readl(a) |
177 | #define ioread32be(a) be32_to_cpu(__raw_readl((a))) | 172 | #define ioread32be(a) be32_to_cpu(__raw_readl((a))) |
178 | 173 | ||
179 | #define iowrite8(v,a) writeb((v),(a)) | 174 | #define iowrite8(v,a) __raw_writeb((v),(a)) |
180 | #define iowrite16(v,a) writew((v),(a)) | 175 | #define iowrite16(v,a) __raw_writew((v),(a)) |
181 | #define iowrite16be(v,a) __raw_writew(cpu_to_be16((v)),(a)) | 176 | #define iowrite16be(v,a) __raw_writew(cpu_to_be16((v)),(a)) |
182 | #define iowrite32(v,a) writel((v),(a)) | 177 | #define iowrite32(v,a) __raw_writel((v),(a)) |
183 | #define iowrite32be(v,a) __raw_writel(cpu_to_be32((v)),(a)) | 178 | #define iowrite32be(v,a) __raw_writel(cpu_to_be32((v)),(a)) |
184 | 179 | ||
185 | #define ioread8_rep(a, d, c) readsb((a), (d), (c)) | 180 | #define ioread8_rep(a, d, c) __raw_readsb((a), (d), (c)) |
186 | #define ioread16_rep(a, d, c) readsw((a), (d), (c)) | 181 | #define ioread16_rep(a, d, c) __raw_readsw((a), (d), (c)) |
187 | #define ioread32_rep(a, d, c) readsl((a), (d), (c)) | 182 | #define ioread32_rep(a, d, c) __raw_readsl((a), (d), (c)) |
188 | 183 | ||
189 | #define iowrite8_rep(a, s, c) writesb((a), (s), (c)) | 184 | #define iowrite8_rep(a, s, c) __raw_writesb((a), (s), (c)) |
190 | #define iowrite16_rep(a, s, c) writesw((a), (s), (c)) | 185 | #define iowrite16_rep(a, s, c) __raw_writesw((a), (s), (c)) |
191 | #define iowrite32_rep(a, s, c) writesl((a), (s), (c)) | 186 | #define iowrite32_rep(a, s, c) __raw_writesl((a), (s), (c)) |
192 | 187 | ||
193 | #define mmiowb() wmb() /* synco on SH-4A, otherwise a nop */ | 188 | #define mmiowb() wmb() /* synco on SH-4A, otherwise a nop */ |
194 | 189 | ||
diff --git a/arch/sh/lib/io.c b/arch/sh/lib/io.c index 4f54ec43516f..88dfe6e396bc 100644 --- a/arch/sh/lib/io.c +++ b/arch/sh/lib/io.c | |||
@@ -14,12 +14,12 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/io.h> | 15 | #include <linux/io.h> |
16 | 16 | ||
17 | void __raw_readsl(unsigned long addr, void *datap, int len) | 17 | void __raw_readsl(const void __iomem *addr, void *datap, int len) |
18 | { | 18 | { |
19 | u32 *data; | 19 | u32 *data; |
20 | 20 | ||
21 | for (data = datap; (len != 0) && (((u32)data & 0x1f) != 0); len--) | 21 | for (data = datap; (len != 0) && (((u32)data & 0x1f) != 0); len--) |
22 | *data++ = ctrl_inl(addr); | 22 | *data++ = __raw_readl(addr); |
23 | 23 | ||
24 | if (likely(len >= (0x20 >> 2))) { | 24 | if (likely(len >= (0x20 >> 2))) { |
25 | int tmp2, tmp3, tmp4, tmp5, tmp6; | 25 | int tmp2, tmp3, tmp4, tmp5, tmp6; |
@@ -59,11 +59,11 @@ void __raw_readsl(unsigned long addr, void *datap, int len) | |||
59 | } | 59 | } |
60 | 60 | ||
61 | for (; len != 0; len--) | 61 | for (; len != 0; len--) |
62 | *data++ = ctrl_inl(addr); | 62 | *data++ = __raw_readl(addr); |
63 | } | 63 | } |
64 | EXPORT_SYMBOL(__raw_readsl); | 64 | EXPORT_SYMBOL(__raw_readsl); |
65 | 65 | ||
66 | void __raw_writesl(unsigned long addr, const void *data, int len) | 66 | void __raw_writesl(void __iomem *addr, const void *data, int len) |
67 | { | 67 | { |
68 | if (likely(len != 0)) { | 68 | if (likely(len != 0)) { |
69 | int tmp1; | 69 | int tmp1; |