Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5726076imw; Wed, 20 Jul 2022 11:11:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ugGn/mCPY2YQz+wF916P8rZBYc/8MYn7gd7fjaryT7PrY+5SiT9jHkg1T7/HLieEpuY9x1 X-Received: by 2002:a17:90b:1bce:b0:1f0:505c:74f7 with SMTP id oa14-20020a17090b1bce00b001f0505c74f7mr6678798pjb.87.1658340675552; Wed, 20 Jul 2022 11:11:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658340675; cv=none; d=google.com; s=arc-20160816; b=wO9LfHjMRJg4y7EvEJimTyt5nqnBSlZ31N0ftSieSaj5dtvXAZ9vQ0M64PHd+3zUzR mZS6vVOX4YDMtalpBWXSrTgiHLFQY6CMxHr2eBYM9njYzXQvNlimJ8wBmAIIX1GjZFHU scJtc+E7Llaq6yYhzw8lMIbe5ale7JcFH1HL2ndF9vUsxD5K+Qc87sGMnfxnByCcu8sS AxDjOB4fUIYRIinIXD6u9izGPtzI5wkxOup3g7cTN9mNasCqTou5+VtHBMrYfnnzAPOQ vEJbfJ2JAcTRDbGTl8lU8SUKXVMSGG91j/iK1tCCMimxEq4D/5vNsXQLfj0RShqNkpaV vTGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=SZl3qX0LM9cd6eczZTP4tcvjVJ6Givuz0Tqtszlu9H0=; b=hgn77NNGdjQ1/Ntc5dWxZoYa30Wx0m40xf27baD0GNfMgg26NryJv5D5Al3axPrIVT jBI1zPUYsM/MJ298Ytq9BGAj9IRe5hEs8meup+YyZmPv3hIdSIZUry55z75Gb57YaNl3 bxLIycGmzq0iTdJgL2XqLnk9xpiBSZ1RMdFsWTGeNcUOoh9yxNKggY4Qocc7oQWqvyTo reuZ7DWHgucley9n9AakB1FPUgFlj3urOQXpfF2l9AHt832HGqPGLfQjclPqeMBxu7ED 54ZSz0wlPCMNxyi419OgfWHVU1MCro8sy6vJP3bqJWwt327RmRWyUqV/5kcvxG5IDnwa Imbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=U13Jza77; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a63454b000000b00419d02e5666si8451404pgk.340.2022.07.20.11.11.00; Wed, 20 Jul 2022 11:11:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=U13Jza77; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233172AbiGTRsT (ORCPT + 99 others); Wed, 20 Jul 2022 13:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbiGTRsP (ORCPT ); Wed, 20 Jul 2022 13:48:15 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AA9852DF8 for ; Wed, 20 Jul 2022 10:48:14 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id x91so24754668ede.1 for ; Wed, 20 Jul 2022 10:48:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=SZl3qX0LM9cd6eczZTP4tcvjVJ6Givuz0Tqtszlu9H0=; b=U13Jza77l6NjL8EvG5WCVxr3nyVQcvJyxXj8Z4nVZMj09m2X/+ACIxCRdKj4DW12uR UGubrBdXaBqXs1FkU7FGZJvt4qrqDXFCBgHEF/GQpJZ3MZ2yqZnt/mw7twUCVF7hBb9K iYzxl7FKWOVd9VdAgTXT39tVVyfN045T6UdO8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=SZl3qX0LM9cd6eczZTP4tcvjVJ6Givuz0Tqtszlu9H0=; b=NyBP8nyXy1va4eVtqmH8R9Hq86PHdCQU7sPxHslfaKFbN+ow3QLeDL3jYNIkm8GUNB NQS3T7ihQ+zJLqjbnXdNKBi2e4V54wEeY3w92XebIgjLQhOmD/M3/Sqc/LxOjgN+1vov IPTtG4lb8RVA1LigMW8LB2tTEUOPlTBnxT0qGrO3jXI2Oh31Tue75w2abWJC6WSzloBc mUHOkb4kydzPuMyQbOv3n5xfL4/GGEOWcLQYGG+MxsKtfUWlpnpz+7WT5dfaHyDRY4Wk f3SjftyAWPH1x76dkd9mVHu4/e5g4trzm+vX/61vHidlxhk8tCTOSZsjdsRbj+/E1spZ iF3Q== X-Gm-Message-State: AJIora+brR+eTOZsDHXdVDxJGx1hFIFxBNwXVbi7Tmx7TKtVs7aqZgfq y+qHwdV56cKfKjL8AhJuP5Ijt/yBg+rpQQ== X-Received: by 2002:a05:6402:354c:b0:43a:dc59:657 with SMTP id f12-20020a056402354c00b0043adc590657mr51070822edd.405.1658339292807; Wed, 20 Jul 2022 10:48:12 -0700 (PDT) Received: from localhost ([2620:10d:c092:400::5:d58e]) by smtp.gmail.com with ESMTPSA id lx23-20020a170906af1700b0072b11cb485asm8036351ejb.208.2022.07.20.10.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 10:48:12 -0700 (PDT) Date: Wed, 20 Jul 2022 18:48:11 +0100 From: Chris Down To: linux-kernel@vger.kernel.org Cc: Petr Mladek , Greg Kroah-Hartman , Sergey Senozhatsky , Steven Rostedt , John Ogness , Geert Uytterhoeven , kernel-team@fb.com Subject: [PATCH v3 1/2] printk: console: Create console= parser that supports named options Message-ID: <732ee897b2bd49ada3f7dee396475c5a2195071b.1658339046.git.chris@chrisdown.name> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.6 (2022-06-05) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will be used in the next patch, and for future changes like the proposed sync/nothread named options. This avoids having to use sigils like "/" to get different semantic meaning for different parts of the option string, and helps to make things more human readable and easily extensible. There are no functional changes for existing console= users. Signed-off-by: Chris Down --- kernel/printk/printk.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index b49c6ff6dca0..6094f773ad4a 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2368,6 +2368,30 @@ static void set_user_specified(struct console_cmdline *c, bool user_specified) console_set_on_cmdline = 1; } +static void parse_console_cmdline_options(struct console_cmdline *c, + char *options) +{ + bool seen_serial_opts = false; + char *key; + + while ((key = strsep(&options, ",")) != NULL) { + char *value; + + value = strchr(key, ':'); + if (value) + *(value++) = '\0'; + + if (!seen_serial_opts && isdigit(key[0]) && !value) { + seen_serial_opts = true; + c->options = key; + continue; + } + + pr_err("ignoring invalid console option: '%s%s%s'\n", key, + value ? ":" : "", value ?: ""); + } +} + static int __add_preferred_console(char *name, int idx, char *options, char *brl_options, bool user_specified) { @@ -2393,7 +2417,7 @@ static int __add_preferred_console(char *name, int idx, char *options, if (!brl_options) preferred_console = i; strlcpy(c->name, name, sizeof(c->name)); - c->options = options; + parse_console_cmdline_options(c, options); set_user_specified(c, user_specified); braille_set_options(c, brl_options); -- 2.37.1