tty/serial: lay the foundations for the next set of reworks
[linux-2.6-block.git] / drivers / serial / 68360serial.c
index 1b299e8c57cdf7071b5d155aa556d4ef05d51b29..f4f737bfa0a7241f9e624ab0460cc949f7b182d9 100644 (file)
@@ -51,6 +51,7 @@ extern int  kgdb_output_string (const char* s, unsigned int count);
 
 /* #ifdef CONFIG_SERIAL_CONSOLE */ /* This seems to be a post 2.0 thing - mles */
 #include <linux/console.h>
+#include <linux/jiffies.h>
 
 /* this defines the index into rs_table for the port to use
  */
@@ -612,7 +613,7 @@ static _INLINE_ void check_modem_status(struct async_struct *info)
  * This is the serial driver's interrupt routine for a single port
  */
 /* static void rs_360_interrupt(void *dev_id) */ /* until and if we start servicing irqs here */
-static void rs_360_interrupt(int vec, void *dev_id, struct pt_regs *fp)
+static void rs_360_interrupt(int vec, void *dev_id)
 {
        u_char  events;
        int     idx;
@@ -620,7 +621,7 @@ static void rs_360_interrupt(int vec, void *dev_id, struct pt_regs *fp)
        volatile struct smc_regs *smcp;
        volatile struct scc_regs *sccp;
        
-       info = (ser_info_t *)dev_id;
+       info = dev_id;
 
        idx = PORT_NUM(info->state->smc_scc_num);
        if (info->state->smc_scc_num & NUM_IS_SCC) {
@@ -934,8 +935,6 @@ static void change_speed(ser_info_t *info)
        /*
         * Set up parity check flag
         */
-#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
-
        info->read_status_mask = (BD_SC_EMPTY | BD_SC_OV);
        if (I_INPCK(info->tty))
                info->read_status_mask |= BD_SC_FR | BD_SC_PR;
@@ -1283,7 +1282,7 @@ static int rs_360_tiocmset(struct tty_struct *tty, struct file *file,
 
        if (tty->flags & (1 << TTY_IO_ERROR))
                return -EIO;
-
+       /* FIXME: locking on info->mcr */
        if (set & TIOCM_RTS)
                info->mcr |= UART_MCR_RTS;
        if (set & TIOCM_DTR)
@@ -1437,18 +1436,6 @@ static int rs_360_ioctl(struct tty_struct *tty, struct file * file,
                                return retval;
                        end_break(info);
                        return 0;
-               case TIOCGSOFTCAR:
-                       /* return put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg); */
-                       put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg);
-                       return 0;
-               case TIOCSSOFTCAR:
-                       error = get_user(arg, (unsigned int *) arg); 
-                       if (error)
-                               return error;
-                       tty->termios->c_cflag =
-                               ((tty->termios->c_cflag & ~CLOCAL) |
-                                (arg ? CLOCAL : 0));
-                       return 0;
 #ifdef maybe
                case TIOCSERGETLSR: /* Get line status register */
                        return get_lsr_info(info, (unsigned int *) arg);
@@ -1523,15 +1510,10 @@ static int rs_360_ioctl(struct tty_struct *tty, struct file * file,
 
 /* FIX UP modem control here someday......
 */
-static void rs_360_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void rs_360_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        ser_info_t *info = (ser_info_t *)tty->driver_data;
 
-       if (   (tty->termios->c_cflag == old_termios->c_cflag)
-           && (   RELEVANT_IFLAG(tty->termios->c_iflag) 
-               == RELEVANT_IFLAG(old_termios->c_iflag)))
-         return;
-
        change_speed(info);
 
 #ifdef modem_control
@@ -1671,8 +1653,7 @@ static void rs_360_close(struct tty_struct *tty, struct file * filp)
                rs_360_wait_until_sent(tty, info->timeout);
        }
        shutdown(info);
-       if (tty->driver->flush_buffer)
-               tty->driver->flush_buffer(tty);
+       rs_360_flush_buffer(tty);
        tty_ldisc_flush(tty);           
        tty->closing = 0;
        info->event = 0;
@@ -1723,6 +1704,7 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout)
        printk("jiff=%lu...", jiffies);
 #endif
 
+       lock_kernel();
        /* We go through the loop at least once because we can't tell
         * exactly when the last character exits the shifter.  There can
         * be at least two characters waiting to be sent after the buffers
@@ -1736,7 +1718,7 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout)
                msleep_interruptible(jiffies_to_msecs(char_time));
                if (signal_pending(current))
                        break;
-               if (timeout && ((orig_jiffies + timeout) < jiffies))
+               if (timeout && (time_after(jiffies, orig_jiffies + timeout)))
                        break;
                /* The 'tx_cur' is really the next buffer to send.  We
                 * have to back up to the previous BD and wait for it
@@ -1751,6 +1733,7 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout)
                        bdp--;
        } while (bdp->status & BD_SC_READY);
        current->state = TASK_RUNNING;
+       unlock_kernel();
 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
        printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
 #endif