From: Andrew Morton Signed-off-by: Andrew Morton --- arch/i386/lib/kgdb_serial.c | 28 ++++++++++++---------------- 1 files changed, 12 insertions(+), 16 deletions(-) diff -puN arch/i386/lib/kgdb_serial.c~kgdb-serial-cleanup-3 arch/i386/lib/kgdb_serial.c --- devel/arch/i386/lib/kgdb_serial.c~kgdb-serial-cleanup-3 2006-02-27 02:43:55.000000000 -0800 +++ devel-akpm/arch/i386/lib/kgdb_serial.c 2006-02-27 02:43:55.000000000 -0800 @@ -93,34 +93,30 @@ static int read_data_bfr(struct async_st * but we will just depend on the uart status to help keep that straight. */ -static spinlock_t uart_interrupt_lock = SPIN_LOCK_UNLOCKED; -#ifdef CONFIG_SMP +static DEFINE_SPINLOCK(uart_interrupt_lock); extern spinlock_t kgdb_spinlock; -#endif -static int -read_char(struct async_struct *info) +static int read_char(struct async_struct *info) { int chr; unsigned long flags; local_irq_save(flags); -#ifdef CONFIG_SMP - if (!spin_is_locked(&kgdb_spinlock)) { + + if (!spin_is_locked(&kgdb_spinlock)) spin_lock(&uart_interrupt_lock); - } -#endif - if (atomic_read(&gdb_buf_in_cnt) != 0) { /* intr routine has q'd chars */ + + if (atomic_read(&gdb_buf_in_cnt) != 0) { + /* intr routine has q'd chars */ chr = gdb_buf[gdb_buf_out_inx++]; gdb_buf_out_inx &= (ARRAY_SIZE(gdb_buf) - 1); atomic_dec(&gdb_buf_in_cnt); } else { chr = read_data_bfr(info); } -#ifdef CONFIG_SMP - if (!spin_is_locked(&kgdb_spinlock)) { + + if (!spin_is_locked(&kgdb_spinlock)) spin_unlock(&uart_interrupt_lock); - } -#endif + local_irq_restore(flags); return (chr); } @@ -311,7 +307,6 @@ static void program_uart(struct async_st */ int kgdb_in_isr; int kgdb_in_lsr; -extern spinlock_t kgdb_spinlock; /* Caller takes needed protections */ @@ -346,7 +341,6 @@ int getDebugChar(void) } static int count = 3; -static spinlock_t one_at_atime = SPIN_LOCK_UNLOCKED; static int __init kgdb_enable_ints(void) { @@ -377,6 +371,8 @@ static inline int kgdb_mem_init_done(voi static void kgdb_enable_ints_now(void) { + static DEFINE_SPINLOCK(one_at_atime); + if (!spin_trylock(&one_at_atime)) return; if (!ints_disabled) _