Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3840080pxv; Mon, 19 Jul 2021 10:00:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydJRjDZcAZpIKkZHjm0BzO0bBTU9Iyltii+/zNoD8RxOkcQncGLgQh1g/90lG1wG6ZGARK X-Received: by 2002:a17:906:2413:: with SMTP id z19mr27620047eja.215.1626713916164; Mon, 19 Jul 2021 09:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626713916; cv=none; d=google.com; s=arc-20160816; b=DyoFm98+wDt9eQ9eicw6j/jpXQxDn96b4L2eHrJbZxIGS6yI0Y+aix+mTqHIRTIA67 SDQ5hTKaTmcgsG6ruZcU259z+8r/zEHuQonYtj3exiyR1yDbhHopxIIv6XDXp+PtBC0U Ji1D88r80SMexFX7N1gEWOWA4dUUm2Av6bhUqdhPtXwS6NeMynoJNmOIVgo81t5Z3veN JzLM9k9ywyLaMp8vYifVMXsXdrrz//hHXnatmz7I13LagUP5n+KHkS8wnEYHZLHPDZc8 yAcMPD7xVSjdzmcuZEalSPiWsfrtlAHe1aG1X3vedDa8sScTeDsCoLOg4TjS82Vp9DIR tvww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Xq3rskFobt5RRGTjQ8g/s+YP8GyHtCpgYXeD69EGA9Y=; b=OBwHeBGVctY2TOCRIjm3WL2/CKbi+gh+/Wp4n1LinB88aFoBJWIaa3nw7us8/2mcob KKptwGxr1as4PyGAF3SrYq5spRUBM6Gue+EWQUDNXlNWnvWc+Bqm6C0J0A+AWbLAcs+7 eQy3puU1J+OoBhJzN/E79KzHtdSUgP2NRfdftHZQsYsLcjBnhz1KOP1zYS073U1rIRuZ N8ys2klnHzuDIQtUZSW63cX2+t2ANECgqJlr206PnOs7SVyJCjWpzvCRNBfSs2l56Xl5 Xf6ja7rqZYVgdLXYMeVJ5M/CSHMQqVVPDyBufpry7VYAxhqUOxLIjAr19INyscA+BW0X NLcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="cr8+LmD/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f14si17850168ejx.84.2021.07.19.09.58.13; Mon, 19 Jul 2021 09:58:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="cr8+LmD/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348708AbhGSQHb (ORCPT + 99 others); Mon, 19 Jul 2021 12:07:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:40730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344660AbhGSPGf (ORCPT ); Mon, 19 Jul 2021 11:06:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2086760551; Mon, 19 Jul 2021 15:47:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626709631; bh=5M9tpNwTPwogTjQ1oUkxOk+hKX3PShmn3FpkKt+Fn7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cr8+LmD/JmAKJeyV/6CMnOofEgbwlX9Bv36OKzUv1MZSCUD+3EKxNRh7iV5fB9HOr brNj/uNGqB71rJS6Isy6sbFNGhG0Xdc71uwI8MN7v/A2PBtZJjrG3vmr9g9MeDJCpl Mb3Z0b7sd50F53/E/dq+2KUbni3Q4i95A99RQrRg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Mack , Sasha Levin Subject: [PATCH 5.4 037/149] serial: tty: uartlite: fix console setup Date: Mon, 19 Jul 2021 16:52:25 +0200 Message-Id: <20210719144910.207159877@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144901.370365147@linuxfoundation.org> References: <20210719144901.370365147@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Mack [ Upstream commit d157fca711ad42e75efef3444c83d2e1a17be27a ] Remove the hack to assign the global console_port variable at probe time. This assumption that cons->index is -1 is wrong for systems that specify 'console=' in the cmdline (or 'stdout-path' in dts). Hence, on such system the actual console assignment is ignored, and the first UART that happens to be probed is used as console instead. Move the logic to console_setup() and map the console to the correct port through the array of available ports instead. Signed-off-by: Daniel Mack Link: https://lore.kernel.org/r/20210528133321.1859346-1-daniel@zonque.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/uartlite.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c index 06e79c11141d..56066d93a65b 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c @@ -508,21 +508,23 @@ static void ulite_console_write(struct console *co, const char *s, static int ulite_console_setup(struct console *co, char *options) { - struct uart_port *port; + struct uart_port *port = NULL; int baud = 9600; int bits = 8; int parity = 'n'; int flow = 'n'; - - port = console_port; + if (co->index >= 0 && co->index < ULITE_NR_UARTS) + port = ulite_ports + co->index; /* Has the device been initialized yet? */ - if (!port->mapbase) { + if (!port || !port->mapbase) { pr_debug("console on ttyUL%i not present\n", co->index); return -ENODEV; } + console_port = port; + /* not initialized yet? */ if (!port->membase) { if (ulite_request_port(port)) @@ -658,17 +660,6 @@ static int ulite_assign(struct device *dev, int id, u32 base, int irq, dev_set_drvdata(dev, port); -#ifdef CONFIG_SERIAL_UARTLITE_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 (ulite_uart_driver.cons->index == -1) - console_port = port; -#endif - /* Register the port */ rc = uart_add_one_port(&ulite_uart_driver, port); if (rc) { @@ -678,12 +669,6 @@ static int ulite_assign(struct device *dev, int id, u32 base, int irq, return rc; } -#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE - /* This is not port which is used for console that's why clean it up */ - if (ulite_uart_driver.cons->index == -1) - console_port = NULL; -#endif - return 0; } -- 2.30.2