diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2015-03-01 11:05:46 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-06 21:55:07 -0500 |
commit | 73abaf87f01be6fa6da3c0aa9c138a1b6b281068 (patch) | |
tree | 165c9ca2fb5d8b583cbf5d83aaa26c486a6f4f83 /drivers/tty/serial/serial_core.c | |
parent | 1e1257860fd10487795b782f1dbb5b5f2c203474 (diff) |
serial: earlycon: Refactor parse_options into serial core
Prepare to support console-defined matching; refactor the command
line parameter string processing from parse_options() into a
new core function, uart_parse_earlycon(), which decodes command line
parameters of the form:
earlycon=<name>,io|mmio|mmio32,<addr>,<options>
console=<name>,io|mmio|mmio32,<addr>,<options>
earlycon=<name>,0x<addr>,<options>
console=<name>,0x<addr>,<options>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/serial_core.c')
-rw-r--r-- | drivers/tty/serial/serial_core.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 63d29473c703..8379e3fa0162 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c | |||
@@ -1809,6 +1809,52 @@ uart_get_console(struct uart_port *ports, int nr, struct console *co) | |||
1809 | } | 1809 | } |
1810 | 1810 | ||
1811 | /** | 1811 | /** |
1812 | * uart_parse_earlycon - Parse earlycon options | ||
1813 | * @p: ptr to 2nd field (ie., just beyond '<name>,') | ||
1814 | * @iotype: ptr for decoded iotype (out) | ||
1815 | * @addr: ptr for decoded mapbase/iobase (out) | ||
1816 | * @options: ptr for <options> field; NULL if not present (out) | ||
1817 | * | ||
1818 | * Decodes earlycon kernel command line parameters of the form | ||
1819 | * earlycon=<name>,io|mmio|mmio32,<addr>,<options> | ||
1820 | * console=<name>,io|mmio|mmio32,<addr>,<options> | ||
1821 | * | ||
1822 | * The optional form | ||
1823 | * earlycon=<name>,0x<addr>,<options> | ||
1824 | * console=<name>,0x<addr>,<options> | ||
1825 | * is also accepted; the returned @iotype will be UPIO_MEM. | ||
1826 | * | ||
1827 | * Returns 0 on success or -EINVAL on failure | ||
1828 | */ | ||
1829 | int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr, | ||
1830 | char **options) | ||
1831 | { | ||
1832 | if (strncmp(p, "mmio,", 5) == 0) { | ||
1833 | *iotype = UPIO_MEM; | ||
1834 | p += 5; | ||
1835 | } else if (strncmp(p, "mmio32,", 7) == 0) { | ||
1836 | *iotype = UPIO_MEM32; | ||
1837 | p += 7; | ||
1838 | } else if (strncmp(p, "io,", 3) == 0) { | ||
1839 | *iotype = UPIO_PORT; | ||
1840 | p += 3; | ||
1841 | } else if (strncmp(p, "0x", 2) == 0) { | ||
1842 | *iotype = UPIO_MEM; | ||
1843 | } else { | ||
1844 | return -EINVAL; | ||
1845 | } | ||
1846 | |||
1847 | *addr = simple_strtoul(p, NULL, 0); | ||
1848 | p = strchr(p, ','); | ||
1849 | if (p) | ||
1850 | p++; | ||
1851 | |||
1852 | *options = p; | ||
1853 | return 0; | ||
1854 | } | ||
1855 | EXPORT_SYMBOL_GPL(uart_parse_earlycon); | ||
1856 | |||
1857 | /** | ||
1812 | * uart_parse_options - Parse serial port baud/parity/bits/flow control. | 1858 | * uart_parse_options - Parse serial port baud/parity/bits/flow control. |
1813 | * @options: pointer to option string | 1859 | * @options: pointer to option string |
1814 | * @baud: pointer to an 'int' variable for the baud rate. | 1860 | * @baud: pointer to an 'int' variable for the baud rate. |