fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / char / ser_a2232.c
index 58f82da..75de5f6 100644 (file)
 #include <asm/amigahw.h>
 #include <linux/zorro.h>
 #include <asm/irq.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
 
 #include <linux/delay.h>
 
 #include <linux/serial.h>
 #include <linux/generic_serial.h>
+#include <linux/tty_flip.h>
 
 #include "ser_a2232.h"
 #include "ser_a2232fw.h"
 /************************* End of Includes **************************/
 
 /***************************** Prototypes ***************************/
-/* Helper functions */
-static __inline__ volatile struct a2232status *a2232stat(unsigned int board,
-                                               unsigned int portonboard);
-static __inline__ volatile struct a2232memory *a2232mem (unsigned int board); 
-static __inline__ void a2232_receive_char(     struct a2232_port *port,
-                                               int ch, int err );
 /* The interrupt service routine */
-static irqreturn_t a2232_vbl_inter(int irq, void *data, struct pt_regs *fp);
+static irqreturn_t a2232_vbl_inter(int irq, void *data);
 /* Initialize the port structures */
 static void a2232_init_portstructs(void);
 /* Initialize and register TTY drivers. */
@@ -178,6 +173,45 @@ static int nr_a2232;
 static struct zorro_dev *zd_a2232[MAX_A2232_BOARDS]; 
 /***************************** End of Global variables **************/
 
+/* Helper functions */
+
+static inline volatile struct a2232memory *a2232mem(unsigned int board)
+{
+       return (volatile struct a2232memory *)ZTWO_VADDR(zd_a2232[board]->resource.start);
+}
+
+static inline volatile struct a2232status *a2232stat(unsigned int board,
+                                                    unsigned int portonboard)
+{
+       volatile struct a2232memory *mem = a2232mem(board);
+       return &(mem->Status[portonboard]);
+}
+
+static inline void a2232_receive_char(struct a2232_port *port, int ch, int err)
+{
+/*     Mostly stolen from other drivers.
+       Maybe one could implement a more efficient version by not only
+       transferring one character at a time.
+*/
+       struct tty_struct *tty = port->gs.tty;
+
+#if 0
+       switch(err) {
+       case TTY_BREAK:
+               break;
+       case TTY_PARITY:
+               break;
+       case TTY_OVERRUN:
+               break;
+       case TTY_FRAME:
+               break;
+       }
+#endif
+
+       tty_insert_flip_char(tty, ch, err);
+       tty_flip_buffer_push(tty);
+}
+
 /***************************** Functions ****************************/
 /*** BEGIN OF REAL_DRIVER FUNCTIONS ***/
 
@@ -470,50 +504,7 @@ static int  a2232_open(struct tty_struct * tty, struct file * filp)
 }
 /*** END OF FUNCTIONS EXPECTED BY TTY DRIVER STRUCTS ***/
 
-static __inline__ volatile struct a2232status *a2232stat(unsigned int board, unsigned int portonboard)
-{
-       volatile struct a2232memory *mem = a2232mem(board);
-       return &(mem->Status[portonboard]);
-}
-
-static __inline__ volatile struct a2232memory *a2232mem (unsigned int board)
-{
-       return (volatile struct a2232memory *) ZTWO_VADDR( zd_a2232[board]->resource.start );
-}
-
-static __inline__ void a2232_receive_char(     struct a2232_port *port,
-                                               int ch, int err )
-{
-/*     Mostly stolen from other drivers.
-       Maybe one could implement a more efficient version by not only
-       transferring one character at a time.
-*/
-       struct tty_struct *tty = port->gs.tty;
-       
-       if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-               return;
-
-       tty->flip.count++;
-
-#if 0
-       switch(err) {
-       case TTY_BREAK:
-               break;
-       case TTY_PARITY:
-               break;
-       case TTY_OVERRUN:
-               break;
-       case TTY_FRAME:
-               break;
-       }
-#endif
-
-       *tty->flip.flag_buf_ptr++ = err;
-       *tty->flip.char_buf_ptr++ = ch;
-       tty_flip_buffer_push(tty);
-}
-
-static irqreturn_t a2232_vbl_inter(int irq, void *data, struct pt_regs *fp)
+static irqreturn_t a2232_vbl_inter(int irq, void *data)
 {
 #if A2232_IOBUFLEN != 256
 #error "Re-Implement a2232_vbl_inter()!"
@@ -603,10 +594,7 @@ int ch, err, n, p;
                                        
                                /* WakeUp if output buffer runs low */
                                if ((port->gs.xmit_cnt <= port->gs.wakeup_chars) && port->gs.tty) {
-                                       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);
+                                       tty_wakeup(port->gs.tty);
                                }
                        } // if the port is used
                } // for every port on the board
@@ -666,14 +654,14 @@ static void a2232_init_portstructs(void)
                port->gs.closing_wait = 30 * HZ;
                port->gs.rd = &a2232_real_driver;
 #ifdef NEW_WRITE_LOCKING
-               init_MUTEX(&(port->gs.port_write_sem));
+               init_MUTEX(&(port->gs.port_write_mutex));
 #endif
                init_waitqueue_head(&port->gs.open_wait);
                init_waitqueue_head(&port->gs.close_wait);
        }
 }
 
-static struct tty_operations a2232_ops = {
+static const struct tty_operations a2232_ops = {
        .open = a2232_open,
        .close = gs_close,
        .write = gs_write,
@@ -707,6 +695,8 @@ static int a2232_init_drivers(void)
        a2232_driver->init_termios = tty_std_termios;
        a2232_driver->init_termios.c_cflag =
                B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       a2232_driver->init_termios.c_ispeed = 9600;
+       a2232_driver->init_termios.c_ospeed = 9600;
        a2232_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(a2232_driver, &a2232_ops);
        if ((error = tty_register_driver(a2232_driver))) {
@@ -797,7 +787,7 @@ static int __init a2232board_init(void)
 
        }       
 
-       printk("Total: %d A2232 boards initialized.\n.", nr_a2232); /* Some status report if no card was found */
+       printk("Total: %d A2232 boards initialized.\n", nr_a2232); /* Some status report if no card was found */
 
        a2232_init_portstructs();