Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / usb / serial / digi_acceleport.c
index 4b59d75..b3f776a 100644 (file)
 #include <linux/workqueue.h>
 #include <asm/uaccess.h>
 #include <linux/usb.h>
+#include <linux/wait.h>
 #include "usb-serial.h"
 
 /* Defines */
@@ -492,20 +493,22 @@ static struct usb_device_id id_table_4 [] = {
 MODULE_DEVICE_TABLE (usb, id_table_combined);
 
 static struct usb_driver digi_driver = {
-       .owner =        THIS_MODULE,
        .name =         "digi_acceleport",
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
+       .no_dynamic_id =        1,
 };
 
 
 /* device info needed for the Digi serial converter */
 
-static struct usb_serial_device_type digi_acceleport_2_device = {
-       .owner =                        THIS_MODULE,
-       .name =                         "Digi 2 port USB adapter",
-       .short_name =                   "digi_2",
+static struct usb_serial_driver digi_acceleport_2_device = {
+       .driver = {
+               .owner =                THIS_MODULE,
+               .name =                 "digi_2",
+       },
+       .description =                  "Digi 2 port USB adapter",
        .id_table =                     id_table_2,
        .num_interrupt_in =             0,
        .num_bulk_in =                  4,
@@ -529,10 +532,12 @@ static struct usb_serial_device_type digi_acceleport_2_device = {
        .shutdown =                     digi_shutdown,
 };
 
-static struct usb_serial_device_type digi_acceleport_4_device = {
-       .owner =                        THIS_MODULE,
-       .name =                         "Digi 4 port USB adapter",
-       .short_name =                   "digi_4",
+static struct usb_serial_driver digi_acceleport_4_device = {
+       .driver = {
+               .owner =                THIS_MODULE,
+               .name =                 "digi_4",
+       },
+       .description =                  "Digi 4 port USB adapter",
        .id_table =                     id_table_4,
        .num_interrupt_in =             0,
        .num_bulk_in =                  5,
@@ -567,30 +572,23 @@ static struct usb_serial_device_type digi_acceleport_4_device = {
 *  and the sleep.  In other words, spin_unlock_irqrestore and
 *  interruptible_sleep_on_timeout are "atomic" with respect to
 *  wake ups.  This is used to implement condition variables.
+*
+*  interruptible_sleep_on_timeout is deprecated and has been replaced
+*  with the equivalent code.
 */
 
 static inline long cond_wait_interruptible_timeout_irqrestore(
        wait_queue_head_t *q, long timeout,
        spinlock_t *lock, unsigned long flags )
 {
+       DEFINE_WAIT(wait);
 
-       wait_queue_t wait;
-
-
-       init_waitqueue_entry( &wait, current );
-
-       set_current_state( TASK_INTERRUPTIBLE );
-
-       add_wait_queue( q, &wait );
-
-       spin_unlock_irqrestore( lock, flags );
-
+       prepare_to_wait(q, &wait, TASK_INTERRUPTIBLE);
+       spin_unlock_irqrestore(lock, flags);
        timeout = schedule_timeout(timeout);
+       finish_wait(q, &wait);
 
-       remove_wait_queue( q, &wait );
-
-       return( timeout );
-
+       return timeout;
 }
 
 
@@ -948,13 +946,10 @@ dbg( "digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num );
        spin_lock_irqsave( &priv->dp_port_lock, flags );
 
        /* send any buffered chars from throttle time on to tty subsystem */
-       len = min(priv->dp_in_buf_len, TTY_FLIPBUF_SIZE - tty->flip.count );
+
+       len = tty_buffer_request_room(tty, priv->dp_in_buf_len);
        if( len > 0 ) {
-               memcpy( tty->flip.char_buf_ptr, priv->dp_in_buf, len );
-               memcpy( tty->flip.flag_buf_ptr, priv->dp_in_flag_buf, len );
-               tty->flip.char_buf_ptr += len;
-               tty->flip.flag_buf_ptr += len;
-               tty->flip.count += len;
+               tty_insert_flip_string_flags(tty, priv->dp_in_buf, priv->dp_in_flag_buf, len);
                tty_flip_buffer_push( tty );
        }
 
@@ -1528,7 +1523,7 @@ dbg( "digi_open: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_cou
 
 static void digi_close( struct usb_serial_port *port, struct file *filp )
 {
-
+       DEFINE_WAIT(wait);
        int ret;
        unsigned char buf[32];
        struct tty_struct *tty = port->tty;
@@ -1604,8 +1599,9 @@ dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_co
                        dbg( "digi_close: write oob failed, ret=%d", ret );
 
                /* wait for final commands on oob port to complete */
-               interruptible_sleep_on_timeout( &priv->dp_flush_wait,
-                       DIGI_CLOSE_TIMEOUT );
+               prepare_to_wait(&priv->dp_flush_wait, &wait, TASK_INTERRUPTIBLE);
+               schedule_timeout(DIGI_CLOSE_TIMEOUT);
+               finish_wait(&priv->dp_flush_wait, &wait);
 
                /* shutdown any outstanding bulk writes */
                usb_kill_urb(port->write_urb);
@@ -1828,6 +1824,7 @@ static int digi_read_inb_callback( struct urb *urb )
        int status = ((unsigned char *)urb->transfer_buffer)[2];
        unsigned char *data = ((unsigned char *)urb->transfer_buffer)+3;
        int flag,throttled;
+       int i;
 
        /* do not process callbacks on closed ports */
        /* but do continue the read chain */
@@ -1886,20 +1883,18 @@ static int digi_read_inb_callback( struct urb *urb )
                        }
 
                } else {
-
-                       len = min( len, TTY_FLIPBUF_SIZE - tty->flip.count );
-
+                       len = tty_buffer_request_room(tty, len);
                        if( len > 0 ) {
-                               memcpy( tty->flip.char_buf_ptr, data, len );
-                               memset( tty->flip.flag_buf_ptr, flag, len );
-                               tty->flip.char_buf_ptr += len;
-                               tty->flip.flag_buf_ptr += len;
-                               tty->flip.count += len;
+                               /* Hot path */
+                               if(flag == TTY_NORMAL)
+                                       tty_insert_flip_string(tty, data, len);
+                               else {
+                                       for(i = 0; i < len; i++)
+                                               tty_insert_flip_char(tty, data[i], flag);
+                               }
                                tty_flip_buffer_push( tty );
                        }
-
                }
-
        }
 
        spin_unlock( &priv->dp_port_lock );