[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190319184325.72807-4-andriy.shevchenko@linux.intel.com>
Date: Tue, 19 Mar 2019 21:43:21 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: "H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
linux-kernel@...r.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v2 3/7] x86/boot: Split out parse_serial_port() helper for earlyprintk
The newly introduced helper will be used later on to parse serial port
in different type of earlyprintk command line arguments.
No functional change intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
arch/x86/boot/early_serial_console.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
index 05d02cd4de99..85a227a21f95 100644
--- a/arch/x86/boot/early_serial_console.c
+++ b/arch/x86/boot/early_serial_console.c
@@ -66,6 +66,20 @@ static void early_serial_init(unsigned long port, int baud)
early_serial_base = port;
}
+static unsigned long parse_serial_port(const char *arg, int off, int *pos)
+{
+ unsigned long port;
+ char *e;
+
+ port = simple_strtoull(arg + off, &e, 16);
+ if (port == 0 || arg + off == e)
+ port = DEFAULT_SERIAL_PORT;
+ else
+ *pos = e - arg;
+
+ return port;
+}
+
static void parse_earlyprintk(void)
{
int baud = DEFAULT_BAUD;
@@ -91,11 +105,7 @@ static void parse_earlyprintk(void)
* "ttyS0,115200"
*/
if (pos == 7 && !strncmp(arg + pos, "0x", 2)) {
- port = simple_strtoull(arg + pos, &e, 16);
- if (port == 0 || arg + pos == e)
- port = DEFAULT_SERIAL_PORT;
- else
- pos = e - arg;
+ port = parse_serial_port(arg, pos + 0, &pos);
early_serial_use_io_accessors();
} else if (!strncmp(arg + pos, "ttyS", 4)) {
static const int bases[] = { 0x3f8, 0x2f8 };
--
2.20.1
Powered by blists - more mailing lists