Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3850238pxv; Mon, 19 Jul 2021 10:13:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8hC+EUXzCwG9aKZMVZ5CWvV1/sKJRJYALIoEiAfji20sOwYv5yfreAEHfHVrxCADe8vfG X-Received: by 2002:a6b:b2d7:: with SMTP id b206mr19550110iof.155.1626714792437; Mon, 19 Jul 2021 10:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626714792; cv=none; d=google.com; s=arc-20160816; b=h3ddo1vXjG1JKO3e8yo5YGMpHQoxLBiS6ljFG4Be523F2AxCoCXWfFWddaBC81ByYC I2V2/7yhS5en0cTWSBDicjq7EVO3iEf29/YLNmuZDY0TBvQ4ICCc2qUUbhE7R4rtzq0R VOrDQtoD+h7Co1/oRvMm4NjGNAnHS8oLo3+rIVDevncw0Nb/oH7MAwHEq1toKZNY/Mky dNIlg3nh8g1Rt6ecD20/t9yHpU9M8V/68VhApHmdSHp27C4vcM/occnuCCxJOYBgkFkO 9hmN9Cel4Z9Iq344IAn3sa0Xo50U3nGqQULY8BOwCpwXjToaDeO1LPbZ+lghdTUF+dzs Yi4w== 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=z7+xadqb/iT1FKIJZgxf2xXOaO4uYp62r94Tw/28eQM=; b=egQomuzSvVeZHydxP3/YdkNAcr5aRtT6vFhBD8nhkLuapabJZ0IH7aIE5XH+2btv1M FvxwFBHO/73FNjHKgMM2NR2tX8+Ztu7tllRSHzHFX5tbBXzoBV/AdTJygHl1uXA2a4l2 V5i82FLeyGvjCBzVuedk/Y+9/ubP+4rK0e2EUV+7HTxgyoAHv+COae+Wg01zJi9gfS6/ ZPp+9y5aoegxHRYOAYRAeXddNWlwRJynuHWwnNW7Qc4Hsw+UzMmxNMlHD/44cWQsgSFY xPnFZPpolHUbfLCj4eQbRz5FH4fWihBgLlW8tdnUTTe3UgfOpDrdvOYhU4TUX2U7/mVO cuzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jOSEOGjV; 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 q11si19709288ilv.18.2021.07.19.10.12.59; Mon, 19 Jul 2021 10:13:12 -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=jOSEOGjV; 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 S1350518AbhGSQ3a (ORCPT + 99 others); Mon, 19 Jul 2021 12:29:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:49596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346449AbhGSPOn (ORCPT ); Mon, 19 Jul 2021 11:14:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 66AF860FD7; Mon, 19 Jul 2021 15:54:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710085; bh=JFkwNMHTZ4m4Ln+1XXyUzVtFsElLALZFZle6sg80EAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jOSEOGjVKUxsBcVxdeHcRhoi1UG3jhZE9Rg9lRkBHFj9HfEDIcoLWGTpWgfKTO8ja XhW0hBJ+fzWQVjZ/ePLK4RWE5h2i7h16MU9SMx3cR6TMJl/lMfzPr9jlASJSupPnMs TKQ3ty67hqLo/WcZfsMedDsO7LqxSjjOeNuvZ88M= 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.10 068/243] serial: tty: uartlite: fix console setup Date: Mon, 19 Jul 2021 16:51:37 +0200 Message-Id: <20210719144943.109730888@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@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 09379db613d8..7081ab322b40 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c @@ -505,21 +505,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)) @@ -655,17 +657,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) { @@ -675,12 +666,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