Commit 8259cf4342029aad37660e524178c8858f48b0ab

Authored by Robin Getz
Committed by Ingo Molnar
1 parent 4d09161196

printk: Ensure that "console enabled" messages are printed on the console

Today, when a console is registered without CON_PRINTBUFFER,
end users never see the announcement of it being added, and
never know if they missed something, if the console is really
at the start or not, and just leads to general confusion.

This re-orders existing code, to make sure the console is
added, before the "console [%s%d] enabled" is printed out -
ensuring that this message is _always_ seen.

This has the desired/intended side effect of making sure that
"console enabled:" messages are printed on the bootconsole, and
the real console. This does cause the same line is printed
twice if the bootconsole and real console are the same device,
but if they are on different devices, the message is printed to
both consoles.

Signed-off-by : Robin Getz <rgetz@blackfin.uclinux.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>
LKML-Reference: <200907091308.37370.rgetz@blackfin.uclinux.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 1 changed file with 29 additions and 15 deletions Side-by-side Diff

... ... @@ -1240,22 +1240,14 @@
1240 1240 if (!(newcon->flags & CON_ENABLED))
1241 1241 return;
1242 1242  
1243   - if (bcon && ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV)) {
1244   - /* we need to iterate through twice, to make sure we print
1245   - * everything out, before we unregister the console(s)
1246   - */
1247   - printk(KERN_INFO "console handover:");
1248   - for_each_console(bcon)
1249   - printk("boot [%s%d] ", bcon->name, bcon->index);
1250   - printk(" -> real [%s%d]\n", newcon->name, newcon->index);
1251   - for_each_console(bcon)
1252   - unregister_console(bcon);
  1243 + /*
  1244 + * If we have a bootconsole, and are switching to a real console,
  1245 + * don't print everything out again, since when the boot console, and
  1246 + * the real console are the same physical device, it's annoying to
  1247 + * see the beginning boot messages twice
  1248 + */
  1249 + if (bcon && ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV))
1253 1250 newcon->flags &= ~CON_PRINTBUFFER;
1254   - } else {
1255   - printk(KERN_INFO "%sconsole [%s%d] enabled\n",
1256   - (newcon->flags & CON_BOOT) ? "boot" : "" ,
1257   - newcon->name, newcon->index);
1258   - }
1259 1251  
1260 1252 /*
1261 1253 * Put this console in the list - keep the
... ... @@ -1281,6 +1273,28 @@
1281 1273 spin_unlock_irqrestore(&logbuf_lock, flags);
1282 1274 }
1283 1275 release_console_sem();
  1276 +
  1277 + /*
  1278 + * By unregistering the bootconsoles after we enable the real console
  1279 + * we get the "console xxx enabled" message on all the consoles -
  1280 + * boot consoles, real consoles, etc - this is to ensure that end
  1281 + * users know there might be something in the kernel's log buffer that
  1282 + * went to the bootconsole (that they do not see on the real console)
  1283 + */
  1284 + if (bcon && ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV)) {
  1285 + /* we need to iterate through twice, to make sure we print
  1286 + * everything out, before we unregister the console(s)
  1287 + */
  1288 + printk(KERN_INFO "console [%s%d] enabled, bootconsole disabled\n",
  1289 + newcon->name, newcon->index);
  1290 + for_each_console(bcon)
  1291 + if (bcon->flags & CON_BOOT)
  1292 + unregister_console(bcon);
  1293 + } else {
  1294 + printk(KERN_INFO "%sconsole [%s%d] enabled\n",
  1295 + (newcon->flags & CON_BOOT) ? "boot" : "" ,
  1296 + newcon->name, newcon->index);
  1297 + }
1284 1298 }
1285 1299 EXPORT_SYMBOL(register_console);
1286 1300