Messages in this thread Patch in this message | | | Date | Wed, 20 Jul 2022 18:48:11 +0100 | From | Chris Down <> | Subject | [PATCH v3 1/2] printk: console: Create console= parser that supports named options |
| |
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 <chris@chrisdown.name> --- 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
| |