Skip to contentSkip to conversation

staging: amso1100: fix format string for 64-bit phys_addr

PATCH In review Arnd Bergmann 2 participants 3 messages Feb 1, 2016 – Feb 4, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: amso1100: fix format string for 64-bit phys_addr

The amso1100 driver prints a phys_addr_t by casting it to a pointer, which causes a warning when phys_addr_t is 64-bit and pointers are 32-bit:

drivers/staging/rdma/amso1100/c2.c: In function 'c2_rx_error':
drivers/staging/rdma/amso1100/c2.c:430:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

This changes the format string to print the address as a 64-bit number all the time to avoids the warnings. Ideally we would use the %pap format string for phys_addr_t, but that doesn't work here easily as it requires passing a pointer to the address.

---
Found on ARM randconfig testing. This must have been there forever but is rather hard to trigger even with randconfig builds.

drivers/staging/rdma/amso1100/c2.c +2 -2
index b46ebd1ae15a..170a42a60552 100644
@@ -426,8 +426,8 @@ static void c2_rx_error(struct c2_port *c2_port, struct c2_element *elem)
 		pr_debug("    index : %Zu\n",
 			elem - c2_port->rx_ring.start);
 		pr_debug("    len   : %u\n", rx_desc->len);
-		pr_debug("  rxp_hdr : %p [PA %p]\n", rxp_hdr,
-			(void *) __pa((unsigned long) rxp_hdr));
+		pr_debug("  rxp_hdr : %p [PA %016llx\n", rxp_hdr,
+			(u64)__pa((unsigned long) rxp_hdr));
 		pr_debug("    flags : 0x%x\n", rxp_hdr->flags);
 		pr_debug("    status: 0x%x\n", rxp_hdr->status);
 		pr_debug("    len   : %u\n", rxp_hdr->len);
#1 lore raw
Quoted 23 lines · Arnd Bergmann

The amso1100 driver prints a phys_addr_t by casting it to a pointer, which causes a warning when phys_addr_t is 64-bit and pointers are 32-bit:

drivers/staging/rdma/amso1100/c2.c: In function 'c2_rx_error':
drivers/staging/rdma/amso1100/c2.c:430:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

This changes the format string to print the address as a 64-bit number all the time to avoids the warnings. Ideally we would use the %pap format string for phys_addr_t, but that doesn't work here easily as it requires passing a pointer to the address.

---
Found on ARM randconfig testing. This must have been there forever but is rather hard to trigger even with randconfig builds.

drivers/staging/rdma/amso1100/c2.c +0 -0
index b46ebd1ae15a..170a42a60552 100644

drivers/staging/rdma/amso1100/c2.c static void c2_rx_error(struct c2_port *c2_port, struct c2_element *elem) · line 433

Quoted 10 lines
drivers/staging/rdma/amso1100/c2.c +2 -2
@@ -426,8 +426,8 @@ static void c2_rx_error(struct c2_port *c2_port, struct c2_element *elem)
 		pr_debug("    index : %Zu\n",
 			elem - c2_port->rx_ring.start);
 		pr_debug("    len   : %u\n", rx_desc->len);
-		pr_debug("  rxp_hdr : %p [PA %p]\n", rxp_hdr,
-			(void *) __pa((unsigned long) rxp_hdr));
+		pr_debug("  rxp_hdr : %p [PA %016llx\n", rxp_hdr,
+			(u64)__pa((unsigned long) rxp_hdr));
 		pr_debug("    flags : 0x%x\n", rxp_hdr->flags);
 		pr_debug("    status: 0x%x\n", rxp_hdr->status);
 		pr_debug("    len   : %u\n", rxp_hdr->len);

I've sent off a deletion of this file to Linus already, sorry.

Signature · 11 lines
Doug Ledford <[email protected]>
              GPG KeyID: 0E572FDD


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 884 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160204/f4c4bc6a/attachment.sig>
#2 lore raw
Quoted 2 lines · On Thursday 04 February 2016 07:15:05 Doug Ledford wrote:

I've sent off a deletion of this file to Linus already, sorry.

Even better, thanks!

Arnd