Skip to content

Commit 1feb48b

Browse files
diandersDaniel Thompson
authored andcommitted
kgdboc: Disable all the early code when kgdboc is a module
When kgdboc is compiled as a module all of the "ekgdboc" and "kgdb_earlycon" code isn't useful and, in fact, breaks compilation. This is because early_param() isn't defined for modules and that's how this code gets configured. It turns out that this was broken by commit eae3e19 ("kgdboc: Remove useless #ifdef CONFIG_KGDB_SERIAL_CONSOLE in kgdboc") and then made worse by commit 2209956 ("kgdboc: Add kgdboc_earlycon to support early kgdb using boot consoles"). I guess the #ifdef wasn't so useless, even if it wasn't obvious why it was useful. When kgdboc was compiled as a module only "CONFIG_KGDB_SERIAL_CONSOLE_MODULE" was defined, not "CONFIG_KGDB_SERIAL_CONSOLE". That meant that the old module. Let's basically do the same thing that the old code (pre-removal of the #ifdef) did but use "IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE)" to make it more obvious what the point of the check is. We'll fix kgdboc_earlycon in a similar way. Fixes: 2209956 ("kgdboc: Add kgdboc_earlycon to support early kgdb using boot consoles") Fixes: eae3e19 ("kgdboc: Remove useless #ifdef CONFIG_KGDB_SERIAL_CONSOLE in kgdboc") Reported-by: Stephen Rothwell <[email protected]> Signed-off-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/20200519084345.1.I91670accc8a5ddabab227eb63bb4ad3e2e9d2b58@changeid Signed-off-by: Daniel Thompson <[email protected]>
1 parent 2209956 commit 1feb48b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/tty/serial/kgdboc.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ static int kgdb_tty_line;
4343

4444
static struct platform_device *kgdboc_pdev;
4545

46+
#if IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE)
4647
static struct kgdb_io kgdboc_earlycon_io_ops;
4748
static struct console *earlycon;
4849
static int (*earlycon_orig_exit)(struct console *con);
50+
#endif /* IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE) */
4951

5052
#ifdef CONFIG_KDB_KEYBOARD
5153
static int kgdboc_reset_connect(struct input_handler *handler,
@@ -140,10 +142,19 @@ static void kgdboc_unregister_kbd(void)
140142
#define kgdboc_restore_input()
141143
#endif /* ! CONFIG_KDB_KEYBOARD */
142144

143-
static void cleanup_kgdboc(void)
145+
#if IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE)
146+
static void cleanup_earlycon(void)
144147
{
145148
if (earlycon)
146149
kgdb_unregister_io_module(&kgdboc_earlycon_io_ops);
150+
}
151+
#else /* !IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE) */
152+
static inline void cleanup_earlycon(void) { }
153+
#endif /* !IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE) */
154+
155+
static void cleanup_kgdboc(void)
156+
{
157+
cleanup_earlycon();
147158

148159
if (configured != 1)
149160
return;
@@ -388,6 +399,7 @@ static struct kgdb_io kgdboc_io_ops = {
388399
.post_exception = kgdboc_post_exp_handler,
389400
};
390401

402+
#if IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE)
391403
static int kgdboc_option_setup(char *opt)
392404
{
393405
if (!opt) {
@@ -544,6 +556,7 @@ static int __init kgdboc_earlycon_init(char *opt)
544556
}
545557

546558
early_param("kgdboc_earlycon", kgdboc_earlycon_init);
559+
#endif /* IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE) */
547560

548561
module_init(init_kgdboc);
549562
module_exit(exit_kgdboc);

0 commit comments

Comments
 (0)