diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2014-11-07 09:39:46 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-11-11 06:03:40 -0500 |
commit | 065e1477d277174242e73e7334c717b840d0693f (patch) | |
tree | ad3c3fc5b4c0d2b2de5263a4820813a1eecf6f30 /drivers/media/pci/saa7164 | |
parent | dd9ac11aefd8f9286d3bc8988ca5a052312c3de6 (diff) |
[media] saa7164: fix sparse warnings
Fix many sparse warnings:
drivers/media/pci/saa7164/saa7164-core.c:97:18: warning: cast removes address space of expression
drivers/media/pci/saa7164/saa7164-core.c:122:31: warning: cast removes address space of expression
drivers/media/pci/saa7164/saa7164-core.c:122:31: warning: incorrect type in initializer (different address spaces)
drivers/media/pci/saa7164/saa7164-core.c:122:31: expected unsigned char [noderef] [usertype] <asn:2>*bufcpu
drivers/media/pci/saa7164/saa7164-core.c:122:31: got unsigned char [usertype] *<noident>
drivers/media/pci/saa7164/saa7164-core.c:282:44: warning: cast removes address space of expression
drivers/media/pci/saa7164/saa7164-core.c:286:38: warning: cast removes address space of expression
drivers/media/pci/saa7164/saa7164-core.c:286:35: warning: incorrect type in assignment (different address spaces)
drivers/media/pci/saa7164/saa7164-core.c:286:35: expected unsigned char [noderef] [usertype] <asn:2>*p
drivers/media/pci/saa7164/saa7164-core.c:286:35: got unsigned char [usertype] *<noident>
drivers/media/pci/saa7164/saa7164-core.c:352:44: warning: cast removes address space of expression
drivers/media/pci/saa7164/saa7164-core.c:527:53: warning: cast removes address space of expression
drivers/media/pci/saa7164/saa7164-core.c:129:30: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-core.c:133:38: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-core.c:133:72: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-core.c:134:35: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-core.c:287:61: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-core.c:288:65: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-core.c:289:65: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-core.c:290:65: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-core.c:291:65: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-core.c:292:65: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-core.c:293:65: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-core.c:294:65: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-fw.c:548:52: warning: incorrect type in argument 5 (different address spaces)
drivers/media/pci/saa7164/saa7164-fw.c:548:52: expected unsigned char [usertype] *dst
drivers/media/pci/saa7164/saa7164-fw.c:548:52: got unsigned char [noderef] [usertype] <asn:2>*
drivers/media/pci/saa7164/saa7164-fw.c:579:44: warning: incorrect type in argument 5 (different address spaces)
drivers/media/pci/saa7164/saa7164-fw.c:579:44: expected unsigned char [usertype] *dst
drivers/media/pci/saa7164/saa7164-fw.c:579:44: got unsigned char [noderef] [usertype] <asn:2>*
drivers/media/pci/saa7164/saa7164-fw.c:597:44: warning: incorrect type in argument 5 (different address spaces)
drivers/media/pci/saa7164/saa7164-fw.c:597:44: expected unsigned char [usertype] *dst
drivers/media/pci/saa7164/saa7164-fw.c:597:44: got unsigned char [noderef] [usertype] <asn:2>*
drivers/media/pci/saa7164/saa7164-bus.c:36:36: warning: cast removes address space of expression
drivers/media/pci/saa7164/saa7164-bus.c:41:36: warning: cast removes address space of expression
drivers/media/pci/saa7164/saa7164-bus.c:151:19: warning: incorrect type in assignment (different base types)
drivers/media/pci/saa7164/saa7164-bus.c:151:19: expected unsigned short [unsigned] [usertype] size
drivers/media/pci/saa7164/saa7164-bus.c:151:19: got restricted __le16 [usertype] <noident>
drivers/media/pci/saa7164/saa7164-bus.c:152:22: warning: incorrect type in assignment (different base types)
drivers/media/pci/saa7164/saa7164-bus.c:152:22: expected unsigned int [unsigned] [usertype] command
drivers/media/pci/saa7164/saa7164-bus.c:152:22: got restricted __le32 [usertype] <noident>
drivers/media/pci/saa7164/saa7164-bus.c:153:30: warning: incorrect type in assignment (different base types)
drivers/media/pci/saa7164/saa7164-bus.c:153:30: expected unsigned short [unsigned] [usertype] controlselector
drivers/media/pci/saa7164/saa7164-bus.c:153:30: got restricted __le16 [usertype] <noident>
drivers/media/pci/saa7164/saa7164-bus.c:172:20: warning: cast to restricted __le32
drivers/media/pci/saa7164/saa7164-bus.c:173:20: warning: cast to restricted __le32
drivers/media/pci/saa7164/saa7164-bus.c:206:28: warning: cast to restricted __le32
drivers/media/pci/saa7164/saa7164-bus.c:287:9: warning: incorrect type in argument 1 (different base types)
drivers/media/pci/saa7164/saa7164-bus.c:287:9: expected unsigned int [unsigned] val
drivers/media/pci/saa7164/saa7164-bus.c:287:9: got restricted __le32 [usertype] <noident>
drivers/media/pci/saa7164/saa7164-bus.c:339:20: warning: cast to restricted __le32
drivers/media/pci/saa7164/saa7164-bus.c:340:20: warning: cast to restricted __le32
drivers/media/pci/saa7164/saa7164-bus.c:463:9: warning: incorrect type in argument 1 (different base types)
drivers/media/pci/saa7164/saa7164-bus.c:463:9: expected unsigned int [unsigned] val
drivers/media/pci/saa7164/saa7164-bus.c:463:9: got restricted __le32 [usertype] <noident>
drivers/media/pci/saa7164/saa7164-bus.c:466:21: warning: cast to restricted __le16
drivers/media/pci/saa7164/saa7164-bus.c:467:24: warning: cast to restricted __le32
drivers/media/pci/saa7164/saa7164-bus.c:468:32: warning: cast to restricted __le16
drivers/media/pci/saa7164/saa7164-buffer.c:122:18: warning: incorrect type in assignment (different address spaces)
drivers/media/pci/saa7164/saa7164-buffer.c:122:18: expected unsigned long long [noderef] [usertype] <asn:2>*cpu
drivers/media/pci/saa7164/saa7164-buffer.c:122:18: got void *
drivers/media/pci/saa7164/saa7164-buffer.c:127:21: warning: incorrect type in assignment (different address spaces)
drivers/media/pci/saa7164/saa7164-buffer.c:127:21: expected unsigned long long [noderef] [usertype] <asn:2>*pt_cpu
drivers/media/pci/saa7164/saa7164-buffer.c:127:21: got void *
drivers/media/pci/saa7164/saa7164-buffer.c:134:20: warning: cast removes address space of expression
drivers/media/pci/saa7164/saa7164-buffer.c:156:63: warning: incorrect type in argument 3 (different address spaces)
drivers/media/pci/saa7164/saa7164-buffer.c:156:63: expected void *vaddr
drivers/media/pci/saa7164/saa7164-buffer.c:156:63: got unsigned long long [noderef] [usertype] <asn:2>*cpu
drivers/media/pci/saa7164/saa7164-buffer.c:179:57: warning: incorrect type in argument 3 (different address spaces)
drivers/media/pci/saa7164/saa7164-buffer.c:179:57: expected void *vaddr
drivers/media/pci/saa7164/saa7164-buffer.c:179:57: got unsigned long long [noderef] [usertype] <asn:2>*cpu
drivers/media/pci/saa7164/saa7164-buffer.c:180:56: warning: incorrect type in argument 3 (different address spaces)
drivers/media/pci/saa7164/saa7164-buffer.c:180:56: expected void *vaddr
drivers/media/pci/saa7164/saa7164-buffer.c:180:56: got unsigned long long [noderef] [usertype] <asn:2>*pt_cpu
drivers/media/pci/saa7164/saa7164-buffer.c:84:17: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-buffer.c:147:31: warning: dereference of noderef expression
drivers/media/pci/saa7164/saa7164-buffer.c:148:17: warning: dereference of noderef expression
Most are caused by pointers marked as __iomem when they aren't or not marked as
__iomem when they should.
Also note that readl/writel already do endian conversion, so there is no need to
do it again.
saa7164_bus_set/get were a bit tricky: you have to make sure the msg endian
conversion is done at the right time, and that the code isn't using fields that
are still little endian instead of cpu-endianness.
The approach chosen is to convert just before writing to the ring buffer
and to convert it back right after reading from the ring buffer.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Steven Toth <stoth@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/pci/saa7164')
-rw-r--r-- | drivers/media/pci/saa7164/saa7164-buffer.c | 4 | ||||
-rw-r--r-- | drivers/media/pci/saa7164/saa7164-bus.c | 101 | ||||
-rw-r--r-- | drivers/media/pci/saa7164/saa7164-core.c | 13 | ||||
-rw-r--r-- | drivers/media/pci/saa7164/saa7164-fw.c | 6 | ||||
-rw-r--r-- | drivers/media/pci/saa7164/saa7164-types.h | 4 | ||||
-rw-r--r-- | drivers/media/pci/saa7164/saa7164.h | 4 |
6 files changed, 74 insertions, 58 deletions
diff --git a/drivers/media/pci/saa7164/saa7164-buffer.c b/drivers/media/pci/saa7164/saa7164-buffer.c index 66696fa8341d..9bd1f73f82da 100644 --- a/drivers/media/pci/saa7164/saa7164-buffer.c +++ b/drivers/media/pci/saa7164/saa7164-buffer.c | |||
@@ -130,9 +130,9 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port, | |||
130 | goto fail2; | 130 | goto fail2; |
131 | 131 | ||
132 | /* init the buffers to a known pattern, easier during debugging */ | 132 | /* init the buffers to a known pattern, easier during debugging */ |
133 | memset_io(buf->cpu, 0xff, buf->pci_size); | 133 | memset(buf->cpu, 0xff, buf->pci_size); |
134 | buf->crc = crc32(0, buf->cpu, buf->actual_size); | 134 | buf->crc = crc32(0, buf->cpu, buf->actual_size); |
135 | memset_io(buf->pt_cpu, 0xff, buf->pt_size); | 135 | memset(buf->pt_cpu, 0xff, buf->pt_size); |
136 | 136 | ||
137 | dprintk(DBGLVL_BUF, "%s() allocated buffer @ 0x%p (%d pageptrs)\n", | 137 | dprintk(DBGLVL_BUF, "%s() allocated buffer @ 0x%p (%d pageptrs)\n", |
138 | __func__, buf, params->numpagetables); | 138 | __func__, buf, params->numpagetables); |
diff --git a/drivers/media/pci/saa7164/saa7164-bus.c b/drivers/media/pci/saa7164/saa7164-bus.c index 5f6f3094c44e..6c73f5b155f6 100644 --- a/drivers/media/pci/saa7164/saa7164-bus.c +++ b/drivers/media/pci/saa7164/saa7164-bus.c | |||
@@ -33,12 +33,12 @@ int saa7164_bus_setup(struct saa7164_dev *dev) | |||
33 | b->Type = TYPE_BUS_PCIe; | 33 | b->Type = TYPE_BUS_PCIe; |
34 | b->m_wMaxReqSize = SAA_DEVICE_MAXREQUESTSIZE; | 34 | b->m_wMaxReqSize = SAA_DEVICE_MAXREQUESTSIZE; |
35 | 35 | ||
36 | b->m_pdwSetRing = (u8 *)(dev->bmmio + | 36 | b->m_pdwSetRing = (u8 __iomem *)(dev->bmmio + |
37 | ((u32)dev->busdesc.CommandRing)); | 37 | ((u32)dev->busdesc.CommandRing)); |
38 | 38 | ||
39 | b->m_dwSizeSetRing = SAA_DEVICE_BUFFERBLOCKSIZE; | 39 | b->m_dwSizeSetRing = SAA_DEVICE_BUFFERBLOCKSIZE; |
40 | 40 | ||
41 | b->m_pdwGetRing = (u8 *)(dev->bmmio + | 41 | b->m_pdwGetRing = (u8 __iomem *)(dev->bmmio + |
42 | ((u32)dev->busdesc.ResponseRing)); | 42 | ((u32)dev->busdesc.ResponseRing)); |
43 | 43 | ||
44 | b->m_dwSizeGetRing = SAA_DEVICE_BUFFERBLOCKSIZE; | 44 | b->m_dwSizeGetRing = SAA_DEVICE_BUFFERBLOCKSIZE; |
@@ -138,6 +138,7 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
138 | u32 bytes_to_write, free_write_space, timeout, curr_srp, curr_swp; | 138 | u32 bytes_to_write, free_write_space, timeout, curr_srp, curr_swp; |
139 | u32 new_swp, space_rem; | 139 | u32 new_swp, space_rem; |
140 | int ret = SAA_ERR_BAD_PARAMETER; | 140 | int ret = SAA_ERR_BAD_PARAMETER; |
141 | u16 size; | ||
141 | 142 | ||
142 | if (!msg) { | 143 | if (!msg) { |
143 | printk(KERN_ERR "%s() !msg\n", __func__); | 144 | printk(KERN_ERR "%s() !msg\n", __func__); |
@@ -148,10 +149,6 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
148 | 149 | ||
149 | saa7164_bus_verify(dev); | 150 | saa7164_bus_verify(dev); |
150 | 151 | ||
151 | msg->size = cpu_to_le16(msg->size); | ||
152 | msg->command = cpu_to_le32(msg->command); | ||
153 | msg->controlselector = cpu_to_le16(msg->controlselector); | ||
154 | |||
155 | if (msg->size > dev->bus.m_wMaxReqSize) { | 152 | if (msg->size > dev->bus.m_wMaxReqSize) { |
156 | printk(KERN_ERR "%s() Exceeded dev->bus.m_wMaxReqSize\n", | 153 | printk(KERN_ERR "%s() Exceeded dev->bus.m_wMaxReqSize\n", |
157 | __func__); | 154 | __func__); |
@@ -169,8 +166,8 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
169 | bytes_to_write = sizeof(*msg) + msg->size; | 166 | bytes_to_write = sizeof(*msg) + msg->size; |
170 | free_write_space = 0; | 167 | free_write_space = 0; |
171 | timeout = SAA_BUS_TIMEOUT; | 168 | timeout = SAA_BUS_TIMEOUT; |
172 | curr_srp = le32_to_cpu(saa7164_readl(bus->m_dwSetReadPos)); | 169 | curr_srp = saa7164_readl(bus->m_dwSetReadPos); |
173 | curr_swp = le32_to_cpu(saa7164_readl(bus->m_dwSetWritePos)); | 170 | curr_swp = saa7164_readl(bus->m_dwSetWritePos); |
174 | 171 | ||
175 | /* Deal with ring wrapping issues */ | 172 | /* Deal with ring wrapping issues */ |
176 | if (curr_srp > curr_swp) | 173 | if (curr_srp > curr_swp) |
@@ -203,7 +200,7 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
203 | mdelay(1); | 200 | mdelay(1); |
204 | 201 | ||
205 | /* Check the space usage again */ | 202 | /* Check the space usage again */ |
206 | curr_srp = le32_to_cpu(saa7164_readl(bus->m_dwSetReadPos)); | 203 | curr_srp = saa7164_readl(bus->m_dwSetReadPos); |
207 | 204 | ||
208 | /* Deal with ring wrapping issues */ | 205 | /* Deal with ring wrapping issues */ |
209 | if (curr_srp > curr_swp) | 206 | if (curr_srp > curr_swp) |
@@ -223,6 +220,16 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
223 | dprintk(DBGLVL_BUS, "%s() bus->m_dwSizeSetRing = %x\n", __func__, | 220 | dprintk(DBGLVL_BUS, "%s() bus->m_dwSizeSetRing = %x\n", __func__, |
224 | bus->m_dwSizeSetRing); | 221 | bus->m_dwSizeSetRing); |
225 | 222 | ||
223 | /* | ||
224 | * Make a copy of msg->size before it is converted to le16 since it is | ||
225 | * used in the code below. | ||
226 | */ | ||
227 | size = msg->size; | ||
228 | /* Convert to le16/le32 */ | ||
229 | msg->size = (__force u16)cpu_to_le16(msg->size); | ||
230 | msg->command = (__force u32)cpu_to_le32(msg->command); | ||
231 | msg->controlselector = (__force u16)cpu_to_le16(msg->controlselector); | ||
232 | |||
226 | /* Mental Note: line 462 tmmhComResBusPCIe.cpp */ | 233 | /* Mental Note: line 462 tmmhComResBusPCIe.cpp */ |
227 | 234 | ||
228 | /* Check if we're going to wrap again */ | 235 | /* Check if we're going to wrap again */ |
@@ -243,28 +250,28 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
243 | dprintk(DBGLVL_BUS, "%s() tr4\n", __func__); | 250 | dprintk(DBGLVL_BUS, "%s() tr4\n", __func__); |
244 | 251 | ||
245 | /* Split the msg into pieces as the ring wraps */ | 252 | /* Split the msg into pieces as the ring wraps */ |
246 | memcpy(bus->m_pdwSetRing + curr_swp, msg, space_rem); | 253 | memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, space_rem); |
247 | memcpy(bus->m_pdwSetRing, (u8 *)msg + space_rem, | 254 | memcpy_toio(bus->m_pdwSetRing, (u8 *)msg + space_rem, |
248 | sizeof(*msg) - space_rem); | 255 | sizeof(*msg) - space_rem); |
249 | 256 | ||
250 | memcpy(bus->m_pdwSetRing + sizeof(*msg) - space_rem, | 257 | memcpy_toio(bus->m_pdwSetRing + sizeof(*msg) - space_rem, |
251 | buf, msg->size); | 258 | buf, size); |
252 | 259 | ||
253 | } else if (space_rem == sizeof(*msg)) { | 260 | } else if (space_rem == sizeof(*msg)) { |
254 | dprintk(DBGLVL_BUS, "%s() tr5\n", __func__); | 261 | dprintk(DBGLVL_BUS, "%s() tr5\n", __func__); |
255 | 262 | ||
256 | /* Additional data at the beginning of the ring */ | 263 | /* Additional data at the beginning of the ring */ |
257 | memcpy(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); | 264 | memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); |
258 | memcpy(bus->m_pdwSetRing, buf, msg->size); | 265 | memcpy_toio(bus->m_pdwSetRing, buf, size); |
259 | 266 | ||
260 | } else { | 267 | } else { |
261 | /* Additional data wraps around the ring */ | 268 | /* Additional data wraps around the ring */ |
262 | memcpy(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); | 269 | memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); |
263 | if (msg->size > 0) { | 270 | if (size > 0) { |
264 | memcpy(bus->m_pdwSetRing + curr_swp + | 271 | memcpy_toio(bus->m_pdwSetRing + curr_swp + |
265 | sizeof(*msg), buf, space_rem - | 272 | sizeof(*msg), buf, space_rem - |
266 | sizeof(*msg)); | 273 | sizeof(*msg)); |
267 | memcpy(bus->m_pdwSetRing, (u8 *)buf + | 274 | memcpy_toio(bus->m_pdwSetRing, (u8 *)buf + |
268 | space_rem - sizeof(*msg), | 275 | space_rem - sizeof(*msg), |
269 | bytes_to_write - space_rem); | 276 | bytes_to_write - space_rem); |
270 | } | 277 | } |
@@ -276,15 +283,20 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
276 | dprintk(DBGLVL_BUS, "%s() tr6\n", __func__); | 283 | dprintk(DBGLVL_BUS, "%s() tr6\n", __func__); |
277 | 284 | ||
278 | /* The ring buffer doesn't wrap, two simple copies */ | 285 | /* The ring buffer doesn't wrap, two simple copies */ |
279 | memcpy(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); | 286 | memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); |
280 | memcpy(bus->m_pdwSetRing + curr_swp + sizeof(*msg), buf, | 287 | memcpy_toio(bus->m_pdwSetRing + curr_swp + sizeof(*msg), buf, |
281 | msg->size); | 288 | size); |
282 | } | 289 | } |
283 | 290 | ||
284 | dprintk(DBGLVL_BUS, "%s() new_swp = %x\n", __func__, new_swp); | 291 | dprintk(DBGLVL_BUS, "%s() new_swp = %x\n", __func__, new_swp); |
285 | 292 | ||
286 | /* Update the bus write position */ | 293 | /* Update the bus write position */ |
287 | saa7164_writel(bus->m_dwSetWritePos, cpu_to_le32(new_swp)); | 294 | saa7164_writel(bus->m_dwSetWritePos, new_swp); |
295 | |||
296 | /* Convert back to cpu after writing the msg to the ringbuffer. */ | ||
297 | msg->size = le16_to_cpu((__force __le16)msg->size); | ||
298 | msg->command = le32_to_cpu((__force __le32)msg->command); | ||
299 | msg->controlselector = le16_to_cpu((__force __le16)msg->controlselector); | ||
288 | ret = SAA_OK; | 300 | ret = SAA_OK; |
289 | 301 | ||
290 | out: | 302 | out: |
@@ -336,8 +348,8 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
336 | /* Peek the bus to see if a msg exists, if it's not what we're expecting | 348 | /* Peek the bus to see if a msg exists, if it's not what we're expecting |
337 | * then return cleanly else read the message from the bus. | 349 | * then return cleanly else read the message from the bus. |
338 | */ | 350 | */ |
339 | curr_gwp = le32_to_cpu(saa7164_readl(bus->m_dwGetWritePos)); | 351 | curr_gwp = saa7164_readl(bus->m_dwGetWritePos); |
340 | curr_grp = le32_to_cpu(saa7164_readl(bus->m_dwGetReadPos)); | 352 | curr_grp = saa7164_readl(bus->m_dwGetReadPos); |
341 | 353 | ||
342 | if (curr_gwp == curr_grp) { | 354 | if (curr_gwp == curr_grp) { |
343 | ret = SAA_ERR_EMPTY; | 355 | ret = SAA_ERR_EMPTY; |
@@ -369,14 +381,18 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
369 | new_grp -= bus->m_dwSizeGetRing; | 381 | new_grp -= bus->m_dwSizeGetRing; |
370 | space_rem = bus->m_dwSizeGetRing - curr_grp; | 382 | space_rem = bus->m_dwSizeGetRing - curr_grp; |
371 | 383 | ||
372 | memcpy(&msg_tmp, bus->m_pdwGetRing + curr_grp, space_rem); | 384 | memcpy_fromio(&msg_tmp, bus->m_pdwGetRing + curr_grp, space_rem); |
373 | memcpy((u8 *)&msg_tmp + space_rem, bus->m_pdwGetRing, | 385 | memcpy_fromio((u8 *)&msg_tmp + space_rem, bus->m_pdwGetRing, |
374 | bytes_to_read - space_rem); | 386 | bytes_to_read - space_rem); |
375 | 387 | ||
376 | } else { | 388 | } else { |
377 | /* No wrapping */ | 389 | /* No wrapping */ |
378 | memcpy(&msg_tmp, bus->m_pdwGetRing + curr_grp, bytes_to_read); | 390 | memcpy_fromio(&msg_tmp, bus->m_pdwGetRing + curr_grp, bytes_to_read); |
379 | } | 391 | } |
392 | /* Convert from little endian to CPU */ | ||
393 | msg_tmp.size = le16_to_cpu((__force __le16)msg_tmp.size); | ||
394 | msg_tmp.command = le32_to_cpu((__force __le32)msg_tmp.command); | ||
395 | msg_tmp.controlselector = le16_to_cpu((__force __le16)msg_tmp.controlselector); | ||
380 | 396 | ||
381 | /* No need to update the read positions, because this was a peek */ | 397 | /* No need to update the read positions, because this was a peek */ |
382 | /* If the caller specifically want to peek, return */ | 398 | /* If the caller specifically want to peek, return */ |
@@ -427,24 +443,24 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
427 | 443 | ||
428 | if (space_rem < sizeof(*msg)) { | 444 | if (space_rem < sizeof(*msg)) { |
429 | /* msg wraps around the ring */ | 445 | /* msg wraps around the ring */ |
430 | memcpy(msg, bus->m_pdwGetRing + curr_grp, space_rem); | 446 | memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, space_rem); |
431 | memcpy((u8 *)msg + space_rem, bus->m_pdwGetRing, | 447 | memcpy_fromio((u8 *)msg + space_rem, bus->m_pdwGetRing, |
432 | sizeof(*msg) - space_rem); | 448 | sizeof(*msg) - space_rem); |
433 | if (buf) | 449 | if (buf) |
434 | memcpy(buf, bus->m_pdwGetRing + sizeof(*msg) - | 450 | memcpy_fromio(buf, bus->m_pdwGetRing + sizeof(*msg) - |
435 | space_rem, buf_size); | 451 | space_rem, buf_size); |
436 | 452 | ||
437 | } else if (space_rem == sizeof(*msg)) { | 453 | } else if (space_rem == sizeof(*msg)) { |
438 | memcpy(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); | 454 | memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); |
439 | if (buf) | 455 | if (buf) |
440 | memcpy(buf, bus->m_pdwGetRing, buf_size); | 456 | memcpy_fromio(buf, bus->m_pdwGetRing, buf_size); |
441 | } else { | 457 | } else { |
442 | /* Additional data wraps around the ring */ | 458 | /* Additional data wraps around the ring */ |
443 | memcpy(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); | 459 | memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); |
444 | if (buf) { | 460 | if (buf) { |
445 | memcpy(buf, bus->m_pdwGetRing + curr_grp + | 461 | memcpy_fromio(buf, bus->m_pdwGetRing + curr_grp + |
446 | sizeof(*msg), space_rem - sizeof(*msg)); | 462 | sizeof(*msg), space_rem - sizeof(*msg)); |
447 | memcpy(buf + space_rem - sizeof(*msg), | 463 | memcpy_fromio(buf + space_rem - sizeof(*msg), |
448 | bus->m_pdwGetRing, bytes_to_read - | 464 | bus->m_pdwGetRing, bytes_to_read - |
449 | space_rem); | 465 | space_rem); |
450 | } | 466 | } |
@@ -453,19 +469,20 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, | |||
453 | 469 | ||
454 | } else { | 470 | } else { |
455 | /* No wrapping */ | 471 | /* No wrapping */ |
456 | memcpy(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); | 472 | memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); |
457 | if (buf) | 473 | if (buf) |
458 | memcpy(buf, bus->m_pdwGetRing + curr_grp + sizeof(*msg), | 474 | memcpy_fromio(buf, bus->m_pdwGetRing + curr_grp + sizeof(*msg), |
459 | buf_size); | 475 | buf_size); |
460 | } | 476 | } |
477 | /* Convert from little endian to CPU */ | ||
478 | msg->size = le16_to_cpu((__force __le16)msg->size); | ||
479 | msg->command = le32_to_cpu((__force __le32)msg->command); | ||
480 | msg->controlselector = le16_to_cpu((__force __le16)msg->controlselector); | ||
461 | 481 | ||
462 | /* Update the read positions, adjusting the ring */ | 482 | /* Update the read positions, adjusting the ring */ |
463 | saa7164_writel(bus->m_dwGetReadPos, cpu_to_le32(new_grp)); | 483 | saa7164_writel(bus->m_dwGetReadPos, new_grp); |
464 | 484 | ||
465 | peekout: | 485 | peekout: |
466 | msg->size = le16_to_cpu(msg->size); | ||
467 | msg->command = le32_to_cpu(msg->command); | ||
468 | msg->controlselector = le16_to_cpu(msg->controlselector); | ||
469 | ret = SAA_OK; | 486 | ret = SAA_OK; |
470 | out: | 487 | out: |
471 | mutex_unlock(&bus->lock); | 488 | mutex_unlock(&bus->lock); |
diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c index cc1be8a7a451..4b0bec3766ed 100644 --- a/drivers/media/pci/saa7164/saa7164-core.c +++ b/drivers/media/pci/saa7164/saa7164-core.c | |||
@@ -119,7 +119,7 @@ static void saa7164_ts_verifier(struct saa7164_buffer *buf) | |||
119 | u32 i; | 119 | u32 i; |
120 | u8 cc, a; | 120 | u8 cc, a; |
121 | u16 pid; | 121 | u16 pid; |
122 | u8 __iomem *bufcpu = (u8 *)buf->cpu; | 122 | u8 *bufcpu = (u8 *)buf->cpu; |
123 | 123 | ||
124 | port->sync_errors = 0; | 124 | port->sync_errors = 0; |
125 | port->v_cc_errors = 0; | 125 | port->v_cc_errors = 0; |
@@ -260,7 +260,7 @@ static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr) | |||
260 | struct saa7164_user_buffer *ubuf = NULL; | 260 | struct saa7164_user_buffer *ubuf = NULL; |
261 | struct list_head *c, *n; | 261 | struct list_head *c, *n; |
262 | int i = 0; | 262 | int i = 0; |
263 | u8 __iomem *p; | 263 | u8 *p; |
264 | 264 | ||
265 | mutex_lock(&port->dmaqueue_lock); | 265 | mutex_lock(&port->dmaqueue_lock); |
266 | list_for_each_safe(c, n, &port->dmaqueue.list) { | 266 | list_for_each_safe(c, n, &port->dmaqueue.list) { |
@@ -318,8 +318,7 @@ static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr) | |||
318 | 318 | ||
319 | if (buf->actual_size <= ubuf->actual_size) { | 319 | if (buf->actual_size <= ubuf->actual_size) { |
320 | 320 | ||
321 | memcpy_fromio(ubuf->data, buf->cpu, | 321 | memcpy(ubuf->data, buf->cpu, ubuf->actual_size); |
322 | ubuf->actual_size); | ||
323 | 322 | ||
324 | if (crc_checking) { | 323 | if (crc_checking) { |
325 | /* Throw a new checksum on the read buffer */ | 324 | /* Throw a new checksum on the read buffer */ |
@@ -346,7 +345,7 @@ static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr) | |||
346 | * with known bad data. We check for this data at a later point | 345 | * with known bad data. We check for this data at a later point |
347 | * in time. */ | 346 | * in time. */ |
348 | saa7164_buffer_zero_offsets(port, bufnr); | 347 | saa7164_buffer_zero_offsets(port, bufnr); |
349 | memset_io(buf->cpu, 0xff, buf->pci_size); | 348 | memset(buf->cpu, 0xff, buf->pci_size); |
350 | if (crc_checking) { | 349 | if (crc_checking) { |
351 | /* Throw yet aanother new checksum on the dma buffer */ | 350 | /* Throw yet aanother new checksum on the dma buffer */ |
352 | buf->crc = crc32(0, buf->cpu, buf->actual_size); | 351 | buf->crc = crc32(0, buf->cpu, buf->actual_size); |
@@ -1096,7 +1095,7 @@ static int saa7164_proc_show(struct seq_file *m, void *v) | |||
1096 | if (c == 0) | 1095 | if (c == 0) |
1097 | seq_printf(m, " %04x:", i); | 1096 | seq_printf(m, " %04x:", i); |
1098 | 1097 | ||
1099 | seq_printf(m, " %02x", *(b->m_pdwSetRing + i)); | 1098 | seq_printf(m, " %02x", readb(b->m_pdwSetRing + i)); |
1100 | 1099 | ||
1101 | if (++c == 16) { | 1100 | if (++c == 16) { |
1102 | seq_printf(m, "\n"); | 1101 | seq_printf(m, "\n"); |
@@ -1111,7 +1110,7 @@ static int saa7164_proc_show(struct seq_file *m, void *v) | |||
1111 | if (c == 0) | 1110 | if (c == 0) |
1112 | seq_printf(m, " %04x:", i); | 1111 | seq_printf(m, " %04x:", i); |
1113 | 1112 | ||
1114 | seq_printf(m, " %02x", *(b->m_pdwGetRing + i)); | 1113 | seq_printf(m, " %02x", readb(b->m_pdwGetRing + i)); |
1115 | 1114 | ||
1116 | if (++c == 16) { | 1115 | if (++c == 16) { |
1117 | seq_printf(m, "\n"); | 1116 | seq_printf(m, "\n"); |
diff --git a/drivers/media/pci/saa7164/saa7164-fw.c b/drivers/media/pci/saa7164/saa7164-fw.c index 86763203d61d..add06ab5124d 100644 --- a/drivers/media/pci/saa7164/saa7164-fw.c +++ b/drivers/media/pci/saa7164/saa7164-fw.c | |||
@@ -72,7 +72,7 @@ static int saa7164_dl_wait_clr(struct saa7164_dev *dev, u32 reg) | |||
72 | /* TODO: move dlflags into dev-> and change to write/readl/b */ | 72 | /* TODO: move dlflags into dev-> and change to write/readl/b */ |
73 | /* TODO: Excessive levels of debug */ | 73 | /* TODO: Excessive levels of debug */ |
74 | static int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize, | 74 | static int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize, |
75 | u32 dlflags, u8 *dst, u32 dstsize) | 75 | u32 dlflags, u8 __iomem *dst, u32 dstsize) |
76 | { | 76 | { |
77 | u32 reg, timeout, offset; | 77 | u32 reg, timeout, offset; |
78 | u8 *srcbuf = NULL; | 78 | u8 *srcbuf = NULL; |
@@ -136,7 +136,7 @@ static int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize, | |||
136 | srcsize -= dstsize, offset += dstsize) { | 136 | srcsize -= dstsize, offset += dstsize) { |
137 | 137 | ||
138 | dprintk(DBGLVL_FW, "%s() memcpy %d\n", __func__, dstsize); | 138 | dprintk(DBGLVL_FW, "%s() memcpy %d\n", __func__, dstsize); |
139 | memcpy(dst, srcbuf + offset, dstsize); | 139 | memcpy_toio(dst, srcbuf + offset, dstsize); |
140 | 140 | ||
141 | /* Flag the data as ready */ | 141 | /* Flag the data as ready */ |
142 | saa7164_writel(drflag, 1); | 142 | saa7164_writel(drflag, 1); |
@@ -154,7 +154,7 @@ static int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize, | |||
154 | 154 | ||
155 | dprintk(DBGLVL_FW, "%s() memcpy(l) %d\n", __func__, dstsize); | 155 | dprintk(DBGLVL_FW, "%s() memcpy(l) %d\n", __func__, dstsize); |
156 | /* Write last block to the device */ | 156 | /* Write last block to the device */ |
157 | memcpy(dst, srcbuf+offset, srcsize); | 157 | memcpy_toio(dst, srcbuf+offset, srcsize); |
158 | 158 | ||
159 | /* Flag the data as ready */ | 159 | /* Flag the data as ready */ |
160 | saa7164_writel(drflag, 1); | 160 | saa7164_writel(drflag, 1); |
diff --git a/drivers/media/pci/saa7164/saa7164-types.h b/drivers/media/pci/saa7164/saa7164-types.h index 1d2140a3eb38..f48ba978f835 100644 --- a/drivers/media/pci/saa7164/saa7164-types.h +++ b/drivers/media/pci/saa7164/saa7164-types.h | |||
@@ -78,9 +78,9 @@ enum tmBusType { | |||
78 | struct tmComResBusInfo { | 78 | struct tmComResBusInfo { |
79 | enum tmBusType Type; | 79 | enum tmBusType Type; |
80 | u16 m_wMaxReqSize; | 80 | u16 m_wMaxReqSize; |
81 | u8 *m_pdwSetRing; | 81 | u8 __iomem *m_pdwSetRing; |
82 | u32 m_dwSizeSetRing; | 82 | u32 m_dwSizeSetRing; |
83 | u8 *m_pdwGetRing; | 83 | u8 __iomem *m_pdwGetRing; |
84 | u32 m_dwSizeGetRing; | 84 | u32 m_dwSizeGetRing; |
85 | u32 m_dwSetWritePos; | 85 | u32 m_dwSetWritePos; |
86 | u32 m_dwSetReadPos; | 86 | u32 m_dwSetReadPos; |
diff --git a/drivers/media/pci/saa7164/saa7164.h b/drivers/media/pci/saa7164/saa7164.h index 8b29e8990301..cd1a07ce27cb 100644 --- a/drivers/media/pci/saa7164/saa7164.h +++ b/drivers/media/pci/saa7164/saa7164.h | |||
@@ -313,13 +313,13 @@ struct saa7164_buffer { | |||
313 | 313 | ||
314 | /* A block of page align PCI memory */ | 314 | /* A block of page align PCI memory */ |
315 | u32 pci_size; /* PCI allocation size in bytes */ | 315 | u32 pci_size; /* PCI allocation size in bytes */ |
316 | u64 __iomem *cpu; /* Virtual address */ | 316 | u64 *cpu; /* Virtual address */ |
317 | dma_addr_t dma; /* Physical address */ | 317 | dma_addr_t dma; /* Physical address */ |
318 | u32 crc; /* Checksum for the entire buffer data */ | 318 | u32 crc; /* Checksum for the entire buffer data */ |
319 | 319 | ||
320 | /* A page table that splits the block into a number of entries */ | 320 | /* A page table that splits the block into a number of entries */ |
321 | u32 pt_size; /* PCI allocation size in bytes */ | 321 | u32 pt_size; /* PCI allocation size in bytes */ |
322 | u64 __iomem *pt_cpu; /* Virtual address */ | 322 | u64 *pt_cpu; /* Virtual address */ |
323 | dma_addr_t pt_dma; /* Physical address */ | 323 | dma_addr_t pt_dma; /* Physical address */ |
324 | 324 | ||
325 | /* Encoder fops */ | 325 | /* Encoder fops */ |