diff options
author | Lee Jones <lee.jones@linaro.org> | 2015-10-20 12:11:27 -0400 |
---|---|---|
committer | Jassi Brar <jaswinder.singh@linaro.org> | 2015-10-23 01:49:21 -0400 |
commit | a133f8b65d591101e48336050ceb7e2f51026502 (patch) | |
tree | 3189f4c3734e643f4ee30fc2bc7a3fdabbff968a | |
parent | 6c03663f98b91cdd04fce2c9fb7a2cc5d164eded (diff) |
mailbox: mailbox-test: Correctly repair Sparse warnings
Kbuild test robot reported some Sparse warnings to the tune of:
sparse: incorrect type in argument 6 (different address spaces)
expected void const *buf
got void [noderef] <asn:2>*mmio
This was due to passing variables tagged with the Sparse cookie
'__iomem' through into memcpy() and print_hex_dump() without
adequate protection or casting. These issues were fixed in a
previous patch suppressing the warnings, but the issue is indeed
still present.
This patch fixes the warnings in the correct way, i.e. by using
the purposely authored memcpy_{from,to}io() derivatives in the
memcpy() case and casting the memory address to (void *) and
forcing Sparse to ignore to ignore it in the print_hex_dump()
case [NB: This is also what the memcpy() derivatives do].
Reported-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
-rw-r--r-- | drivers/mailbox/mailbox-test.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index 22f2e40476b9..a4f10cc4aea3 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/debugfs.h> | 12 | #include <linux/debugfs.h> |
13 | #include <linux/err.h> | 13 | #include <linux/err.h> |
14 | #include <linux/io.h> | ||
14 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
15 | #include <linux/mailbox_client.h> | 16 | #include <linux/mailbox_client.h> |
16 | #include <linux/module.h> | 17 | #include <linux/module.h> |
@@ -30,7 +31,7 @@ static struct dentry *root_debugfs_dir; | |||
30 | 31 | ||
31 | struct mbox_test_device { | 32 | struct mbox_test_device { |
32 | struct device *dev; | 33 | struct device *dev; |
33 | void *mmio; | 34 | void __iomem *mmio; |
34 | struct mbox_chan *tx_channel; | 35 | struct mbox_chan *tx_channel; |
35 | struct mbox_chan *rx_channel; | 36 | struct mbox_chan *rx_channel; |
36 | char *rx_buffer; | 37 | char *rx_buffer; |
@@ -222,8 +223,8 @@ static void mbox_test_receive_message(struct mbox_client *client, void *message) | |||
222 | if (tdev->mmio) { | 223 | if (tdev->mmio) { |
223 | print_hex_dump(KERN_INFO, "Client: Received [MMIO]: ", | 224 | print_hex_dump(KERN_INFO, "Client: Received [MMIO]: ", |
224 | DUMP_PREFIX_ADDRESS, MBOX_BYTES_PER_LINE, 1, | 225 | DUMP_PREFIX_ADDRESS, MBOX_BYTES_PER_LINE, 1, |
225 | tdev->mmio, MBOX_MAX_MSG_LEN, true); | 226 | __io_virt(tdev->mmio), MBOX_MAX_MSG_LEN, true); |
226 | memcpy(tdev->rx_buffer, tdev->mmio, MBOX_MAX_MSG_LEN); | 227 | memcpy_fromio(tdev->rx_buffer, tdev->mmio, MBOX_MAX_MSG_LEN); |
227 | 228 | ||
228 | } else if (message) { | 229 | } else if (message) { |
229 | print_hex_dump(KERN_INFO, "Client: Received [API]: ", | 230 | print_hex_dump(KERN_INFO, "Client: Received [API]: ", |
@@ -240,9 +241,9 @@ static void mbox_test_prepare_message(struct mbox_client *client, void *message) | |||
240 | 241 | ||
241 | if (tdev->mmio) { | 242 | if (tdev->mmio) { |
242 | if (tdev->signal) | 243 | if (tdev->signal) |
243 | memcpy(tdev->mmio, tdev->message, MBOX_MAX_MSG_LEN); | 244 | memcpy_toio(tdev->mmio, tdev->message, MBOX_MAX_MSG_LEN); |
244 | else | 245 | else |
245 | memcpy(tdev->mmio, message, MBOX_MAX_MSG_LEN); | 246 | memcpy_toio(tdev->mmio, message, MBOX_MAX_MSG_LEN); |
246 | } | 247 | } |
247 | } | 248 | } |
248 | 249 | ||