fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / char / vme_scc.c
index 6f78334..e01317c 100644 (file)
@@ -14,7 +14,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/config.h>
 #include <linux/kdev_t.h>
 #include <asm/io.h>
 #include <linux/kernel.h>
@@ -82,10 +81,10 @@ static int scc_ioctl(struct tty_struct * tty, struct file * filp,
                      unsigned int cmd, unsigned long arg);
 static void scc_throttle(struct tty_struct *tty);
 static void scc_unthrottle(struct tty_struct *tty);
-static irqreturn_t scc_tx_int(int irq, void *data, struct pt_regs *fp);
-static irqreturn_t scc_rx_int(int irq, void *data, struct pt_regs *fp);
-static irqreturn_t scc_stat_int(int irq, void *data, struct pt_regs *fp);
-static irqreturn_t scc_spcond_int(int irq, void *data, struct pt_regs *fp);
+static irqreturn_t scc_tx_int(int irq, void *data);
+static irqreturn_t scc_rx_int(int irq, void *data);
+static irqreturn_t scc_stat_int(int irq, void *data);
+static irqreturn_t scc_spcond_int(int irq, void *data);
 static void scc_setsignals(struct scc_port *port, int dtr, int rts);
 static void scc_break_ctl(struct tty_struct *tty, int break_state);
 
@@ -114,7 +113,7 @@ static struct real_driver scc_real_driver = {
 };
 
 
-static struct tty_operations scc_ops = {
+static const struct tty_operations scc_ops = {
        .open   = scc_open,
        .close = gs_close,
        .write = gs_write,
@@ -147,7 +146,6 @@ static int scc_init_drivers(void)
        scc_driver->owner = THIS_MODULE;
        scc_driver->driver_name = "scc";
        scc_driver->name = "ttyS";
-       scc_driver->devfs_name = "tts/";
        scc_driver->major = TTY_MAJOR;
        scc_driver->minor_start = SCC_MINOR_BASE;
        scc_driver->type = TTY_DRIVER_TYPE_SERIAL;
@@ -155,6 +153,8 @@ static int scc_init_drivers(void)
        scc_driver->init_termios = tty_std_termios;
        scc_driver->init_termios.c_cflag =
          B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       scc_driver->init_termios.c_ispeed = 9600;
+       scc_driver->init_termios.c_ospeed = 9600;
        scc_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(scc_driver, &scc_ops);
 
@@ -184,7 +184,7 @@ static void scc_init_portstructs(void)
                port->gs.closing_wait = 30 * HZ;
                port->gs.rd = &scc_real_driver;
 #ifdef NEW_WRITE_LOCKING
-               port->gs.port_write_sem = MUTEX;
+               port->gs.port_write_mutex = MUTEX;
 #endif
                init_waitqueue_head(&port->gs.open_wait);
                init_waitqueue_head(&port->gs.close_wait);
@@ -205,13 +205,13 @@ static int mvme147_scc_init(void)
        port->datap = port->ctrlp + 1;
        port->port_a = &scc_ports[0];
        port->port_b = &scc_ports[1];
-       request_irq(MVME147_IRQ_SCCA_TX, scc_tx_int, SA_INTERRUPT,
+       request_irq(MVME147_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
                            "SCC-A TX", port);
-       request_irq(MVME147_IRQ_SCCA_STAT, scc_stat_int, SA_INTERRUPT,
+       request_irq(MVME147_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
                            "SCC-A status", port);
-       request_irq(MVME147_IRQ_SCCA_RX, scc_rx_int, SA_INTERRUPT,
+       request_irq(MVME147_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
                            "SCC-A RX", port);
-       request_irq(MVME147_IRQ_SCCA_SPCOND, scc_spcond_int, SA_INTERRUPT,
+       request_irq(MVME147_IRQ_SCCA_SPCOND, scc_spcond_int, IRQF_DISABLED,
                            "SCC-A special cond", port);
        {
                SCC_ACCESS_INIT(port);
@@ -232,13 +232,13 @@ static int mvme147_scc_init(void)
        port->datap = port->ctrlp + 1;
        port->port_a = &scc_ports[0];
        port->port_b = &scc_ports[1];
-       request_irq(MVME147_IRQ_SCCB_TX, scc_tx_int, SA_INTERRUPT,
+       request_irq(MVME147_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
                            "SCC-B TX", port);
-       request_irq(MVME147_IRQ_SCCB_STAT, scc_stat_int, SA_INTERRUPT,
+       request_irq(MVME147_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
                            "SCC-B status", port);
-       request_irq(MVME147_IRQ_SCCB_RX, scc_rx_int, SA_INTERRUPT,
+       request_irq(MVME147_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
                            "SCC-B RX", port);
-       request_irq(MVME147_IRQ_SCCB_SPCOND, scc_spcond_int, SA_INTERRUPT,
+       request_irq(MVME147_IRQ_SCCB_SPCOND, scc_spcond_int, IRQF_DISABLED,
                            "SCC-B special cond", port);
        {
                SCC_ACCESS_INIT(port);
@@ -275,13 +275,13 @@ static int mvme162_scc_init(void)
        port->datap = port->ctrlp + 2;
        port->port_a = &scc_ports[0];
        port->port_b = &scc_ports[1];
-       request_irq(MVME162_IRQ_SCCA_TX, scc_tx_int, SA_INTERRUPT,
+       request_irq(MVME162_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
                            "SCC-A TX", port);
-       request_irq(MVME162_IRQ_SCCA_STAT, scc_stat_int, SA_INTERRUPT,
+       request_irq(MVME162_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
                            "SCC-A status", port);
-       request_irq(MVME162_IRQ_SCCA_RX, scc_rx_int, SA_INTERRUPT,
+       request_irq(MVME162_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
                            "SCC-A RX", port);
-       request_irq(MVME162_IRQ_SCCA_SPCOND, scc_spcond_int, SA_INTERRUPT,
+       request_irq(MVME162_IRQ_SCCA_SPCOND, scc_spcond_int, IRQF_DISABLED,
                            "SCC-A special cond", port);
        {
                SCC_ACCESS_INIT(port);
@@ -302,13 +302,13 @@ static int mvme162_scc_init(void)
        port->datap = port->ctrlp + 2;
        port->port_a = &scc_ports[0];
        port->port_b = &scc_ports[1];
-       request_irq(MVME162_IRQ_SCCB_TX, scc_tx_int, SA_INTERRUPT,
+       request_irq(MVME162_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
                            "SCC-B TX", port);
-       request_irq(MVME162_IRQ_SCCB_STAT, scc_stat_int, SA_INTERRUPT,
+       request_irq(MVME162_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
                            "SCC-B status", port);
-       request_irq(MVME162_IRQ_SCCB_RX, scc_rx_int, SA_INTERRUPT,
+       request_irq(MVME162_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
                            "SCC-B RX", port);
-       request_irq(MVME162_IRQ_SCCB_SPCOND, scc_spcond_int, SA_INTERRUPT,
+       request_irq(MVME162_IRQ_SCCB_SPCOND, scc_spcond_int, IRQF_DISABLED,
                            "SCC-B special cond", port);
 
        {
@@ -343,13 +343,13 @@ static int bvme6000_scc_init(void)
        port->datap = port->ctrlp + 4;
        port->port_a = &scc_ports[0];
        port->port_b = &scc_ports[1];
-       request_irq(BVME_IRQ_SCCA_TX, scc_tx_int, SA_INTERRUPT,
+       request_irq(BVME_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
                            "SCC-A TX", port);
-       request_irq(BVME_IRQ_SCCA_STAT, scc_stat_int, SA_INTERRUPT,
+       request_irq(BVME_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
                            "SCC-A status", port);
-       request_irq(BVME_IRQ_SCCA_RX, scc_rx_int, SA_INTERRUPT,
+       request_irq(BVME_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
                            "SCC-A RX", port);
-       request_irq(BVME_IRQ_SCCA_SPCOND, scc_spcond_int, SA_INTERRUPT,
+       request_irq(BVME_IRQ_SCCA_SPCOND, scc_spcond_int, IRQF_DISABLED,
                            "SCC-A special cond", port);
        {
                SCC_ACCESS_INIT(port);
@@ -370,13 +370,13 @@ static int bvme6000_scc_init(void)
        port->datap = port->ctrlp + 4;
        port->port_a = &scc_ports[0];
        port->port_b = &scc_ports[1];
-       request_irq(BVME_IRQ_SCCB_TX, scc_tx_int, SA_INTERRUPT,
+       request_irq(BVME_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
                            "SCC-B TX", port);
-       request_irq(BVME_IRQ_SCCB_STAT, scc_stat_int, SA_INTERRUPT,
+       request_irq(BVME_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
                            "SCC-B status", port);
-       request_irq(BVME_IRQ_SCCB_RX, scc_rx_int, SA_INTERRUPT,
+       request_irq(BVME_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
                            "SCC-B RX", port);
-       request_irq(BVME_IRQ_SCCB_SPCOND, scc_spcond_int, SA_INTERRUPT,
+       request_irq(BVME_IRQ_SCCB_SPCOND, scc_spcond_int, IRQF_DISABLED,
                            "SCC-B special cond", port);
 
        {
@@ -421,7 +421,7 @@ module_init(vme_scc_init);
  * Interrupt handlers
  *--------------------------------------------------------------------------*/
 
-static irqreturn_t scc_rx_int(int irq, void *data, struct pt_regs *fp)
+static irqreturn_t scc_rx_int(int irq, void *data)
 {
        unsigned char   ch;
        struct scc_port *port = data;
@@ -434,13 +434,7 @@ static irqreturn_t scc_rx_int(int irq, void *data, struct pt_regs *fp)
                SCCwrite_NB(COMMAND_REG, CR_HIGHEST_IUS_RESET);
                return IRQ_HANDLED;
        }
-       if (tty->flip.count < TTY_FLIPBUF_SIZE) {
-               *tty->flip.char_buf_ptr = ch;
-               *tty->flip.flag_buf_ptr = 0;
-               tty->flip.flag_buf_ptr++;
-               tty->flip.char_buf_ptr++;
-               tty->flip.count++;
-       }
+       tty_insert_flip_char(tty, ch, 0);
 
        /* Check if another character is already ready; in that case, the
         * spcond_int() function must be used, because this character may have an
@@ -448,7 +442,7 @@ static irqreturn_t scc_rx_int(int irq, void *data, struct pt_regs *fp)
         */
        if (SCCread(INT_PENDING_REG) &
            (port->channel == CHANNEL_A ? IPR_A_RX : IPR_B_RX)) {
-               scc_spcond_int (irq, data, fp);
+               scc_spcond_int (irq, data);
                return IRQ_HANDLED;
        }
 
@@ -459,7 +453,7 @@ static irqreturn_t scc_rx_int(int irq, void *data, struct pt_regs *fp)
 }
 
 
-static irqreturn_t scc_spcond_int(int irq, void *data, struct pt_regs *fp)
+static irqreturn_t scc_spcond_int(int irq, void *data)
 {
        struct scc_port *port = data;
        struct tty_struct *tty = port->gs.tty;
@@ -487,13 +481,7 @@ static irqreturn_t scc_spcond_int(int irq, void *data, struct pt_regs *fp)
                else
                        err = 0;
 
-               if (tty->flip.count < TTY_FLIPBUF_SIZE) {
-                       *tty->flip.char_buf_ptr = ch;
-                       *tty->flip.flag_buf_ptr = err;
-                       tty->flip.flag_buf_ptr++;
-                       tty->flip.char_buf_ptr++;
-                       tty->flip.count++;
-               }
+               tty_insert_flip_char(tty, ch, err);
 
                /* ++TeSche: *All* errors have to be cleared manually,
                 * else the condition persists for the next chars
@@ -510,7 +498,7 @@ static irqreturn_t scc_spcond_int(int irq, void *data, struct pt_regs *fp)
 }
 
 
-static irqreturn_t scc_tx_int(int irq, void *data, struct pt_regs *fp)
+static irqreturn_t scc_tx_int(int irq, void *data)
 {
        struct scc_port *port = data;
        SCC_ACCESS_INIT(port);
@@ -544,19 +532,15 @@ static irqreturn_t scc_tx_int(int irq, void *data, struct pt_regs *fp)
                SCCwrite(COMMAND_REG, CR_TX_PENDING_RESET);   /* disable tx_int on next tx underrun? */
                port->gs.flags &= ~GS_TX_INTEN;
        }
-       if (port->gs.tty && port->gs.xmit_cnt <= port->gs.wakeup_chars) {
-               if ((port->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-                               port->gs.tty->ldisc.write_wakeup)
-                       (port->gs.tty->ldisc.write_wakeup)(port->gs.tty);
-               wake_up_interruptible(&port->gs.tty->write_wait);
-       }
+       if (port->gs.tty && port->gs.xmit_cnt <= port->gs.wakeup_chars)
+               tty_wakeup(port->gs.tty);
 
        SCCwrite_NB(COMMAND_REG, CR_HIGHEST_IUS_RESET);
        return IRQ_HANDLED;
 }
 
 
-static irqreturn_t scc_stat_int(int irq, void *data, struct pt_regs *fp)
+static irqreturn_t scc_stat_int(int irq, void *data)
 {
        struct scc_port *port = data;
        unsigned channel = port->channel;
@@ -611,7 +595,7 @@ static void scc_enable_tx_interrupts(void *ptr)
        local_irq_save(flags);
        SCCmod(INT_AND_DMA_REG, 0xff, IDR_TX_INT_ENAB);
        /* restart the transmitter */
-       scc_tx_int (0, port, 0);
+       scc_tx_int (0, port);
        local_irq_restore(flags);
 }
 
@@ -879,13 +863,13 @@ static int scc_open (struct tty_struct * tty, struct file * filp)
                local_irq_save(flags);
 #if defined(CONFIG_MVME147_SCC) || defined(CONFIG_MVME162_SCC)
                if (MACH_IS_MVME147 || MACH_IS_MVME16x) {
-                       for (i=0; i<sizeof(mvme_init_tab)/sizeof(*mvme_init_tab); ++i)
+                       for (i = 0; i < ARRAY_SIZE(mvme_init_tab); ++i)
                                SCCwrite(mvme_init_tab[i].reg, mvme_init_tab[i].val);
                }
 #endif
 #if defined(CONFIG_BVME6000_SCC)
                if (MACH_IS_BVME6000) {
-                       for (i=0; i<sizeof(bvme_init_tab)/sizeof(*bvme_init_tab); ++i)
+                       for (i = 0; i < ARRAY_SIZE(bvme_init_tab); ++i)
                                SCCwrite(bvme_init_tab[i].reg, bvme_init_tab[i].val);
                }
 #endif