]> git.itanic.dy.fi Git - linux-stable/commitdiff
MIPS: pic32: treat port as signed integer
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 28 Oct 2022 13:23:44 +0000 (15:23 +0200)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Fri, 11 Nov 2022 14:53:58 +0000 (15:53 +0100)
get_port_from_cmdline() returns an int, yet is assigned to a char, which
is wrong in its own right, but also, with char becoming unsigned, this
poses problems, because -1 is used as an error value. Further
complicating things, fw_init_early_console() is only ever called with a
-1 argument. Fix this up by removing the unused argument from
fw_init_early_console() and treating port as a proper signed integer.

Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/include/asm/fw/fw.h
arch/mips/pic32/pic32mzda/early_console.c
arch/mips/pic32/pic32mzda/init.c

index d0ef8b4892bbe6af327a0b351df93f948c413b37..d0494ce4b3373a751597d063c6b9bece9379b431 100644 (file)
@@ -26,6 +26,6 @@ extern char *fw_getcmdline(void);
 extern void fw_meminit(void);
 extern char *fw_getenv(char *name);
 extern unsigned long fw_getenvl(char *name);
-extern void fw_init_early_console(char port);
+extern void fw_init_early_console(void);
 
 #endif /* __ASM_FW_H_ */
index 25372e62783b584456162362d6765aca7a73b829..3cd1b408fa1cb039f917f2d92e82fd00d8a44574 100644 (file)
@@ -27,7 +27,7 @@
 #define U_BRG(x)       (UART_BASE(x) + 0x40)
 
 static void __iomem *uart_base;
-static char console_port = -1;
+static int console_port = -1;
 
 static int __init configure_uart_pins(int port)
 {
@@ -47,7 +47,7 @@ static int __init configure_uart_pins(int port)
        return 0;
 }
 
-static void __init configure_uart(char port, int baud)
+static void __init configure_uart(int port, int baud)
 {
        u32 pbclk;
 
@@ -60,7 +60,7 @@ static void __init configure_uart(char port, int baud)
                     uart_base + PIC32_SET(U_STA(port)));
 }
 
-static void __init setup_early_console(char port, int baud)
+static void __init setup_early_console(int port, int baud)
 {
        if (configure_uart_pins(port))
                return;
@@ -130,16 +130,15 @@ static int __init get_baud_from_cmdline(char *arch_cmdline)
        return baud;
 }
 
-void __init fw_init_early_console(char port)
+void __init fw_init_early_console(void)
 {
        char *arch_cmdline = pic32_getcmdline();
-       int baud = -1;
+       int baud, port;
 
        uart_base = ioremap(PIC32_BASE_UART, 0xc00);
 
        baud = get_baud_from_cmdline(arch_cmdline);
-       if (port == -1)
-               port = get_port_from_cmdline(arch_cmdline);
+       port = get_port_from_cmdline(arch_cmdline);
 
        if (port == -1)
                port = EARLY_CONSOLE_PORT;
index 08c46cf122d73576c9998c861ebe1fcd3f4076f7..53b227a9074cc6caba948fe33762aaa80ee65e10 100644 (file)
@@ -47,7 +47,7 @@ void __init plat_mem_setup(void)
                strscpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
 
 #ifdef CONFIG_EARLY_PRINTK
-       fw_init_early_console(-1);
+       fw_init_early_console();
 #endif
        pic32_config_init();
 }