From patchwork Fri Jun 3 15:19:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 69261 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp317892qgf; Fri, 3 Jun 2016 08:20:09 -0700 (PDT) X-Received: by 10.107.39.149 with SMTP id n143mr6013393ion.50.1464967209219; Fri, 03 Jun 2016 08:20:09 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s63si8074553pfd.27.2016.06.03.08.20.09; Fri, 03 Jun 2016 08:20:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933086AbcFCPUH (ORCPT + 2 others); Fri, 3 Jun 2016 11:20:07 -0400 Received: from foss.arm.com ([217.140.101.70]:53567 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932229AbcFCPTz (ORCPT ); Fri, 3 Jun 2016 11:19:55 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 85B93F; Fri, 3 Jun 2016 08:20:25 -0700 (PDT) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DBCBE3F253; Fri, 3 Jun 2016 08:19:52 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: Mark Rutland , Greg Kroah-Hartman , Jiri Slaby , Leif Lindholm , Peter Hurley , Rob Herring , Will Deacon , linux-serial@vger.kernel.org Subject: [PATCH] serial: earlycon: stop abusing console::index Date: Fri, 3 Jun 2016 16:19:33 +0100 Message-Id: <1464967173-27744-1-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Commit cda64e6824026575 ("serial: earlycon: Fixup earlycon console name and index") added code to decompose an earlycon driver name into a string prefix and numeric suffix, and place this into console::name and console::index, such that we'd get a pretty name out of the core console code, which requires a name and index. This is simply to give a pretty/useful earlycon driver name in the log messages, and other than logging the name and index hold no significance. However, this is broken for drivers such as "pl011", where the "011" suffix gets stripped off, then subsequently restored, printed as a decimal, erroneously giving "pl11" in log messages. Additionally, for earlycon drivers without a numeric suffix, "0" is added regardless. Thus the code is broken in some cases, and generally inconsistent. Instead, this patch changes the earlycon code to consistently register "earlycon0", but ensures that the earlycon driver name is logged at earlycon_init time. This is obvious, consistent, and sufficient to provide the required information to the user. With this in place, amongst the first messages from the kernel, the user will see something like: [ 0.000000] earlycon: earlycon0 (pl011) at MMIO 0x000000007ff80000 (options '') [ 0.000000] bootconsole [earlycon0] enabled Signed-off-by: Mark Rutland Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: Leif Lindholm Cc: Peter Hurley Cc: Rob Herring Cc: Will Deacon Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/tty/serial/earlycon.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c index 067783f..2b6622a 100644 --- a/drivers/tty/serial/earlycon.c +++ b/drivers/tty/serial/earlycon.c @@ -29,7 +29,7 @@ #include static struct console early_con = { - .name = "uart", /* fixed up at earlycon registration */ + .name = "earlycon", .flags = CON_PRINTBUFFER | CON_BOOT, .index = 0, }; @@ -60,24 +60,13 @@ static void __init earlycon_init(struct earlycon_device *device, { struct console *earlycon = device->con; struct uart_port *port = &device->port; - const char *s; - size_t len; - - /* scan backwards from end of string for first non-numeral */ - for (s = name + strlen(name); - s > name && s[-1] >= '0' && s[-1] <= '9'; - s--) - ; - if (*s) - earlycon->index = simple_strtoul(s, NULL, 10); - len = s - name; - strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name))); + earlycon->data = &early_console_dev; if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 || port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE) - pr_info("%s%d at MMIO%s %pa (options '%s')\n", - earlycon->name, earlycon->index, + pr_info("%s%d (%s) at MMIO%s %pa (options '%s')\n", + earlycon->name, earlycon->index, name, (port->iotype == UPIO_MEM) ? "" : (port->iotype == UPIO_MEM16) ? "16" : (port->iotype == UPIO_MEM32) ? "32" : "32be",