From patchwork Mon Dec 18 07:09:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 180171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1075830dyi; Sun, 17 Dec 2023 23:14:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXFVzDsRYf13zwbTalfoLWtgPgyg0FvAovq/iWN4zpTDCDyQwrkYFXLU7xfYJzYcoMqQdF X-Received: by 2002:a05:6214:1312:b0:67f:24c7:a54 with SMTP id pn18-20020a056214131200b0067f24c70a54mr6193716qvb.51.1702883680003; Sun, 17 Dec 2023 23:14:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702883679; cv=none; d=google.com; s=arc-20160816; b=aGqIh2Ne/fUx2rPvkm2VdvSX5sKtze28NqaWFwbcCBXN3pwjwR2QowuGydDTs6RJc7 ge02rvTGavVLIWU7Ra/I9Uh9OGglyG9BTqjCmweLKwy2BWGx89S3UHQXqjGVz/VTVido N6COoZT6/FoQ3VVVudLUYCzfDkzFSKsnMUoSFleFUd7esCc34TU8RzahOVLmJc4JXzoV v6VmGWuqvQ38cN+xKE7KZV3XZs7yFooqbUHTlbCKeZoTwbZWCb+1BZAXwmi74EEdRGc2 o2zI/IZI3lHqDZEr4vT+1vVS0wo6bg50x+7lxs1HHTCDbx5J7scwKT1M8RWyP72XIW0B Ob8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=k9V5DPVrF+flpx86Vnug/l3AAv2D1wWDjt6veLtJxoo=; fh=OQrZIrddo55Tm+afxTOsnGwFgD38y2NNd7tU+1OGSCE=; b=UREEMGp1iadmY9EO4zFS7AFgQtPXjF6UgEDEaqVSwpICJLL+/e9IId5yw1L5HrttF9 zLdfT5fqSICpvN8ouZLBQ6+zlLNufvPCJYneIZdFuKFXUOH3zHa5tUPmrfV8nLowxTj8 WTfiMQBLynD83lW/QQtjG2L7aWRKpido1/iJj3iEyPZrY0v07ILpawZMoHrIsbsu0GCo Cq9mNCPSdacQF6+x73KtcXq60ffstesirqLbJYsF/nO/jWSEqsKBZX3a3x464ZC++SKY FDpoOUZt12gtP+VMLFE7Kqjs+SUg7vk8lq6la5XquGlVMPEpS7gVZwN91EOGXC6n/oT0 g87Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atomide.com header.s=25mailst header.b=oAZvLSH0; spf=pass (google.com: domain of linux-kernel+bounces-3087-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3087-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b1-20020a0ccd01000000b0067f2b2b7532si4541820qvm.357.2023.12.17.23.14.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 23:14:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3087-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@atomide.com header.s=25mailst header.b=oAZvLSH0; spf=pass (google.com: domain of linux-kernel+bounces-3087-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3087-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4CCD31C222A1 for ; Mon, 18 Dec 2023 07:14:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42204848B; Mon, 18 Dec 2023 07:14:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=atomide.com header.i=@atomide.com header.b="oAZvLSH0" X-Original-To: linux-kernel@vger.kernel.org Received: from mail5.25mail.st (mail5.25mail.st [74.50.62.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68C22F519; Mon, 18 Dec 2023 07:14:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomide.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=atomide.com Received: from localhost (91-158-86-216.elisa-laajakaista.fi [91.158.86.216]) by mail5.25mail.st (Postfix) with ESMTPSA id A32C2603E6; Mon, 18 Dec 2023 07:13:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=atomide.com; s=25mailst; t=1702883660; bh=4HBQW/GgIjvWli0+SMeQEsuVWaT3PJ2i4XEk11NeR2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oAZvLSH03WJr8omtxTAFNR5axlxaIwiUYk7rcofP8YV91KcrpSfI0zudexZXWoCb2 rG/98zMYFsk94HO7SkUlJBrGn9kPpVMYFOD2foJJvqq5C5xEwBsRFT8HSnc///thHW T1iU4Nqkmv6Y22oYioNvg+d7scPEBr5/wqdCY4VdFUmVhbd7CaHacd2jzvY3KVPKd1 vj7jq5f1aLJemGrXWRAgmPza0kzA0ZWcqfRb8YvkfinxWl3r3oyK2bjdPqtRbtjCXF tm3ZjQ6X1jDnvFr/m4yBuZnpzJKqCidZ5l1xElaiRFbOOR9lQ4OQiSAVmbeFt7PSGw dsJz7i3nbMaBg== 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: [RFC PATCH v5 5/6] serial: core: Handle serial console options Date: Mon, 18 Dec 2023 09:09:52 +0200 Message-ID: <20231218071020.21805-6-tony@atomide.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218071020.21805-1-tony@atomide.com> References: <20231218071020.21805-1-tony@atomide.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785602957507421305 X-GMAIL-MSGID: 1785602957507421305 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. 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 | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 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 @@ -219,9 +219,58 @@ static int serial_base_add_one_prefcon(const char *match, const char *dev_name, return ret; } +#ifdef __sparc__ + +/* Handle Sparc ttya and ttyb options as done in console_setup() */ +static int serial_base_add_sparc_console(const char *dev_name, int idx) +{ + const char *name = NULL; + + switch (idx) { + case 0: + name = "ttya"; + break; + case 1: + name = "ttyb"; + break; + default: + return 0; + } + + return serial_base_add_one_prefcon(name, dev_name, idx); +} + +#else + +static inline int serial_base_add_sparc_console(const char *dev_name, int idx) +{ + return 0; +} + +#endif + static int serial_base_add_prefcon(const char *name, int idx) { const char *char_match __free(kfree) = NULL; + const char *nmbr_match __free(kfree) = NULL; + int ret; + + /* Handle ttyS specific options */ + if (str_has_prefix(name, "ttyS")) { + /* No name, just a number */ + nmbr_match = kasprintf(GFP_KERNEL, "%i", idx); + if (!nmbr_match) + return -ENODEV; + + ret = serial_base_add_one_prefcon(nmbr_match, name, idx); + if (ret) + return ret; + + /* Sparc ttya and ttyb */ + ret = serial_base_add_sparc_console(name, idx); + if (ret) + return ret; + } /* Handle the traditional character device name style console=ttyS0 */ char_match = kasprintf(GFP_KERNEL, "%s%i", name, idx);