--- linux-2.6.10-ac2/drivers/char/moxa.c.orig 2005-01-02 01:10:54.000000000 +0200 +++ linux-2.6.10-ac2/drivers/char/moxa.c 2005-01-02 07:29:00.000000000 +0200 @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -153,6 +152,7 @@ int blocked_open; long event; /* long req'd for set_bit --RR */ int asyncflags; + spinlock_t lock; unsigned long statusflags; struct tty_struct *tty; int cflag; @@ -516,7 +516,6 @@ struct moxa_str *ch; int port; int retval; - unsigned long page; port = PORTNO(tty); if (port == MAX_PORTS) { @@ -1004,11 +1003,10 @@ printk("block_til_ready before block: ttys%d, count = %d\n", ch->line, ch->count); #endif - save_flags(flags); - cli(); + spin_lock_irqsave(&ch->lock, flags); if (!tty_hung_up_p(filp)) ch->count--; - restore_flags(flags); + spin_unlock_irqrestore(&ch->lock, flags); ch->blocked_open++; while (1) { set_current_state(TASK_INTERRUPTIBLE); @@ -1129,10 +1127,9 @@ charptr = tp->flip.char_buf_ptr; flagptr = tp->flip.flag_buf_ptr; rc = tp->flip.count; - save_flags(flags); - cli(); + spin_lock_irqsave(&ch->lock, flags); count = MoxaPortReadData(ch->port, charptr, space); - restore_flags(flags); + spin_unlock_irqrestore(&ch->lock, flags); for (i = 0; i < count; i++) *flagptr++ = 0; charptr += count;