tty/serial: lay the foundations for the next set of reworks
[linux-2.6-block.git] / drivers / serial / crisv10.c
index 88e7c1d5b919f455b47658367b9b7d835d849ba9..8b9af73c1d594f2c43f6c7b8de2d9b22df9c9368 100644 (file)
@@ -3581,8 +3581,9 @@ rs_tiocmset(struct tty_struct *tty, struct file *file,
                unsigned int set, unsigned int clear)
 {
        struct e100_serial *info = (struct e100_serial *)tty->driver_data;
+       unsigned long flags;
 
-       lock_kernel();
+       local_irq_save(flags);
 
        if (clear & TIOCM_RTS)
                e100_rts(info, 0);
@@ -3604,7 +3605,7 @@ rs_tiocmset(struct tty_struct *tty, struct file *file,
        if (set & TIOCM_CD)
                e100_cd_out(info, 1);
 
-       unlock_kernel();
+       local_irq_restore(flags);
        return 0;
 }
 
@@ -3613,8 +3614,10 @@ rs_tiocmget(struct tty_struct *tty, struct file *file)
 {
        struct e100_serial *info = (struct e100_serial *)tty->driver_data;
        unsigned int result;
+       unsigned long flags;
+
+       local_irq_save(flags);
 
-       lock_kernel();
        result =
                (!E100_RTS_GET(info) ? TIOCM_RTS : 0)
                | (!E100_DTR_GET(info) ? TIOCM_DTR : 0)
@@ -3623,7 +3626,7 @@ rs_tiocmget(struct tty_struct *tty, struct file *file)
                | (!E100_CD_GET(info) ? TIOCM_CAR : 0)
                | (!E100_CTS_GET(info) ? TIOCM_CTS : 0);
 
-       unlock_kernel();
+       local_irq_restore(flags);
 
 #ifdef SERIAL_DEBUG_IO
        printk(KERN_DEBUG "ser%i: modem state: %i 0x%08X\n",
@@ -3702,10 +3705,6 @@ rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        struct e100_serial *info = (struct e100_serial *)tty->driver_data;
 
-       if (tty->termios->c_cflag == old_termios->c_cflag &&
-           tty->termios->c_iflag == old_termios->c_iflag)
-               return;
-
        change_speed(info);
 
        /* Handle turning off CRTSCTS */
@@ -3808,10 +3807,8 @@ rs_close(struct tty_struct *tty, struct file * filp)
 #endif
 
        shutdown(info);
-       if (tty->driver->flush_buffer)
-               tty->driver->flush_buffer(tty);
-       if (tty->ldisc.flush_buffer)
-               tty->ldisc.flush_buffer(tty);
+       rs_flush_buffer(tty);
+       tty_ldisc_flush_buffer(tty);
        tty->closing = 0;
        info->event = 0;
        info->tty = 0;
@@ -3885,6 +3882,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
         * Check R_DMA_CHx_STATUS bit 0-6=number of available bytes in FIFO
         * R_DMA_CHx_HWSW bit 31-16=nbr of bytes left in DMA buffer (0=64k)
         */
+       lock_kernel();
        orig_jiffies = jiffies;
        while (info->xmit.head != info->xmit.tail || /* More in send queue */
               (*info->ostatusadr & 0x007f) ||  /* more in FIFO */
@@ -3901,6 +3899,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
                        curr_time_usec - info->last_tx_active_usec;
        }
        set_current_state(TASK_RUNNING);
+       unlock_kernel();
 }
 
 /*