From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5643A33A9E1 for ; Fri, 29 May 2026 10:05:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780049153; cv=none; b=DpYdsx1EOh1TVywxMzPYXmvjRNxHlERUQq3HRJwJBUtk4Kf4NHsYnQukR5jf3byGc9v4fi4x9u4jXu/5Afrg8D7yI5cwjbXef5LX0jy7k6L1y/P5QhVLfzfuKDN+RQv00IIRc1ljv2L8+bVwjlZbTCvjnxSilTk9oT/sSvFJ0OU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780049153; c=relaxed/simple; bh=0nBm5C7n5xcH521kpkdII4AjM8mzQT7riEV3/wKTeAo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fBbu2caURaY+RsedRQpA7JFyTRyWXd1ne5i/DLLVVYBB2w3IW18zd07yS7mVntHzgPxHCHsFgKwcP9pOH3tK6zSqy82EiyyyFxNa516xo1rvNr23Gs0yLp1h3FVvGek2ltJF+inxAu0NPwNZ8RCp+4YemUCq4N6MpoD27qReQM8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=fYYfMZ9L; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="fYYfMZ9L" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-45ef189aa1cso420832f8f.0 for ; Fri, 29 May 2026 03:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780049151; x=1780653951; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=BEQ/eDU2Znub/dWHsQpKORC+5LoPvH9EW9RgX6b15kY=; b=fYYfMZ9LUpvDClItyZ3NeH/wWgcm65P2BgMh2YRA5TJiTyOkuEC/y8UZDpC/UHtjbw fR4dop8Dns1OUCgWFlt0PdPOlTYtHWmB95/ZNcMQgoivXtl9BdcWCKnE8nzuGyRgsGUQ MffiQgEK1mwzIRwTAJay8s4O8KZAo5nrKA96GjPpSyUdfaLA4jzELeQ+sHSnQhWjcOB4 LziEtJpQWtWOKqdO6G4b6jH035CDWD9Ca+2NLI5lHMIuLbqMQ1bP1pcbyTMBB441qxhr 4gw+rftCX5yigiyD6DxemSgzlWzzRqTeHcaT9k6EDPq1Zu9MbEQG+Y0xvve4xevO1x/1 d1BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780049151; x=1780653951; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BEQ/eDU2Znub/dWHsQpKORC+5LoPvH9EW9RgX6b15kY=; b=NB7ymhdOReznGlJPHxWu41eqd++/B7YMRGna19BwRNGlSdCPzC87rDC0ohdqlvnxL7 p0H+du9oPkBnihwPe0VrCmNvn4NwGBmOM4Pug/+QCco5vscHkFTHTv7hOWUnC+FEZl8P hDbghgJZLUps91ZPCHkopW/ibo2pdWoQzFhRFtI+cmzQaWXIRTfawnveFXThv/GFjxtx 484eQwD7vpOg8+oTBp1eQrsethfgU2svuSqVU+gePaILOe+P6zhp21R0NRolhk362/6W UlIybOldvOCljxMggk4D0u+FCQ8utHK4VGjydHnELYmTe9XRh537U9FMQxxtbmUQPNoC SX/g== X-Forwarded-Encrypted: i=1; AFNElJ82hNswQxri5wotJmYv5/6r0HU9MAyrrWQKuJSU/nRz7zWKF3n4WitA57WHfiVQogj6krx6N+r2D3oxS6I=@vger.kernel.org X-Gm-Message-State: AOJu0YxnGadYOlyDBPynYto1uvVOVy5UHUi50qik5GcOngBJ/nA12K5t oI3Wt4VXfkpPv8w+2EoVx9lljAsvPxspXONewG4G0KJ7MSQW+OZgWeWAq/+QQ6itKnI= X-Gm-Gg: Acq92OHRfnckbqKVxnmBMSEja2/ZDZqx1by7Gp1UFoXSTvR61rzb2i/Ebpys3rRENSf RygjCJvr8qN94nyf5SC8S33XW8FzlTKoliFt0AC3gGRbTZpdC0rnAbRVLcfC5bQeBNGpjcEcYic WU0ZrS1qNo07LQdT7Ur2/lovVic/p9NCehT2dGogL7y16FXlVezXMze2F8y0M7mV2y8kwWf5/o5 5IASWkwM5vg6WQ2u3E4tr0RAux1QfCfFiM09mbw52HNztHASh6MnFU9Ezyp20g+t6RB3W+XcwbB nKJq9uoeDGFulZMOs8oosSd5WveV53/xIckHugiLZUDoZN4WcKdA7llQrI07o0ETsE4mholLA5U jA35u1Qasb+dtIbgR0lnBUTDLSgffVBJzObTmNZQ1h9lLhnUEgVpZ6rVWFTcQeseVj6UtBj/hDQ /YsCLPVT4wzCo9iNo1ygj9RPkorQ== X-Received: by 2002:a5d:6892:0:b0:43d:7c1b:b8c7 with SMTP id ffacd0b85a97d-45ef142b437mr2772451f8f.21.1780049150532; Fri, 29 May 2026 03:05:50 -0700 (PDT) Received: from pathway ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45ef34a0374sm2169630f8f.2.2026.05.29.03.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 03:05:50 -0700 (PDT) Date: Fri, 29 May 2026 12:05:47 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/9] printk: Separate code for adding/updating preferred console metadata Message-ID: References: <20260423130015.85175-1-pmladek@suse.com> <20260423130015.85175-4-pmladek@suse.com> <87o6ih6kfh.fsf@jogness.linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87o6ih6kfh.fsf@jogness.linutronix.de> On Fri 2026-05-15 12:29:14, John Ogness wrote: > On 2026-04-23, Petr Mladek wrote: > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > > index 13c98285892b..d251bf8e104f 100644 > > --- a/kernel/printk/printk.c > > +++ b/kernel/printk/printk.c > > @@ -2544,18 +2544,119 @@ asmlinkage __visible void early_printk(const char *fmt, ...) > > } > > #endif > > > > -static void set_user_specified(struct preferred_console *pc, bool user_specified) > > +/** update_preferred_console - Update a given entry in the preferred_consoles[] > > + * table. > > Perhaps the description should be: > > Update or add a given entry in the preferred_consoles[] table. > > If the caller didn't match an existing preferred_console, this function > is called to add a new entry. This is obvious if you are looking at the > caller, but it is not obvious at all if you are only looking at this > function, i.e. strscpy'ing in @name or @devname is the only clue that > you are dealing with a new entry. Good point! I'll update the comment in v3. Also I'll rename the function to add_or_update_preferred_console(). It is long but the function is used only once so it does not harm that much ;-) > > + * @i: index of the entry in @preferred_consoles table which should get updated. > > + * @name: The name of the preferred console driver. > > + * @idx: Preferred console index, e.g. port number. > > + * @devname: The name of the preferred physical device. > > + * @options: Options used when setting up the console driver. > > + * @brl_options: Options used when setting up the console driver > > + * as a braille console. > > + * @user_specified: True if preferred via the kernel command line. > > + * > > + * The function ensures that the given values are consistent. Also > > + * it updates some global variables which are used to make the right > > + * decisions in register_console(). > > + * > > + * Rules: > > + * > > + * 1. Either @name and valid @idx OR @devname and @idx=-1 are allowed. > > + * Note that a valid @name and @idx will get assigned later when > > + * @devname matches during the device initialization. > > + * 2. Specify @brl_options if the console should be enabled as > > + * a Braille console [*] > > + * 3. Only matching entries can be updated. > > + * 4. @options passed via the command line are used when the same > > + * console is preferred also by some platform-specific code. > > + * > > + * [*] Braille console is using the mechanism for registering consoles > > + * but it is very special. It is primarily used for user interaction > > + * with the system. It neither gets printk() messages nor is associated > > + * with /dev/console. > > + */ > > +static int update_preferred_console(unsigned int i, > > + const char *name, const short idx, > > + const char *devname, char *options, > > + char *brl_options, bool user_specified) > > { > > - if (!user_specified) > > - return; > > + struct preferred_console *pc; > > + > > + if (i >= MAX_PREFERRED_CONSOLES) > > + return -E2BIG; > > + > > + pc = &preferred_consoles[i]; > > + > > + if (!name && !devname) > > + return -EINVAL; > > You are adding detailed error messages for all possible wrong calls > except for this on. Maybe this should be covered as well with: > > if (WARN_ON(!name && !devname)) > return -EINVAL; Makes sense. Also I am going print an error when reached the maximal number of preferred consoles in the above check. It would look like: if (i >= MAX_PREFERRED_CONSOLES) { pr_err_once("Reached maximal number of preferred consoles.\n"); return -E2BIG; } It would be nice to print some more details. But it is not that easy because we do not know whether "name" or "devname" is defined, ... IMHO, it is not worth the complexity. I guess not nobody has reached the limit in a real life scenario yet. Best Regards, Petr