Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: earlycon: Extend earlycon command line option to support 64-bit addresses

earlycon implementation used "unsigned long" internally, but there are systems
(ARM with LPAE) where sizeof(unsigned long) == 4 and uart is mapped beyond 4GiB
address range.

Switch to resource_size_t internally and replace obsoleted simple_strtoul() with
kstrtoull().

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexander Sverdlin and committed by
Greg Kroah-Hartman
46e36683 8f975fe4

+14 -9
+1 -1
drivers/tty/serial/8250/8250_core.c
··· 639 639 { 640 640 char match[] = "uart"; /* 8250-specific earlycon name */ 641 641 unsigned char iotype; 642 - unsigned long addr; 642 + resource_size_t addr; 643 643 int i; 644 644 645 645 if (strncmp(name, match, 4) != 0)
+3 -4
drivers/tty/serial/earlycon.c
··· 38 38 .con = &early_con, 39 39 }; 40 40 41 - static void __iomem * __init earlycon_map(unsigned long paddr, size_t size) 41 + static void __iomem * __init earlycon_map(resource_size_t paddr, size_t size) 42 42 { 43 43 void __iomem *base; 44 44 #ifdef CONFIG_FIX_EARLYCON_MEM ··· 49 49 base = ioremap(paddr, size); 50 50 #endif 51 51 if (!base) 52 - pr_err("%s: Couldn't map 0x%llx\n", __func__, 53 - (unsigned long long)paddr); 52 + pr_err("%s: Couldn't map %pa\n", __func__, &paddr); 54 53 55 54 return base; 56 55 } ··· 91 92 { 92 93 struct uart_port *port = &device->port; 93 94 int length; 94 - unsigned long addr; 95 + resource_size_t addr; 95 96 96 97 if (uart_parse_earlycon(options, &port->iotype, &addr, &options)) 97 98 return -EINVAL;
+9 -3
drivers/tty/serial/serial_core.c
··· 1892 1892 * console=<name>,0x<addr>,<options> 1893 1893 * is also accepted; the returned @iotype will be UPIO_MEM. 1894 1894 * 1895 - * Returns 0 on success or -EINVAL on failure 1895 + * Returns 0 on success, -EINVAL or -ERANGE on failure 1896 1896 */ 1897 - int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr, 1897 + int uart_parse_earlycon(char *p, unsigned char *iotype, resource_size_t *addr, 1898 1898 char **options) 1899 1899 { 1900 + int ret; 1901 + unsigned long long tmp; 1902 + 1900 1903 if (strncmp(p, "mmio,", 5) == 0) { 1901 1904 *iotype = UPIO_MEM; 1902 1905 p += 5; ··· 1925 1922 return -EINVAL; 1926 1923 } 1927 1924 1928 - *addr = simple_strtoul(p, NULL, 0); 1925 + ret = kstrtoull(p, 0, &tmp); 1926 + if (ret) 1927 + return ret; 1928 + *addr = tmp; 1929 1929 p = strchr(p, ','); 1930 1930 if (p) 1931 1931 p++;
+1 -1
include/linux/serial_core.h
··· 374 374 375 375 struct uart_port *uart_get_console(struct uart_port *ports, int nr, 376 376 struct console *c); 377 - int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr, 377 + int uart_parse_earlycon(char *p, unsigned char *iotype, resource_size_t *addr, 378 378 char **options); 379 379 void uart_parse_options(char *options, int *baud, int *parity, int *bits, 380 380 int *flow);