[PATCH] fix idiocy in asd_init_lseq_mdp()
[safe/jmp/linux-2.6] / drivers / char / rocket.c
index 5b1d368..0ac1318 100644 (file)
@@ -256,7 +256,6 @@ static int sInitController(CONTROLLER_T * CtlP, int CtlNum, ByteIO_t MudbacIO,
 static int sReadAiopID(ByteIO_t io);
 static int sReadAiopNumChan(WordIO_t io);
 
-#ifdef MODULE
 MODULE_AUTHOR("Theodore Ts'o");
 MODULE_DESCRIPTION("Comtrol RocketPort driver");
 module_param(board1, ulong, 0);
@@ -288,17 +287,14 @@ MODULE_PARM_DESC(pc104_3, "set interface types for ISA(PC104) board #3 (e.g. pc1
 module_param_array(pc104_4, ulong, NULL, 0);
 MODULE_PARM_DESC(pc104_4, "set interface types for ISA(PC104) board #4 (e.g. pc104_4=232,232,485,485,...");
 
-int rp_init(void);
+static int rp_init(void);
 static void rp_cleanup_module(void);
 
 module_init(rp_init);
 module_exit(rp_cleanup_module);
 
-#endif
 
-#ifdef MODULE_LICENSE
 MODULE_LICENSE("Dual BSD/GPL");
-#endif
 
 /*************************************************************************/
 /*                     Module code starts here                           */
@@ -328,34 +324,15 @@ static void rp_do_receive(struct r_port *info,
                          CHANNEL_t * cp, unsigned int ChanStatus)
 {
        unsigned int CharNStat;
-       int ToRecv, wRecv, space = 0, count;
+       int ToRecv, wRecv, space;
        unsigned char *cbuf;
-       char *fbuf;
-       struct tty_ldisc *ld;
-
-       ld = tty_ldisc_ref(tty);
 
        ToRecv = sGetRxCnt(cp);
-       if (ld)
-               space = ld->receive_room(tty);
-       if (space > 2 * TTY_FLIPBUF_SIZE)
-               space = 2 * TTY_FLIPBUF_SIZE;
-       cbuf = tty->flip.char_buf;
-       fbuf = tty->flip.flag_buf;
-       count = 0;
 #ifdef ROCKET_DEBUG_INTR
-       printk(KERN_INFO "rp_do_receive(%d, %d)...", ToRecv, space);
+       printk(KERN_INFO "rp_do_receive(%d)...", ToRecv);
 #endif
-
-       /*
-        * determine how many we can actually read in.  If we can't
-        * read any in then we have a software overrun condition.
-        */
-       if (ToRecv > space)
-               ToRecv = space;
-
-       if (ToRecv <= 0)
-               goto done;
+       if (ToRecv == 0)
+               return;
 
        /*
         * if status indicates there are errored characters in the
@@ -383,6 +360,8 @@ static void rp_do_receive(struct r_port *info,
                       info->read_status_mask);
 #endif
                while (ToRecv) {
+                       char flag;
+
                        CharNStat = sInW(sGetTxRxDataIO(cp));
 #ifdef ROCKET_DEBUG_RECEIVE
                        printk(KERN_INFO "%x...", CharNStat);
@@ -395,17 +374,16 @@ static void rp_do_receive(struct r_port *info,
                        }
                        CharNStat &= info->read_status_mask;
                        if (CharNStat & STMBREAKH)
-                               *fbuf++ = TTY_BREAK;
+                               flag = TTY_BREAK;
                        else if (CharNStat & STMPARITYH)
-                               *fbuf++ = TTY_PARITY;
+                               flag = TTY_PARITY;
                        else if (CharNStat & STMFRAMEH)
-                               *fbuf++ = TTY_FRAME;
+                               flag = TTY_FRAME;
                        else if (CharNStat & STMRCVROVRH)
-                               *fbuf++ = TTY_OVERRUN;
+                               flag = TTY_OVERRUN;
                        else
-                               *fbuf++ = 0;
-                       *cbuf++ = CharNStat & 0xff;
-                       count++;
+                               flag = TTY_NORMAL;
+                       tty_insert_flip_char(tty, CharNStat & 0xff, flag);
                        ToRecv--;
                }
 
@@ -425,20 +403,23 @@ static void rp_do_receive(struct r_port *info,
                 * characters at time by doing repeated word IO
                 * transfer.
                 */
+               space = tty_prepare_flip_string(tty, &cbuf, ToRecv);
+               if (space < ToRecv) {
+#ifdef ROCKET_DEBUG_RECEIVE
+                       printk(KERN_INFO "rp_do_receive:insufficient space ToRecv=%d space=%d\n", ToRecv, space);
+#endif
+                       if (space <= 0)
+                               return;
+                       ToRecv = space;
+               }
                wRecv = ToRecv >> 1;
                if (wRecv)
                        sInStrW(sGetTxRxDataIO(cp), (unsigned short *) cbuf, wRecv);
                if (ToRecv & 1)
                        cbuf[ToRecv - 1] = sInB(sGetTxRxDataIO(cp));
-               memset(fbuf, 0, ToRecv);
-               cbuf += ToRecv;
-               fbuf += ToRecv;
-               count += ToRecv;
        }
        /*  Push the data up to the tty layer */
-       ld->receive_buf(tty, tty->flip.char_buf, tty->flip.flag_buf, count);
-done:
-       tty_ldisc_deref(ld);
+       tty_flip_buffer_push(tty);
 }
 
 /*
@@ -2378,7 +2359,7 @@ static struct tty_operations rocket_ops = {
 /*
  * The module "startup" routine; it's run when the module is loaded.
  */
-int __init rp_init(void)
+static int __init rp_init(void)
 {
        int retval, pci_boards_found, isa_boards_found, i;
 
@@ -2445,8 +2426,7 @@ int __init rp_init(void)
         */
 
        rocket_driver->owner = THIS_MODULE;
-       rocket_driver->flags = TTY_DRIVER_NO_DEVFS;
-       rocket_driver->devfs_name = "tts/R";
+       rocket_driver->flags = TTY_DRIVER_DYNAMIC_DEV;
        rocket_driver->name = "ttyR";
        rocket_driver->driver_name = "Comtrol RocketPort";
        rocket_driver->major = TTY_ROCKET_MAJOR;
@@ -2457,7 +2437,7 @@ int __init rp_init(void)
        rocket_driver->init_termios.c_cflag =
            B9600 | CS8 | CREAD | HUPCL | CLOCAL;
 #ifdef ROCKET_SOFT_FLOW
-       rocket_driver->flags |= TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
+       rocket_driver->flags |= TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
 #endif
        tty_set_operations(rocket_driver, &rocket_ops);
 
@@ -2502,7 +2482,6 @@ int __init rp_init(void)
        return 0;
 }
 
-#ifdef MODULE
 
 static void rp_cleanup_module(void)
 {
@@ -2517,10 +2496,8 @@ static void rp_cleanup_module(void)
                       "rocketport driver\n", -retval);
        put_tty_driver(rocket_driver);
 
-       for (i = 0; i < MAX_RP_PORTS; i++) {
-               if (rp_table[i])
-                       kfree(rp_table[i]);
-       }
+       for (i = 0; i < MAX_RP_PORTS; i++)
+               kfree(rp_table[i]);
 
        for (i = 0; i < NUM_BOARDS; i++) {
                if (rcktpt_io_addr[i] <= 0 || is_PCI[i])
@@ -2530,7 +2507,6 @@ static void rp_cleanup_module(void)
        if (controller)
                release_region(controller, 4);
 }
-#endif
 
 /***************************************************************************
 Function: sInitController