From patchwork Tue Dec 5 07:32:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 173765 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3266093vqy; Mon, 4 Dec 2023 23:35:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLUd9FWDcAmFqvRfsGcsOOUgcWCfdoqdmqNoA4KrFJulK3HFQnKyYYgIykVndZlWe/gz2L X-Received: by 2002:a17:90a:e7c4:b0:286:1e90:fe2f with SMTP id kb4-20020a17090ae7c400b002861e90fe2fmr848253pjb.15.1701761749207; Mon, 04 Dec 2023 23:35:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701761749; cv=none; d=google.com; s=arc-20160816; b=A89dxAJsTaomEivNjg3xH/PzUPVrFp3TyIyqSmHjXrguO66HnU+fElO55PQsBTs51W 6VSqexSIYOnq4MBskfNW9uSYCwAe1/0ipKS6TIhdxxzJGwvPg9lEjIyR+EiY5KJr4tc7 vURtQhXK3Bdw4uA8CjaFVKHkLdiqIALhi13AkZ6pnv7qZyZ98ejWrow/BSlM4IBt9WwM otjgMEl7i5AKXTtx/NXVrC7aBB+QCWw0RNTyJbWcoCIzMpFmKhWKPUAQPdLPbFUrX/5Q hzYfTxZj4FVM1swA/MMtT4CGh4dygXZxk96wjfknS0OLdMC0VCAS7lKNCo09tL6NZUBs fNIg== 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=N1BVdxh8ER8Wxvu7pAmmRB981/3DLJQg53C27T/UvIc=; fh=OQrZIrddo55Tm+afxTOsnGwFgD38y2NNd7tU+1OGSCE=; b=jNOqH/L1xy5htrbzKJpKHxHTdJkOVvC6cn8X1phQG735lztAmPl4ZZG9/VBFfCEoq7 uMyyyxMTG99xvtpDcc7OUsH3zXXFBHeveBcEN4GTBpAl7VMwoHuMNGmYVRjle47o+I+E mMpeVEQfAQv06C2BfO+O66DMdB9ILz7GKQ9QM2kRTa/LywE8GQHrlgkuNVax2GGkqOn6 wJ/Y/wNtnmGvdeBSB80qpZXyYI1akuYnzdbp/R47bWtheHFQSo2zPuKXkPpEcfux5fXn E88oA8RQasTnW+hY+Ae25fXNPi2mRFF7vM7wO/65Rf4KUzHfdKJacVETBWh6eCmi4gE8 OIVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@atomide.com header.s=25mailst header.b=iiapsB0i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id x14-20020a17090a46ce00b0028669c1a54bsi5722543pjg.141.2023.12.04.23.35.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 23:35:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=fail header.i=@atomide.com header.s=25mailst header.b=iiapsB0i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C1FB780A3114; Mon, 4 Dec 2023 23:35:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344587AbjLEHfa (ORCPT + 99 others); Tue, 5 Dec 2023 02:35:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjLEHf2 (ORCPT ); Tue, 5 Dec 2023 02:35:28 -0500 Received: from mail5.25mail.st (mail5.25mail.st [74.50.62.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AFDCC9; Mon, 4 Dec 2023 23:35:35 -0800 (PST) Received: from localhost (91-158-86-216.elisa-laajakaista.fi [91.158.86.216]) by mail5.25mail.st (Postfix) with ESMTPSA id AA5FA60354; Tue, 5 Dec 2023 07:35:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=atomide.com; s=25mailst; t=1701761734; bh=KP1Y9auzSXohgEBe/nM2pmeM9gWKTqhwu5purIjrJ30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iiapsB0ixP6Lf5/Ezprk5y448kv3RZzHmd3IR5yz1x4boItzQnnZN11PbSNvN4enQ lDKVr1994kakOMmX+ogP1Op4G+bxETd9sZFScCMmtNYjxc1UwE4+y2gdGMvfJwaE9s V8kI5Jt0inhXmcn+M91J/uYeJpf4vh/NYcboNbJ4JUPcibvYlOIKc0IgVghIOL7FId TkU901sjzOfjZBktm6wHzHswdJLjBfsRSQjvyiY4kqUFAIokWViTP25Dif4IJ6Bw2+ 4iVNJ1o9hw3SqFTC2GeJa7rcONy9JExiEdV/pd1/gfybmm0MI3wnz+JJk5lfEvJxVj z5jGjoOALQFpA== From: Tony Lindgren To: Greg Kroah-Hartman , Jiri Slaby , Petr Mladek , Steven Rostedt , John Ogness , Sergey Senozhatsky Cc: "David S . Miller" , Andy Shevchenko , Dhruva Gole , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH v4 3/4] serial: core: Handle serial console options Date: Tue, 5 Dec 2023 09:32:35 +0200 Message-ID: <20231205073255.20562-4-tony@atomide.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205073255.20562-1-tony@atomide.com> References: <20231205073255.20562-1-tony@atomide.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 04 Dec 2023 23:35:39 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784426527943547360 X-GMAIL-MSGID: 1784426527943547360 In order to start moving the serial console quirks out of console_setup(), let's add parsing for the quirks to the serial core layer. We can use add_preferred_console_match() to handle the quirks. At this point we can't drop the quirks from console_setup() because it would confuse add_preferred_console(). And try_enable_default_console() would get called before try_enable_preferred_console(). Note that eventually we may want to set up driver specific console quirk handling for the serial port device drivers to use. But we need to figure out which driver(s) need to call the quirk. So for now, we just handle the sparc quirk directly. Signed-off-by: Tony Lindgren --- drivers/tty/serial/serial_base_bus.c | 67 ++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/drivers/tty/serial/serial_base_bus.c b/drivers/tty/serial/serial_base_bus.c --- a/drivers/tty/serial/serial_base_bus.c +++ b/drivers/tty/serial/serial_base_bus.c @@ -207,6 +207,43 @@ void serial_base_port_device_remove(struct serial_port_device *port_dev) #ifdef CONFIG_SERIAL_CORE_CONSOLE +#ifdef __sparc__ + +/* Handle Sparc ttya and ttyb options as done in console_setup() */ +static int serial_base_add_sparc_console(struct uart_driver *drv, + struct uart_port *port) +{ + const char *name = NULL; + int ret; + + switch (port->line) { + case 0: + name = "ttya"; + break; + case 1: + name = "ttyb"; + break; + default: + return 0; + } + + ret = add_preferred_console_match(name, drv->dev_name, port->line); + if (ret && ret != -ENOENT) + return ret; + + return 0; +} + +#else + +static inline int serial_base_add_sparc_console(struct uart_driver *drv, + struct uart_port *port) +{ + return 0; +} + +#endif + static int serial_base_add_one_prefcon(const char *match, const char *dev_name, int port_id) { @@ -240,12 +277,42 @@ int serial_base_add_preferred_console(struct uart_driver *drv, struct uart_port *port) { const char *port_match __free(kfree); + const char *char_match __free(kfree) = NULL; + const char *nmbr_match __free(kfree) = NULL; + int ret; port_match = kasprintf(GFP_KERNEL, "%s:%i.%i", dev_name(port->dev), port->ctrl_id, port->port_id); if (!port_match) return -ENOMEM; + char_match = kasprintf(GFP_KERNEL, "%s%i", drv->dev_name, port->line); + if (!char_match) + return -ENOMEM; + + /* Handle ttyS specific options */ + if (!strncmp(drv->dev_name, "ttyS", 4)) { + /* No name, just a number */ + nmbr_match = kasprintf(GFP_KERNEL, "%i", port->line); + if (!nmbr_match) + return -ENODEV; + + ret = serial_base_add_one_prefcon(nmbr_match, drv->dev_name, + port->line); + if (ret) + return ret; + + /* Sparc ttya and ttyb */ + ret = serial_base_add_sparc_console(drv, port); + if (ret) + return ret; + } + + /* Handle the traditional character device name style console=ttyS0 */ + ret = serial_base_add_one_prefcon(char_match, drv->dev_name, port->line); + if (ret) + return ret; + /* Translate a hardware addressing style console=DEVNAME:0.0 */ return serial_base_add_one_prefcon(port_match, drv->dev_name, port->line); }