Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1144885pxv; Fri, 9 Jul 2021 19:26:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqPEC3yAzWc5T8Vtfg3Ls/xghPb0vacwRZZm4ck5s933lSrNdHus5oEFRCWsf1Mw7RKJ0t X-Received: by 2002:a17:906:35d4:: with SMTP id p20mr20907290ejb.212.1625883976224; Fri, 09 Jul 2021 19:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625883976; cv=none; d=google.com; s=arc-20160816; b=tD2s9LsDZArGzJrlR6eRok51Io6ZE7Gy1sH491nASt6JkjTS0XLWIivlovVvUGtgST uTDcgI+uxysoDT9eFSCJFKv/wPH6c0p5cNtM4GFMRQftoel1dAeJER7Q8sYFti7WqUIS XbWTkjOzKtGQhn17yP37Mthq1iPzpcPMW4vQk7clh9qZLf2o4cRNV8i1W5KiX+ROGLqC nVWRlSvaAY0DcnKw3kJd6EfC7axsUk63V0GMUb6Y+hqd2R2DYUYBTF5HwCusODuY+N7s 3278zEEW7svJ+5pG/ARgi5ZID9vkHMHN7Fp8RD4el6B5z3BLILQVBnfVVGYe8Qb+sUe7 VsGg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rnl5xNOMWPXDvfechvLGMo+RVIGJPg//1/z/k9LUZCk=; b=jSartvN/6znb4JIReDwu0vfBoTnmAE7r5VhMlcE3v6L7drfCuS4aBjgkYIbcof/Vls W1LvkzzA8rrC5tOr5vQevXdHAOTQs9QpYP2LlmaHDSQlnosE9WLoSZ5sCgFw4YRQic7p xS1L8uSR1cx5ApKtCUDFTNcH4YrAwTCsK/H2QsWfJCeV149tfEQNgwKT+q4iLmrW9roA O0QUZ1NyImSRRTEsgIoEWxZZeBlVY0dz1BgLoh3BdqOnHPOSROtAppJyNHEADGDNFgbb GeUAS7xn4uGKDrpxiPDs8WywA2lZP8EpCiIwp03LCCBZC8XOvIHx7Gexhw/xGqCnWBSZ PKxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bFRQfQNN; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs19si9520836ejc.676.2021.07.09.19.25.50; Fri, 09 Jul 2021 19:26:16 -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=@kernel.org header.s=k20201202 header.b=bFRQfQNN; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232111AbhGJC0y (ORCPT + 99 others); Fri, 9 Jul 2021 22:26:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:43192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233349AbhGJCZu (ORCPT ); Fri, 9 Jul 2021 22:25:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D0A7361407; Sat, 10 Jul 2021 02:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883785; bh=l7HpfyGaASe1EXqssYiTB8W6w7CPgRkUmS+BAL1qRFQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bFRQfQNNMfdm2VAPsR/PBKVzIK0vWY9k+YPi6OWxFACqY5fAGIQjTU4aGLApKTBPu gzfQRs3cjlX5H1m42c2ouKHBwa8htcI+tm/tQjJ14Txfo473a1OZUHVtQzzkZp88Y5 ArkeNuTl/UqlgmQ6jdI/Zz3RmmzR7fqtDYPZiKs8adj3Sg/hXKdJxWFzVnVoT7bQ5e pXesN+r38e5jLZhJRBTLdA8CzKTGoNWV7Um1O+AJL5VfhQ4T4RLv5fUZb3c6UaU5zn JOmObTzLp/HCq4TO+lOcOufUicxknilC+qV426qV5XG76qFL+VR1i2xysMDd79ZkM+ A+WzQhuN84c0w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Daniel Mack , Greg Kroah-Hartman , Sasha Levin , linux-serial@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 052/104] serial: tty: uartlite: fix console setup Date: Fri, 9 Jul 2021 22:21:04 -0400 Message-Id: <20210710022156.3168825-52-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022156.3168825-1-sashal@kernel.org> References: <20210710022156.3168825-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 f42ccc40ffa6..a5f15f22d9ef 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