From patchwork Fri Jul 21 09:32:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 9856379 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DC7B2601C0 for ; Fri, 21 Jul 2017 09:34:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC75728749 for ; Fri, 21 Jul 2017 09:34:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C13D428778; Fri, 21 Jul 2017 09:34:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5285928749 for ; Fri, 21 Jul 2017 09:34:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=dIWLJA4HlKcnbyOKo+ideJXifsU8M0tCH6XYGKXktu8=; b=HcZmTmMcFhK//+XyKddQkQJ4gx qmllbBRAs899JycS/q+klSXhFWjl6dGi+10MOgF/k4b92aMUSvrmO6I8ka7A1Xj8naosTw2U5nNne 0L2aBqvNrMI3/vxR0jTrCpKj2VU3y9s6U6RDXt2AaOLiDVaJiwCmx2kxmLHyhevqBqCyCNWctVkCa N2iIJN7nZVEhErzKdVW4zTq3pa4jDoXSSyRJGjBzXI/U8a8T+IniVXzrLmCPLktFWsMo2pcrJL/ex dc+HNstfc3Lcy7IG1e8XCdg31WEcubWNAXYIhPd+VNMtYf+2A9lK60lucIKLh0l+zcDylJ5qRHOzx OCqQNdNQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dYUKM-0007yW-3m; Fri, 21 Jul 2017 09:34:30 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dYUIp-000759-UD for linux-arm-kernel@lists.infradead.org; Fri, 21 Jul 2017 09:32:58 +0000 Received: by mail-wr0-x242.google.com with SMTP id y67so11111081wrb.3 for ; Fri, 21 Jul 2017 02:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=q/irWlTaAZWdKy3IQ92D2600A5udXtfYObmHH8EhEUo=; b=q6hdWTvB1tlKzffclkod3eNB6pjsOYcjMhcwjLmFpPl9NR1HfzCPuS/99qZn6FxWHW sCYT+F7O3oZIsl7ipyrVGiG9eMwBVx6zYKQKFOq+RWoFEBvhS3diKG8mRzin7JGE6tIJ 8tcRiA3BoM2z7NYcnvvpBjdQDylDnt9zOTw1ZmXWnSsWbeE27Cc17rwFclfQM2+3rIAe GuyAaU3Zpy9Txd+73Bj8DR0fI8sjsV/TenuNYO25YHC7DtIyhinGosiBRVtu6C6mhTyr AsYFHPkSryStvGmL8LFlBYtIYaFIWPw7S9Vl0WTJhyZ6iy/ME+jqjivR5DqUqMmGYTn5 MF1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=q/irWlTaAZWdKy3IQ92D2600A5udXtfYObmHH8EhEUo=; b=o5hG4I+PbLEWw2mFhSv0ad9plpOAMGx7+MHwpGPfgN0cOQ+AVQ9NyjRUUZ1dUVhkyB xfQil3Y0O4tATd/XlxcvLgJ14UBkWJiYmZjfgwUxa0NA8lOtluic1NwhSXA/A0Wdai9K V+Rf5MVZ6ChKvuwlMr5Pt7PeYQiSbNaqfKqWa153CzOfF+rhuTHiJcwCFvfoOfjYT4PI r3r8ELgw+mkjwaaAvDGkE7t1vXwlb4T9+jjUmeUv44Ql2WOAD71tkVRRRmdokCVePIju c9ztaEVnKD38cOhHoxtg0PpRKZGBGnqnn/uVd6ZXDoFyfKyTt7bCFxprUyLy1Si+Fc6r oWnQ== X-Gm-Message-State: AIVw111ZqEN1w8m9f9OZmkYY6ikeFD9KOA1IIOX/xjt/dU6I4YtdL6uu n3MuVIg1xniozykWb/k= X-Received: by 10.223.144.129 with SMTP id i1mr9455965wri.40.1500629554138; Fri, 21 Jul 2017 02:32:34 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id 80sm673668wms.36.2017.07.21.02.32.33 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 21 Jul 2017 02:32:33 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, Alan Cox Subject: [RFC PATCH 2/4] serial: uartps: Use dynamic array for console port Date: Fri, 21 Jul 2017 11:32:25 +0200 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170721_023256_134838_665A6035 X-CRM114-Status: GOOD ( 14.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , linux-serial@vger.kernel.org, =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , Jiri Slaby MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Driver console functions are using pointer to static array with fixed size. There can be only one serial console at the time which is found by register_console(). register_console() is filling cons->index to port->line value. Signed-off-by: Michal Simek --- drivers/tty/serial/xilinx_uartps.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 4614349403c1..e6470a3111ce 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1211,6 +1211,10 @@ static int __init cdns_early_console_setup(struct earlycon_device *device, OF_EARLYCON_DECLARE(cdns, "cdns,uart-r1p12", cdns_early_console_setup); OF_EARLYCON_DECLARE(cdns, "xlnx,zynqmp-uart", cdns_early_console_setup); + +/* Static pointer to console port */ +static struct uart_port *console_port; + /** * cdns_uart_console_write - perform write operation * @co: Console handle @@ -1220,7 +1224,7 @@ static int __init cdns_early_console_setup(struct earlycon_device *device, static void cdns_uart_console_write(struct console *co, const char *s, unsigned int count) { - struct uart_port *port = &cdns_uart_port[co->index]; + struct uart_port *port = console_port; unsigned long flags; unsigned int imr, ctrl; int locked = 1; @@ -1266,15 +1270,13 @@ static void cdns_uart_console_write(struct console *co, const char *s, */ static int __init cdns_uart_console_setup(struct console *co, char *options) { - struct uart_port *port = &cdns_uart_port[co->index]; + struct uart_port *port = console_port; + int baud = 9600; int bits = 8; int parity = 'n'; int flow = 'n'; - if (co->index < 0 || co->index >= CDNS_UART_NR_PORTS) - return -EINVAL; - if (!port->membase) { pr_debug("console on " CDNS_UART_TTY_NAME "%i not present\n", co->index); @@ -1570,6 +1572,17 @@ static int cdns_uart_probe(struct platform_device *pdev) pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); +#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE + /* + * If console hasn't been found yet try to assign this port + * because it is required to be assigned for console setup function. + * If register_console() don't assign value, then console_port pointer + * is cleanup. + */ + if (cdns_uart_uart_driver.cons->index == -1) + console_port = port; +#endif + rc = uart_add_one_port(&cdns_uart_uart_driver, port); if (rc) { dev_err(&pdev->dev, @@ -1577,6 +1590,12 @@ static int cdns_uart_probe(struct platform_device *pdev) goto err_out_pm_disable; } +#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE + /* This is not port which is used for console that's why clean it up */ + if (cdns_uart_uart_driver.cons->index == -1) + console_port = NULL; +#endif + return 0; err_out_pm_disable: