Commit 46e36683 authored by Alexander Sverdlin's avatar Alexander Sverdlin Committed by Greg Kroah-Hartman

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: default avatarAlexander Sverdlin <alexander.sverdlin@nokia.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8f975fe4
...@@ -639,7 +639,7 @@ static int univ8250_console_match(struct console *co, char *name, int idx, ...@@ -639,7 +639,7 @@ static int univ8250_console_match(struct console *co, char *name, int idx,
{ {
char match[] = "uart"; /* 8250-specific earlycon name */ char match[] = "uart"; /* 8250-specific earlycon name */
unsigned char iotype; unsigned char iotype;
unsigned long addr; resource_size_t addr;
int i; int i;
if (strncmp(name, match, 4) != 0) if (strncmp(name, match, 4) != 0)
......
...@@ -38,7 +38,7 @@ static struct earlycon_device early_console_dev = { ...@@ -38,7 +38,7 @@ static struct earlycon_device early_console_dev = {
.con = &early_con, .con = &early_con,
}; };
static void __iomem * __init earlycon_map(unsigned long paddr, size_t size) static void __iomem * __init earlycon_map(resource_size_t paddr, size_t size)
{ {
void __iomem *base; void __iomem *base;
#ifdef CONFIG_FIX_EARLYCON_MEM #ifdef CONFIG_FIX_EARLYCON_MEM
...@@ -49,8 +49,7 @@ static void __iomem * __init earlycon_map(unsigned long paddr, size_t size) ...@@ -49,8 +49,7 @@ static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
base = ioremap(paddr, size); base = ioremap(paddr, size);
#endif #endif
if (!base) if (!base)
pr_err("%s: Couldn't map 0x%llx\n", __func__, pr_err("%s: Couldn't map %pa\n", __func__, &paddr);
(unsigned long long)paddr);
return base; return base;
} }
...@@ -92,7 +91,7 @@ static int __init parse_options(struct earlycon_device *device, char *options) ...@@ -92,7 +91,7 @@ static int __init parse_options(struct earlycon_device *device, char *options)
{ {
struct uart_port *port = &device->port; struct uart_port *port = &device->port;
int length; int length;
unsigned long addr; resource_size_t addr;
if (uart_parse_earlycon(options, &port->iotype, &addr, &options)) if (uart_parse_earlycon(options, &port->iotype, &addr, &options))
return -EINVAL; return -EINVAL;
......
...@@ -1892,11 +1892,14 @@ uart_get_console(struct uart_port *ports, int nr, struct console *co) ...@@ -1892,11 +1892,14 @@ uart_get_console(struct uart_port *ports, int nr, struct console *co)
* console=<name>,0x<addr>,<options> * console=<name>,0x<addr>,<options>
* is also accepted; the returned @iotype will be UPIO_MEM. * is also accepted; the returned @iotype will be UPIO_MEM.
* *
* Returns 0 on success or -EINVAL on failure * Returns 0 on success, -EINVAL or -ERANGE on failure
*/ */
int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr, int uart_parse_earlycon(char *p, unsigned char *iotype, resource_size_t *addr,
char **options) char **options)
{ {
int ret;
unsigned long long tmp;
if (strncmp(p, "mmio,", 5) == 0) { if (strncmp(p, "mmio,", 5) == 0) {
*iotype = UPIO_MEM; *iotype = UPIO_MEM;
p += 5; p += 5;
...@@ -1922,7 +1925,10 @@ int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr, ...@@ -1922,7 +1925,10 @@ int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr,
return -EINVAL; return -EINVAL;
} }
*addr = simple_strtoul(p, NULL, 0); ret = kstrtoull(p, 0, &tmp);
if (ret)
return ret;
*addr = tmp;
p = strchr(p, ','); p = strchr(p, ',');
if (p) if (p)
p++; p++;
......
...@@ -374,7 +374,7 @@ extern int of_setup_earlycon(const struct earlycon_id *match, ...@@ -374,7 +374,7 @@ extern int of_setup_earlycon(const struct earlycon_id *match,
struct uart_port *uart_get_console(struct uart_port *ports, int nr, struct uart_port *uart_get_console(struct uart_port *ports, int nr,
struct console *c); struct console *c);
int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr, int uart_parse_earlycon(char *p, unsigned char *iotype, resource_size_t *addr,
char **options); char **options);
void uart_parse_options(char *options, int *baud, int *parity, int *bits, void uart_parse_options(char *options, int *baud, int *parity, int *bits,
int *flow); int *flow);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment