Skip to contentSkip to conversation

mailbox: mailbox-test: avoid reading iomem twice

PATCH In review [email protected] 2 participants 2 messages Nov 4, 2015 Mailbox API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mailbox: mailbox-test: avoid reading iomem twice

From: Jassi Brar <[email protected]>

Don't pass mmio region as source to print_hex_dump() and then again to memcpy_fromio(). Do it once and give print_hex_dump() the buffer we just read the data in.

---
 drivers/mailbox/mailbox-test.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mailbox/mailbox-test.c +2 -3
index f82dc89..684ae17 100644
@@ -221,11 +221,10 @@ static void mbox_test_receive_message(struct mbox_client *client, void *message)
 
 	spin_lock_irqsave(&tdev->lock, flags);
 	if (tdev->mmio) {
+		memcpy_fromio(tdev->rx_buffer, tdev->mmio, MBOX_MAX_MSG_LEN);
 		print_hex_dump(KERN_INFO, "Client: Received [MMIO]: ",
 			       DUMP_PREFIX_ADDRESS, MBOX_BYTES_PER_LINE, 1,
-			       __io_virt(tdev->mmio), MBOX_MAX_MSG_LEN, true);
-		memcpy_fromio(tdev->rx_buffer, tdev->mmio, MBOX_MAX_MSG_LEN);
-
+			       tdev->rx_buffer, MBOX_MAX_MSG_LEN, true);
 	} else if (message) {
 		print_hex_dump(KERN_INFO, "Client: Received [API]: ",
 			       DUMP_PREFIX_ADDRESS, MBOX_BYTES_PER_LINE, 1,
Signature · 1 line
1.9.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Wed, 04 Nov 2015, [email protected] wrote:

From: Jassi Brar <[email protected]>

Don't pass mmio region as source to print_hex_dump() and then again to memcpy_fromio(). Do it once and give print_hex_dump() the buffer we just read the data in.

---
 drivers/mailbox/mailbox-test.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Nice fix Jassi.

Quoted 18 lines
drivers/mailbox/mailbox-test.c +2 -3
index f82dc89..684ae17 100644
@@ -221,11 +221,10 @@ static void mbox_test_receive_message(struct mbox_client *client, void *message)
 
 	spin_lock_irqsave(&tdev->lock, flags);
 	if (tdev->mmio) {
+		memcpy_fromio(tdev->rx_buffer, tdev->mmio, MBOX_MAX_MSG_LEN);
 		print_hex_dump(KERN_INFO, "Client: Received [MMIO]: ",
 			       DUMP_PREFIX_ADDRESS, MBOX_BYTES_PER_LINE, 1,
-			       __io_virt(tdev->mmio), MBOX_MAX_MSG_LEN, true);
-		memcpy_fromio(tdev->rx_buffer, tdev->mmio, MBOX_MAX_MSG_LEN);
-
+			       tdev->rx_buffer, MBOX_MAX_MSG_LEN, true);
 	} else if (message) {
 		print_hex_dump(KERN_INFO, "Client: Received [API]: ",
 			       DUMP_PREFIX_ADDRESS, MBOX_BYTES_PER_LINE, 1,
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog