vserver 1.9.3
[linux-2.6.git] / drivers / char / isicom.c
index e865044..b454bf2 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/miscdevice.h>
 #include <linux/interrupt.h>
 #include <linux/timer.h>
+#include <linux/delay.h>
 #include <linux/ioport.h>
 
 #include <asm/uaccess.h>
@@ -389,7 +390,7 @@ static void isicom_tx(unsigned long _data)
                
                tty = port->tty;
                save_flags(flags); cli();
-               txcount = MIN(TX_SIZE, port->xmit_cnt);
+               txcount = min_t(short, TX_SIZE, port->xmit_cnt);
                if ((txcount <= 0) || tty->stopped || tty->hw_stopped) {
                        restore_flags(flags);
                        continue;
@@ -421,7 +422,7 @@ static void isicom_tx(unsigned long _data)
                residue = NO;
                wrd = 0;                        
                while (1) {
-                       cnt = MIN(txcount, (SERIAL_XMIT_SIZE - port->xmit_tail));
+                       cnt = min_t(int, txcount, (SERIAL_XMIT_SIZE - port->xmit_tail));
                        if (residue == YES) {
                                residue = NO;
                                if (cnt > 0) {
@@ -484,10 +485,8 @@ static void isicom_bottomhalf(void * data)
        
        if (!tty)
                return;
-       
-       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-           tty->ldisc.write_wakeup)
-               (tty->ldisc.write_wakeup)(tty);
+
+       tty_wakeup(tty);        
        wake_up_interruptible(&tty->write_wait);
 }              
                
@@ -650,7 +649,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id,
                }        
        }
        else {                          /* Data   Packet */
-               count = MIN(byte_count, (TTY_FLIPBUF_SIZE - tty->flip.count));
+               count = min_t(unsigned short, byte_count, (TTY_FLIPBUF_SIZE - tty->flip.count));
 #ifdef ISICOM_DEBUG
                printk(KERN_DEBUG "ISICOM: Intr: Can rx %d of %d bytes.\n", 
                                        count, byte_count);
@@ -1119,8 +1118,8 @@ static void isicom_close(struct tty_struct * tty, struct file * filp)
        isicom_shutdown_port(port);
        if (tty->driver->flush_buffer)
                tty->driver->flush_buffer(tty);
-       if (tty->ldisc.flush_buffer)
-               tty->ldisc.flush_buffer(tty);
+               
+       tty_ldisc_flush(tty);
        tty->closing = 0;
        port->tty = NULL;
        if (port->blocked_open) {
@@ -1163,8 +1162,8 @@ static int isicom_write(struct tty_struct * tty, int from_user,
        save_flags(flags);
        while(1) {      
                cli();
-               cnt = MIN(count, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
-                       SERIAL_XMIT_SIZE - port->xmit_head));
+               cnt = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
+                                           SERIAL_XMIT_SIZE - port->xmit_head));
                if (cnt <= 0) 
                        break;
                
@@ -1180,8 +1179,8 @@ static int isicom_write(struct tty_struct * tty, int from_user,
                                return -EFAULT;
                        }
                        cli();
-                       cnt = MIN(cnt, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
-                       SERIAL_XMIT_SIZE - port->xmit_head));
+                       cnt = min_t(int, cnt, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
+                                                 SERIAL_XMIT_SIZE - port->xmit_head));
                        memcpy(port->xmit_buf + port->xmit_head, tmp_buf, cnt);
                }       
                else
@@ -1563,9 +1562,7 @@ static void isicom_flush_buffer(struct tty_struct * tty)
        restore_flags(flags);
        
        wake_up_interruptible(&tty->write_wait);
-       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-           tty->ldisc.write_wakeup)
-               (tty->ldisc.write_wakeup)(tty);
+       tty_wakeup(tty);
 }
 
 
@@ -1906,8 +1903,7 @@ int init_module(void)
 void cleanup_module(void)
 {
        re_schedule = 0;
-       set_current_state(TASK_INTERRUPTIBLE);
-       schedule_timeout(HZ);
+       msleep(1000);
 
 #ifdef ISICOM_DEBUG    
        printk("ISICOM: isicom_tx tx_count = %ld.\n", tx_count);