tty: Ldisc revamp
[linux-2.6-block.git] / drivers / net / wan / pc300_tty.c
index 07dbdfbfc15d1e1fa02305d98bc3e4ed07133f73..c2c10c6322602dbfa462d5e54eb75c75eede5ccd 100644 (file)
@@ -38,7 +38,6 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/pci.h>
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/init.h>
@@ -179,6 +178,20 @@ static void cpc_tty_signal_on(pc300dev_t *pc300dev, unsigned char signal)
        CPC_TTY_UNLOCK(card,flags); 
 }
 
+
+static const struct tty_operations pc300_ops = {
+       .open = cpc_tty_open,
+       .close = cpc_tty_close,
+       .write = cpc_tty_write,
+       .write_room = cpc_tty_write_room,
+       .chars_in_buffer = cpc_tty_chars_in_buffer,
+       .tiocmset = pc300_tiocmset,
+       .tiocmget = pc300_tiocmget,
+       .flush_buffer = cpc_tty_flush_buffer,
+       .hangup = cpc_tty_hangup,
+};
+
+
 /*
  * PC300 TTY initialization routine
  *
@@ -226,15 +239,7 @@ void cpc_tty_init(pc300dev_t *pc300dev)
                serial_drv.flags = TTY_DRIVER_REAL_RAW;
 
                /* interface routines from the upper tty layer to the tty driver */
-               serial_drv.open = cpc_tty_open;
-               serial_drv.close = cpc_tty_close;
-               serial_drv.write = cpc_tty_write; 
-               serial_drv.write_room = cpc_tty_write_room; 
-               serial_drv.chars_in_buffer = cpc_tty_chars_in_buffer; 
-               serial_drv.tiocmset = pc300_tiocmset;
-               serial_drv.tiocmget = pc300_tiocmget;
-               serial_drv.flush_buffer = cpc_tty_flush_buffer; 
-               serial_drv.hangup = cpc_tty_hangup;
+               tty_set_operations(&serial_drv, &pc300_ops);
 
                /* register the TTY driver */
                if (tty_register_driver(&serial_drv)) { 
@@ -314,7 +319,7 @@ static int cpc_tty_open(struct tty_struct *tty, struct file *flip)
        if (cpc_tty->num_open == 0) { /* first open of this tty */
                if (!cpc_tty_area[port].buf_tx){
                        cpc_tty_area[port].buf_tx = kmalloc(CPC_TTY_MAX_MTU,GFP_KERNEL);
-                       if (cpc_tty_area[port].buf_tx == 0){
+                       if (!cpc_tty_area[port].buf_tx) {
                                CPC_TTY_DBG("%s: error in memory allocation\n",cpc_tty->name);
                                return -ENOMEM;
                        }
@@ -679,13 +684,13 @@ static void cpc_tty_rx_work(struct work_struct *work)
                for (j=0; j < CPC_TTY_NPORTS; j++) {
                        cpc_tty = &cpc_tty_area[port];
                
-                       if ((buf=cpc_tty->buf_rx.first) != 0) {
+                       if ((buf=cpc_tty->buf_rx.first) != NULL) {
                                if (cpc_tty->tty) {
                                        ld = tty_ldisc_ref(cpc_tty->tty);
                                        if (ld) {
-                                               if (ld->receive_buf) {
+                                               if (ld->ops->receive_buf) {
                                                        CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name);
-                                                       ld->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size);
+                                                       ld->ops->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size);
                                                }
                                                tty_ldisc_deref(ld);
                                        }
@@ -785,7 +790,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
                } 
                
                new = kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC);
-               if (new == 0) {
+               if (!new) {
                        cpc_tty_rx_disc_frame(pc300chan);
                        continue;
                }
@@ -864,7 +869,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
                        } 
                        new->size = rx_len;
                        new->next = NULL;
-                       if (cpc_tty->buf_rx.first == 0) {
+                       if (cpc_tty->buf_rx.first == NULL) {
                                cpc_tty->buf_rx.first = new;
                                cpc_tty->buf_rx.last = new;
                        } else {
@@ -892,7 +897,7 @@ static void cpc_tty_tx_work(struct work_struct *work)
 
        CPC_TTY_DBG("%s: cpc_tty_tx_work init\n",cpc_tty->name);
        
-       if ((tty = cpc_tty->tty) == 0) { 
+       if ((tty = cpc_tty->tty) == NULL) { 
                CPC_TTY_DBG("%s: the interface is not opened\n",cpc_tty->name);
                return; 
        }
@@ -1028,7 +1033,7 @@ void cpc_tty_unregister_service(pc300dev_t *pc300dev)
        ulong flags;
        int res;
 
-       if ((cpc_tty= (st_cpc_tty_area *) pc300dev->cpc_tty) == 0) { 
+       if ((cpc_tty= (st_cpc_tty_area *) pc300dev->cpc_tty) == NULL) {
                CPC_TTY_DBG("%s: interface is not TTY\n", pc300dev->dev->name);
                return; 
        }