Skip to contentSkip to conversation

serial: ns16550: Fix pointer type mismatch

PATCH In review J. Neuschäfer 2 participants 2 messages Feb 18, 2025 – Feb 28, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: ns16550: Fix pointer type mismatch

serial_out_dynamic() takes a u8* addr and uses it for 8-bit or 32-bit accesses, depending on the value of plat->reg_width. This results in a pointer type mismatch that the compiler may even turn into an error:

drivers/serial/ns16550.c: In function ‘serial_out_dynamic’:
drivers/serial/ns16550.c:115:42: error: passing argument 1 of ‘out_be32’ from incompatible pointer type [-Wincompatible-pointer-types]

  115 |                                 out_be32(addr, value);
      |                                          ^~~~
      |                                          |
      |                                          u8 * {aka unsigned char *}

This error was observed on PowerPC.

---
 drivers/serial/ns16550.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/serial/ns16550.c +4 -4
index 042220081079382a611877aef14ab3ea4b005441..06665d1b3385d90b14c09c3f816bb01802cea2ab 100644
@@ -112,9 +112,9 @@ static void serial_out_dynamic(struct ns16550_plat *plat, u8 *addr,
 	} else if (plat->reg_width == 4) {
 		if (plat->flags & NS16550_FLAG_ENDIAN) {
 			if (plat->flags & NS16550_FLAG_BE)
-				out_be32(addr, value);
+				out_be32((u32 *)addr, value);
 			else
-				out_le32(addr, value);
+				out_le32((u32 *)addr, value);
 		} else {
 			writel(value, addr);
 		}
@@ -132,9 +132,9 @@ static int serial_in_dynamic(struct ns16550_plat *plat, u8 *addr)
 	} else if (plat->reg_width == 4) {
 		if (plat->flags & NS16550_FLAG_ENDIAN) {
 			if (plat->flags & NS16550_FLAG_BE)
-				return in_be32(addr);
+				return in_be32((u32 *)addr);
 			else
-				return in_le32(addr);
+				return in_le32((u32 *)addr);
 		} else {
 			return readl(addr);
 		}

---
base-commit: 3b1c055bf9e254ab6395907779af4e2ce14bb7e6
change-id: 20250218-serial-type-86c31980cb25

Best regards,

Signature · 1 line
J. Neuschäfer <[email protected]>
#1 lore raw
Quoted 4 lines · J. Neuschäfer

serial_out_dynamic() takes a u8* addr and uses it for 8-bit or 32-bit accesses, depending on the value of plat->reg_width. This results in a pointer type mismatch that the compiler may even turn into an error:

Quoted 8 lines

drivers/serial/ns16550.c: In function ‘serial_out_dynamic’:
drivers/serial/ns16550.c:115:42: error: passing argument 1 of ‘out_be32’ from incompatible pointer type [-Wincompatible-pointer-types]

  115 |                                 out_be32(addr, value);
      |                                          ^~~~
      |                                          |
      |                                          u8 * {aka unsigned char *}

[...]

Applied to u-boot/next, thanks!

Signature · 1 line
Tom