Skip to content

Commit dc0cf5a

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk
Pull printk fix from Petr Mladek: "This reverts a fix added into 4.12-rc1. It caused the kernel log to be printed on another console when two consoles of the same type were defined, e.g. console=ttyS0 console=ttyS1. This configuration was never supported by kernel itself, but it started to make sense with systemd. In other words, the commit broke userspace" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk: Revert "printk: fix double printing with earlycon"
2 parents d0aab7d + dac8bbb commit dc0cf5a

File tree

1 file changed

+10
-36
lines changed

1 file changed

+10
-36
lines changed

kernel/printk/printk.c

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ static struct console *exclusive_console;
269269
#define MAX_CMDLINECONSOLES 8
270270

271271
static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
272-
static int console_cmdline_cnt;
273272

274273
static int preferred_console = -1;
275274
int console_set_on_cmdline;
@@ -1906,25 +1905,12 @@ static int __add_preferred_console(char *name, int idx, char *options,
19061905
* See if this tty is not yet registered, and
19071906
* if we have a slot free.
19081907
*/
1909-
for (i = 0, c = console_cmdline; i < console_cmdline_cnt; i++, c++) {
1908+
for (i = 0, c = console_cmdline;
1909+
i < MAX_CMDLINECONSOLES && c->name[0];
1910+
i++, c++) {
19101911
if (strcmp(c->name, name) == 0 && c->index == idx) {
1911-
if (brl_options)
1912-
return 0;
1913-
1914-
/*
1915-
* Maintain an invariant that will help to find if
1916-
* the matching console is preferred, see
1917-
* register_console():
1918-
*
1919-
* The last non-braille console is always
1920-
* the preferred one.
1921-
*/
1922-
if (i != console_cmdline_cnt - 1)
1923-
swap(console_cmdline[i],
1924-
console_cmdline[console_cmdline_cnt - 1]);
1925-
1926-
preferred_console = console_cmdline_cnt - 1;
1927-
1912+
if (!brl_options)
1913+
preferred_console = i;
19281914
return 0;
19291915
}
19301916
}
@@ -1937,7 +1923,6 @@ static int __add_preferred_console(char *name, int idx, char *options,
19371923
braille_set_options(c, brl_options);
19381924

19391925
c->index = idx;
1940-
console_cmdline_cnt++;
19411926
return 0;
19421927
}
19431928
/*
@@ -2477,23 +2462,12 @@ void register_console(struct console *newcon)
24772462
}
24782463

24792464
/*
2480-
* See if this console matches one we selected on the command line.
2481-
*
2482-
* There may be several entries in the console_cmdline array matching
2483-
* with the same console, one with newcon->match(), another by
2484-
* name/index:
2485-
*
2486-
* pl011,mmio,0x87e024000000,115200 -- added from SPCR
2487-
* ttyAMA0 -- added from command line
2488-
*
2489-
* Traverse the console_cmdline array in reverse order to be
2490-
* sure that if this console is preferred then it will be the first
2491-
* matching entry. We use the invariant that is maintained in
2492-
* __add_preferred_console().
2465+
* See if this console matches one we selected on
2466+
* the command line.
24932467
*/
2494-
for (i = console_cmdline_cnt - 1; i >= 0; i--) {
2495-
c = console_cmdline + i;
2496-
2468+
for (i = 0, c = console_cmdline;
2469+
i < MAX_CMDLINECONSOLES && c->name[0];
2470+
i++, c++) {
24972471
if (!newcon->match ||
24982472
newcon->match(newcon, c->name, c->index, c->options) != 0) {
24992473
/* default matching */

0 commit comments

Comments
 (0)