rt2x00: Rework rt61 antenna selection.
[safe/jmp/linux-2.6] / drivers / char / mxser.c
index c063359..fd0abef 100644 (file)
 #include <linux/gfp.h>
 #include <linux/ioport.h>
 #include <linux/mm.h>
-#include <linux/smp_lock.h>
 #include <linux/delay.h>
 #include <linux/pci.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 
 #include "mxser.h"
@@ -91,8 +90,6 @@
 #define UART_MCR_AFE           0x20
 #define UART_LSR_SPECIAL       0x1E
 
-#define RELEVANT_IFLAG(iflag)  (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|\
-                                         IXON|IXOFF))
 
 #define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : IRQF_DISABLED)
 
@@ -321,8 +318,6 @@ struct mxser_struct {
        unsigned long event;
        int count;              /* # of fd on device */
        int blocked_open;       /* # of blocked opens */
-       long session;           /* Session of opening process */
-       long pgrp;              /* pgrp of opening process */
        unsigned char *xmit_buf;
        int xmit_head;
        int xmit_tail;
@@ -388,7 +383,6 @@ static int mxser_init(void);
 
 /* static void   mxser_poll(unsigned long); */
 static int mxser_get_ISA_conf(int, struct mxser_hwconf *);
-static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *);
 static void mxser_do_softint(struct work_struct *);
 static int mxser_open(struct tty_struct *, struct file *);
 static void mxser_close(struct tty_struct *, struct file *);
@@ -427,7 +421,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout);
 static void mxser_startrx(struct tty_struct *tty);
 static void mxser_stoprx(struct tty_struct *tty);
 
-
+#ifdef CONFIG_PCI
 static int CheckIsMoxaMust(int io)
 {
        u8 oldmcr, hwid;
@@ -450,6 +444,7 @@ static int CheckIsMoxaMust(int io)
        }
        return MOXA_OTHER_UART;
 }
+#endif
 
 /* above is modified by Victor Yu. 08-15-2002 */
 
@@ -717,6 +712,7 @@ static int mxser_init(void)
 
        /* Initialize the tty_driver structure */
        memset(mxvar_sdriver, 0, sizeof(struct tty_driver));
+       mxvar_sdriver->owner = THIS_MODULE;
        mxvar_sdriver->magic = TTY_DRIVER_MAGIC;
        mxvar_sdriver->name = "ttyMI";
        mxvar_sdriver->major = ttymajor;
@@ -1000,15 +996,12 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
                mxser_change_speed(info, NULL);
        }
 
-       info->session = process_session(current);
-       info->pgrp = process_group(current);
-
        /*
        status = mxser_get_msr(info->base, 0, info->port);
        mxser_check_modem_status(info, status);
        */
 
-/* unmark here for very high baud rate (ex. 921600 bps) used */
+       /* unmark here for very high baud rate (ex. 921600 bps) used */
        tty->low_latency = 1;
        return 0;
 }
@@ -1253,9 +1246,7 @@ static void mxser_flush_buffer(struct tty_struct *tty)
        spin_unlock_irqrestore(&info->slock, flags);
        /* above added by shinhay */
 
-       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);
 }
 
 static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
@@ -1344,43 +1335,23 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
                 *   (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
                 * Caller should use TIOCGICOUNT to see which one it was
                 */
-       case TIOCMIWAIT: {
-                       DECLARE_WAITQUEUE(wait, current);
-                       int ret;
+       case TIOCMIWAIT:
+               spin_lock_irqsave(&info->slock, flags);
+               cnow = info->icount;    /* note the counters on entry */
+               spin_unlock_irqrestore(&info->slock, flags);
+
+               wait_event_interruptible(info->delta_msr_wait, ({
+                       cprev = cnow;
                        spin_lock_irqsave(&info->slock, flags);
-                       cprev = info->icount;   /* note the counters on entry */
+                       cnow = info->icount;    /* atomic copy */
                        spin_unlock_irqrestore(&info->slock, flags);
 
-                       add_wait_queue(&info->delta_msr_wait, &wait);
-                       while (1) {
-                               spin_lock_irqsave(&info->slock, flags);
-                               cnow = info->icount;    /* atomic copy */
-                               spin_unlock_irqrestore(&info->slock, flags);
-
-                               set_current_state(TASK_INTERRUPTIBLE);
-                               if (((arg & TIOCM_RNG) &&
-                                               (cnow.rng != cprev.rng)) ||
-                                               ((arg & TIOCM_DSR) &&
-                                               (cnow.dsr != cprev.dsr)) ||
-                                               ((arg & TIOCM_CD) &&
-                                               (cnow.dcd != cprev.dcd)) ||
-                                               ((arg & TIOCM_CTS) &&
-                                               (cnow.cts != cprev.cts))) {
-                                       ret = 0;
-                                       break;
-                               }
-                               /* see if a signal did it */
-                               if (signal_pending(current)) {
-                                       ret = -ERESTARTSYS;
-                                       break;
-                               }
-                               cprev = cnow;
-                       }
-                       current->state = TASK_RUNNING;
-                       remove_wait_queue(&info->delta_msr_wait, &wait);
-                       break;
-               }
-               /* NOTREACHED */
+                       ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
+                       ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
+                       ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
+                       ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts));
+               }));
+               break;
                /*
                 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
                 * Return: write counters to the user passed counter struct
@@ -1756,16 +1727,12 @@ static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termi
        struct mxser_struct *info = tty->driver_data;
        unsigned long flags;
 
-       if ((tty->termios->c_cflag != old_termios->c_cflag) ||
-                       (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) {
-
-               mxser_change_speed(info, old_termios);
+       mxser_change_speed(info, old_termios);
 
-               if ((old_termios->c_cflag & CRTSCTS) &&
-                               !(tty->termios->c_cflag & CRTSCTS)) {
-                       tty->hw_stopped = 0;
-                       mxser_start(tty);
-               }
+       if ((old_termios->c_cflag & CRTSCTS) &&
+                       !(tty->termios->c_cflag & CRTSCTS)) {
+               tty->hw_stopped = 0;
+               mxser_start(tty);
        }
 
 /* Handle sw stopped */
@@ -1971,14 +1938,6 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
                                inb(info->base + UART_MSR);
                                continue;
                        }
-                       /* above add by Victor Yu. 09-13-2002 */
-                       /*
-                          if (info->tty->flip.count < TTY_FLIPBUF_SIZE / 4) {
-                          info->IER |= MOXA_MUST_RECV_ISR;
-                          outb(info->IER, info->base + UART_IER);
-                          }
-                        */
-
 
                        /* mask by Victor Yu. 09-13-2002
                           if ( !info->tty ||
@@ -2632,19 +2591,8 @@ static int mxser_change_speed(struct mxser_struct *info, struct ktermios *old_te
                info->IER |= UART_IER_MSI;
                if ((info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) {
                        info->MCR |= UART_MCR_AFE;
-                       /* status = mxser_get_msr(info->base, 0, info->port); */
-/*
-       save_flags(flags);
-       cli();
-       status = inb(baseaddr + UART_MSR);
-       restore_flags(flags);
-*/
-                       /* mxser_check_modem_status(info, status); */
                } else {
-                       /* status = mxser_get_msr(info->base, 0, info->port); */
-                       /* MX_LOCK(&info->slock); */
                        status = inb(info->base + UART_MSR);
-                       /* MX_UNLOCK(&info->slock); */
                        if (info->tty->hw_stopped) {
                                if (status & UART_MSR_CTS) {
                                        info->tty->hw_stopped = 0;