[IA64] Enable early console for Ski simulator

This patch cleans up the `enable early console for SKI' patch
(471e7a44848f467c9b83adc3463d019d2fa8817f), and
1. potentially allows the gensparse_defconfig to work again.
(there are other problems running a generic kernel on Ski)
2. fixes the `console registered twice' problem.
3. Cleans up the code by moving the `extern hpsim_cons' declaration to
a new asm/hpsim.h file.

Thanks to Jes for comments.

Signed-off-by: Peter Chubb <peterc@gelato.unsw.edu.au>
Signed-off-by: Tony Luck <tony.luck@intel.com>

authored by Peter Chubb and committed by Tony Luck 8b713c67 99a19cf1

+28 -14
+14 -1
arch/ia64/hp/sim/hpsim_console.c
··· 21 #include <asm/machvec.h> 22 #include <asm/pgtable.h> 23 #include <asm/sal.h> 24 25 #include "hpsim_ssc.h" 26 ··· 29 static void simcons_write (struct console *, const char *, unsigned); 30 static struct tty_driver *simcons_console_device (struct console *, int *); 31 32 - struct console hpsim_cons = { 33 .name = "simcons", 34 .write = simcons_write, 35 .device = simcons_console_device, ··· 62 extern struct tty_driver *hp_simserial_driver; 63 *index = c->index; 64 return hp_simserial_driver; 65 }
··· 21 #include <asm/machvec.h> 22 #include <asm/pgtable.h> 23 #include <asm/sal.h> 24 + #include <asm/hpsim.h> 25 26 #include "hpsim_ssc.h" 27 ··· 28 static void simcons_write (struct console *, const char *, unsigned); 29 static struct tty_driver *simcons_console_device (struct console *, int *); 30 31 + static struct console hpsim_cons = { 32 .name = "simcons", 33 .write = simcons_write, 34 .device = simcons_console_device, ··· 61 extern struct tty_driver *hp_simserial_driver; 62 *index = c->index; 63 return hp_simserial_driver; 64 + } 65 + 66 + int simcons_register(void) 67 + { 68 + if (!ia64_platform_is("hpsim")) 69 + return 1; 70 + 71 + if (hpsim_cons.flags & CON_ENABLED) 72 + return 1; 73 + 74 + register_console(&hpsim_cons); 75 + return 0; 76 }
+2 -7
arch/ia64/hp/sim/hpsim_setup.c
··· 21 #include <asm/machvec.h> 22 #include <asm/pgtable.h> 23 #include <asm/sal.h> 24 25 #include "hpsim_ssc.h" 26 ··· 42 { 43 ROOT_DEV = Root_SDA1; /* default to first SCSI drive */ 44 45 - #ifdef CONFIG_HP_SIMSERIAL_CONSOLE 46 - { 47 - extern struct console hpsim_cons; 48 - if (ia64_platform_is("hpsim")) 49 - register_console(&hpsim_cons); 50 - } 51 - #endif 52 }
··· 21 #include <asm/machvec.h> 22 #include <asm/pgtable.h> 23 #include <asm/sal.h> 24 + #include <asm/hpsim.h> 25 26 #include "hpsim_ssc.h" 27 ··· 41 { 42 ROOT_DEV = Root_SDA1; /* default to first SCSI drive */ 43 44 + simcons_register(); 45 }
+2 -6
arch/ia64/kernel/setup.c
··· 60 #include <asm/smp.h> 61 #include <asm/system.h> 62 #include <asm/unistd.h> 63 64 #if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE) 65 # error "struct cpuinfo_ia64 too big!" ··· 390 if (!efi_setup_pcdp_console(cmdline)) 391 earlycons++; 392 #endif 393 - #ifdef CONFIG_HP_SIMSERIAL_CONSOLE 394 - { 395 - extern struct console hpsim_cons; 396 - register_console(&hpsim_cons); 397 earlycons++; 398 - } 399 - #endif 400 401 return (earlycons) ? 0 : -1; 402 }
··· 60 #include <asm/smp.h> 61 #include <asm/system.h> 62 #include <asm/unistd.h> 63 + #include <asm/hpsim.h> 64 65 #if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE) 66 # error "struct cpuinfo_ia64 too big!" ··· 389 if (!efi_setup_pcdp_console(cmdline)) 390 earlycons++; 391 #endif 392 + if (!simcons_register()) 393 earlycons++; 394 395 return (earlycons) ? 0 : -1; 396 }
+10
include/asm-ia64/hpsim.h
···
··· 1 + #ifndef _ASMIA64_HPSIM_H 2 + #define _ASMIA64_HPSIM_H 3 + 4 + #ifndef CONFIG_HP_SIMSERIAL_CONSOLE 5 + static inline int simcons_register(void) { return 1; } 6 + #else 7 + int simcons_register(void); 8 + #endif 9 + 10 + #endif