From: Jiri Slaby <jirislaby@kernel.org>
To: Tony Lindgren <tony@atomide.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Andy Shevchenko" <andriy.shevchenko@intel.com>,
"Dhruva Gole" <d-gole@ti.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"John Ogness" <john.ogness@linutronix.de>,
"Johan Hovold" <johan@kernel.org>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH v2 2/3] serial: core: Add support for DEVNAME:0.0 style naming for kernel console
Date: Thu, 14 Sep 2023 07:43:31 +0200 [thread overview]
Message-ID: <4c9c637a-9117-4f43-a64f-892fa33958c1@kernel.org> (raw)
In-Reply-To: <20230912110350.14482-3-tony@atomide.com>
On 12. 09. 23, 13:03, Tony Lindgren wrote:
> --- /dev/null
> +++ b/drivers/tty/serial/serial_base_con.c
...
> +/* Adds a command line console to the list of consoles for driver probe time */
> +static int __init serial_base_add_con(char *name, char *opt)
> +{
> + struct serial_base_console *con;
> +
> + con = kzalloc(sizeof(*con), GFP_KERNEL);
> + if (!con)
> + return -ENOMEM;
> +
> + con->name = kstrdup(name, GFP_KERNEL);
> + if (!con->name)
> + goto free_con;
> +
> + if (opt) {
> + con->opt = kstrdup(opt, GFP_KERNEL);
> + if (!con->name)
con->opt
> + goto free_name;
> + }
> +
> + list_add_tail(&con->node, &serial_base_consoles);
> +
> + return 0;
> +
> +free_name:
> + kfree(con->name);
> +
> +free_con:
> + kfree(con);
> +
> + return -ENOMEM;
> +}
> +
> +/* Parse console name and options */
> +static int __init serial_base_parse_one(char *param, char *val,
> + const char *unused, void *arg)
> +{
> + char *opt;
> +
> + if (strcmp(param, "console"))
> + return 0;
> +
> + if (!val)
> + return 0;
> +
> + opt = strchr(val, ',');
> + if (opt) {
> + opt[0] = '\0';
> + opt++;
> + }
Can this be done without mangling val, i.e. without kstrdup below?
> + if (!strlen(val))
IOW, can this check be "val - opt > 0" or alike?
> + return 0;
> +
> + return serial_base_add_con(val, opt);
> +}
> +
> +/*
> + * The "console=" option is handled by console_setup() in printk. We can't use
> + * early_param() as do_early_param() checks for "console" and "earlycon" options
> + * so console_setup() potentially handles console also early. Use parse_args().
So why not concentrate console= handling on one place, ie. in
console_setup()? The below (second time console= handling) occurs quite
illogical to me.
> + */
> +static int __init serial_base_opts_init(void)
> +{
> + char *command_line;
> +
> + command_line = kstrdup(boot_command_line, GFP_KERNEL);
> + if (!command_line)
> + return -ENOMEM;
> +
> + parse_args("Setting serial core console", command_line,
> + NULL, 0, -1, -1, NULL, serial_base_parse_one);
> +
> + kfree(command_line);
> +
> + return 0;
> +}
thanks,
--
js
suse labs
next prev parent reply other threads:[~2023-09-14 5:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 11:03 [PATCH v2 0/3] Add support for DEVNAME:0.0 style hardware based addressing Tony Lindgren
2023-09-12 11:03 ` [PATCH v2 1/3] printk: Constify name for add_preferred_console() Tony Lindgren
2023-09-20 10:17 ` Petr Mladek
2023-09-20 10:56 ` Ilpo Järvinen
2023-09-28 6:58 ` Tony Lindgren
2023-09-12 11:03 ` [PATCH v2 2/3] serial: core: Add support for DEVNAME:0.0 style naming for kernel console Tony Lindgren
2023-09-12 12:24 ` Ilpo Järvinen
2023-09-13 12:06 ` Tony Lindgren
2023-09-12 15:06 ` Andy Shevchenko
2023-09-13 12:15 ` Tony Lindgren
2023-09-14 5:43 ` Jiri Slaby [this message]
2023-09-14 6:07 ` Tony Lindgren
2023-09-12 11:03 ` [PATCH v2 3/3] serial: core: Add sysfs links for serial core port instances for ttys Tony Lindgren
2023-09-12 15:17 ` Andy Shevchenko
2023-09-13 12:30 ` Tony Lindgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4c9c637a-9117-4f43-a64f-892fa33958c1@kernel.org \
--to=jirislaby@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=bigeasy@linutronix.de \
--cc=d-gole@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=johan@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=tony@atomide.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®