Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

m68k/amiga,atari: Fix specifying multiple debug= parameters

Since commit d6713b4091a99fa2af2fabdcd2f3fb97f32ecf2e ("m68k: early
parameter support"), the user can specify multiple debug consoles using the
"debug=" kernel command line parameter.
However, as there's only a single struct console object, which is reused,
it would actually register the same console object multiple times, causing
the following warning:

WARNING: CPU: 0 PID: 0 at kernel/printk/printk.c:2233 register_console+0x36/
console 'debug0' already registered

Make sure to register the console object only once, to avoid the warning.

Note that still only one console (the one corresponding to the last
"debug=" parameter) will be active at the same time, as the .write() method
of the already registered console object is overwritten by a subsequent
"debug=" parameter.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

+18 -6
+14 -5
arch/m68k/amiga/config.c
··· 620 620 621 621 static int __init amiga_savekmsg_setup(char *arg) 622 622 { 623 + bool registered; 624 + 623 625 if (!MACH_IS_AMIGA || strcmp(arg, "mem")) 624 626 return 0; 625 627 ··· 638 636 savekmsg->magicptr = ZTWO_PADDR(savekmsg); 639 637 savekmsg->size = 0; 640 638 639 + registered = !!amiga_console_driver.write; 641 640 amiga_console_driver.write = amiga_mem_console_write; 642 - register_console(&amiga_console_driver); 641 + if (!registered) 642 + register_console(&amiga_console_driver); 643 643 return 0; 644 644 } 645 645 ··· 723 719 724 720 static int __init amiga_debug_setup(char *arg) 725 721 { 726 - if (MACH_IS_AMIGA && !strcmp(arg, "ser")) { 727 - /* no initialization required (?) */ 728 - amiga_console_driver.write = amiga_serial_console_write; 722 + bool registered; 723 + 724 + if (!MACH_IS_AMIGA || strcmp(arg, "ser")) 725 + return 0; 726 + 727 + /* no initialization required (?) */ 728 + registered = !!amiga_console_driver.write; 729 + amiga_console_driver.write = amiga_serial_console_write; 730 + if (!registered) 729 731 register_console(&amiga_console_driver); 730 - } 731 732 return 0; 732 733 } 733 734
+4 -1
arch/m68k/atari/debug.c
··· 287 287 288 288 static int __init atari_debug_setup(char *arg) 289 289 { 290 + bool registered; 291 + 290 292 if (!MACH_IS_ATARI) 291 293 return 0; 292 294 ··· 296 294 /* defaults to ser2 for a Falcon and ser1 otherwise */ 297 295 arg = MACH_IS_FALCON ? "ser2" : "ser1"; 298 296 297 + registered = !!atari_console_driver.write; 299 298 if (!strcmp(arg, "ser1")) { 300 299 /* ST-MFP Modem1 serial port */ 301 300 atari_init_mfp_port(B9600|CS8); ··· 320 317 sound_ym.wd_data = sound_ym.rd_data_reg_sel | 0x20; /* strobe H */ 321 318 atari_console_driver.write = atari_par_console_write; 322 319 } 323 - if (atari_console_driver.write) 320 + if (atari_console_driver.write && !registered) 324 321 register_console(&atari_console_driver); 325 322 326 323 return 0;