From patchwork Mon Apr 23 09:51:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10356545 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 E53BC60225 for ; Mon, 23 Apr 2018 09:56:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3EC2289BF for ; Mon, 23 Apr 2018 09:56:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8B9128A03; Mon, 23 Apr 2018 09:56:49 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 4B5AF289BF for ; Mon, 23 Apr 2018 09:56:49 +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=aBeCKTRoLib3GgeErJJc5+5F53XyoRW9O53HnH0tDbo=; b=Uk2YwOxc9YTXN6DNpWyFccXCrT 7JCzjvBP7GaKQZLD+Hcnupn7E8ZxQ6R1XI5L7jVkXfthPAOwQjcSEPN2DI2OvpyzWYbjEMPZYVPkv dEdwInmf5dZf2ZeE0GPtxfg0NNLF0drCAc0T2Iq/vvEW6GcXb/dESbUsBAoMEKgfrXtM5cqGJyPgg nHXltGI3yhVrPdlQ0X13zmsycUXqtYGK1mBmhytOnSTpU/j2AraUn/EWNIHdTuC5S7LcCW4nngEjI uIQkbQXt/PQrlLxwFxcKwgw9c6f8S7tS7Z4T+AnUoI4Gwif3Vl6pRKyC1yCrahb10XITqmYTBxZx0 stLgy/1w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fAYD9-0006Eo-EA; Mon, 23 Apr 2018 09:56:39 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fAY7z-0002mP-9g for linux-arm-kernel@lists.infradead.org; Mon, 23 Apr 2018 09:51:31 +0000 Received: by mail-wr0-x244.google.com with SMTP id v60-v6so39400712wrc.7 for ; Mon, 23 Apr 2018 02:51:08 -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=IurOd2JqdG+7jSB1hwjjGsnHufPOir2b/Fh/NXGSayE=; b=A1+/s+zaTPB03an+C4lTw8LdxDPw+wu/J/1ODc1FkjoTeI3Ime185I0KteD1yiQXen Eluguhqhia/9HGVMSqE8H7coU/EnM4yFlVN6Fs8Upw7b+xvTfrihDKoIY3ZGCKzi3Hu4 ewAOMHgshFR6WnBaL114IXi5XZCfy+t7NJijI435Hvw6LRoA9w/f8E6Qh6v6Firx4xsQ p0XQfORmxa5G4N9z8wMvS/3zUXVsKupNwntXvYY6OIfBms26oZ1TiD0KeMP9pQR6OUA8 BJZAKLo7H3Mw4ISepix49tV8oBqXazcoz6aXQiTF2Ai39CbLeMtdLp+LJ8DnGDYHQjsU jtrg== 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=IurOd2JqdG+7jSB1hwjjGsnHufPOir2b/Fh/NXGSayE=; b=OVm5IXATfbfsmSWrFILxmxV0zjRA3ju9IXNlrFJmsrSuKDmecLjlVkIbxYz7IVkKRT o9Dh5xhnKtnj6dAPj/Q7EiWyytrQsT26YH05loqNOzqhZ2reNyTZAUJ6ZgBf9Dbryc5s 40xito+dSbErMxVExLpEXmvuzJ+fvC9RfCMTWbqCqCDH3xjJz5YWFwHtj28cm0MIIuUH cpVMJB2535d4CWvqICqn0ttoXCNpqNwJ7NvQXlayaCl7G5LMBMd3wmjM1po3HbA033Rd qXqLImbdsqTWHjWEAOZjlzVTc4ZS9Qfb1r48A4h12OJfmEgoeuipaj5zY2CSfKKaDR4P 4IWg== X-Gm-Message-State: ALQs6tACtfXOnqsO0w4bOo3Ch6BOryqzczFiNStFdCPUCjEiC/D40kDQ ZWwCUDMHkku0go5QkA/bniVqYg== X-Google-Smtp-Source: AIpwx48hKubXfusEzVGK2t5jC0JNZDatHDCJSZPMkt+wZQjZw2xgqagBJE+chcTpeyc+8w7REyp9+g== X-Received: by 2002:adf:e802:: with SMTP id o2-v6mr7263770wrm.123.1524477067579; Mon, 23 Apr 2018 02:51:07 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id b83sm8778655wmb.0.2018.04.23.02.51.06 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 23 Apr 2018 02:51:07 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, Alan Cox , geert+renesas@glider.be Subject: [PATCH 2/4] serial: uartps: Use dynamic array for console port Date: Mon, 23 Apr 2018 11:51:01 +0200 Message-Id: <4878fdc4564d4574b18307f80f1e9a0c00c63111.1524477059.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180423_025119_393776_4DAA091F X-CRM114-Status: GOOD ( 16.41 ) 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: Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, 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 Reviewed-by: Alan Cox --- 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 932210331484..789423d081ed 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1206,6 +1206,10 @@ OF_EARLYCON_DECLARE(cdns, "cdns,uart-r1p8", cdns_early_console_setup); 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 @@ -1215,7 +1219,7 @@ OF_EARLYCON_DECLARE(cdns, "xlnx,zynqmp-uart", cdns_early_console_setup); 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; @@ -1261,15 +1265,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); @@ -1565,6 +1567,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, @@ -1572,6 +1585,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: