Skip to content

Commit 83f672a

Browse files
fthaingeertu
authored andcommitted
m68k: Don't unregister boot console needlessly
When MACH_IS_MVME147, the boot console calls mvme147_scc_write() to generate console output. That will continue to work even after debug_cons_nputs() becomes unavailable so there's no need to unregister the boot console. Take the opportunity to remove a repeated MACH_IS_* test. Use the actual .write method (instead of a wrapper) and test that pointer instead. This means adding an unused parameter to debug_cons_nputs() for consistency with the struct console API. early_printk.c is only built when CONFIG_EARLY_PRINTK=y. As of late, head.S is only built when CONFIG_MMU_MOTOROLA=y. So let the former symbol depend on the latter, to obviate some ifdef conditionals. Cc: Daniel Palmer <[email protected]> Fixes: 077b33b ("m68k: mvme147: Reinstate early console") Signed-off-by: Finn Thain <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/d1d4328e5aa9a87bd8352529ce62b767731c0530.1743467205.git.fthain@linux-m68k.org Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent e911044 commit 83f672a

File tree

3 files changed

+19
-33
lines changed

3 files changed

+19
-33
lines changed

arch/m68k/Kconfig.debug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ config BOOTPARAM_STRING
1010

1111
config EARLY_PRINTK
1212
bool "Early printk"
13-
depends on !(SUN3 || M68000 || COLDFIRE)
13+
depends on MMU_MOTOROLA
1414
help
1515
Write kernel log output directly to a serial port.
1616
Where implemented, output goes to the framebuffer as well.

arch/m68k/kernel/early_printk.c

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,10 @@
1616
#include "../mvme147/mvme147.h"
1717
#include "../mvme16x/mvme16x.h"
1818

19-
asmlinkage void __init debug_cons_nputs(const char *s, unsigned n);
20-
21-
static void __ref debug_cons_write(struct console *c,
22-
const char *s, unsigned n)
23-
{
24-
#if !(defined(CONFIG_SUN3) || defined(CONFIG_M68000) || \
25-
defined(CONFIG_COLDFIRE))
26-
if (MACH_IS_MVME147)
27-
mvme147_scc_write(c, s, n);
28-
else if (MACH_IS_MVME16x)
29-
mvme16x_cons_write(c, s, n);
30-
else
31-
debug_cons_nputs(s, n);
32-
#endif
33-
}
19+
asmlinkage void __init debug_cons_nputs(struct console *c, const char *s, unsigned int n);
3420

3521
static struct console early_console_instance = {
3622
.name = "debug",
37-
.write = debug_cons_write,
3823
.flags = CON_PRINTBUFFER | CON_BOOT,
3924
.index = -1
4025
};
@@ -44,27 +29,28 @@ static int __init setup_early_printk(char *buf)
4429
if (early_console || buf)
4530
return 0;
4631

32+
if (MACH_IS_MVME147)
33+
early_console_instance.write = mvme147_scc_write;
34+
else if (MACH_IS_MVME16x)
35+
early_console_instance.write = mvme16x_cons_write;
36+
else
37+
early_console_instance.write = debug_cons_nputs;
4738
early_console = &early_console_instance;
4839
register_console(early_console);
4940

5041
return 0;
5142
}
5243
early_param("earlyprintk", setup_early_printk);
5344

54-
/*
55-
* debug_cons_nputs() defined in arch/m68k/kernel/head.S cannot be called
56-
* after init sections are discarded (for platforms that use it).
57-
*/
58-
#if !(defined(CONFIG_SUN3) || defined(CONFIG_M68000) || \
59-
defined(CONFIG_COLDFIRE))
60-
6145
static int __init unregister_early_console(void)
6246
{
63-
if (!early_console || MACH_IS_MVME16x)
64-
return 0;
47+
/*
48+
* debug_cons_nputs() defined in arch/m68k/kernel/head.S cannot be
49+
* called after init sections are discarded (for platforms that use it).
50+
*/
51+
if (early_console && early_console->write == debug_cons_nputs)
52+
return unregister_console(early_console);
6553

66-
return unregister_console(early_console);
54+
return 0;
6755
}
6856
late_initcall(unregister_early_console);
69-
70-
#endif

arch/m68k/kernel/head.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,8 +3263,8 @@ func_return putn
32633263
* turns around and calls the internal routines. This routine
32643264
* is used by the boot console.
32653265
*
3266-
* The calling parameters are:
3267-
* void debug_cons_nputs(const char *str, unsigned length)
3266+
* The function signature is -
3267+
* void debug_cons_nputs(struct console *c, const char *s, unsigned int n)
32683268
*
32693269
* This routine does NOT understand variable arguments only
32703270
* simple strings!
@@ -3273,8 +3273,8 @@ ENTRY(debug_cons_nputs)
32733273
moveml %d0/%d1/%a0,%sp@-
32743274
movew %sr,%sp@-
32753275
ori #0x0700,%sr
3276-
movel %sp@(18),%a0 /* fetch parameter */
3277-
movel %sp@(22),%d1 /* fetch parameter */
3276+
movel %sp@(22),%a0 /* char *s */
3277+
movel %sp@(26),%d1 /* unsigned int n */
32783278
jra 2f
32793279
1:
32803280
#ifdef CONSOLE_DEBUG

0 commit comments

Comments
 (0)