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 / ipw.c
index 11105d7..e760a70 100644 (file)
@@ -46,7 +46,6 @@
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/usb.h>
-#include <linux/usb.h>
 #include <asm/uaccess.h>
 #include "usb-serial.h"
 
@@ -153,11 +152,11 @@ static struct usb_device_id usb_ipw_ids[] = {
 MODULE_DEVICE_TABLE(usb, usb_ipw_ids);
 
 static struct usb_driver usb_ipw_driver = {
-       .owner =        THIS_MODULE,
        .name =         "ipwtty",
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     usb_ipw_ids,
+       .no_dynamic_id =        1,
 };
 
 static int debug;
@@ -167,7 +166,6 @@ static void ipw_read_bulk_callback(struct urb *urb, struct pt_regs *regs)
        struct usb_serial_port *port = urb->context;
        unsigned char *data = urb->transfer_buffer;
        struct tty_struct *tty;
-       int i;
        int result;
 
        dbg("%s - port %d", __FUNCTION__, port->number);
@@ -181,14 +179,8 @@ static void ipw_read_bulk_callback(struct urb *urb, struct pt_regs *regs)
 
        tty = port->tty;
        if (tty && urb->actual_length) {
-               for (i = 0; i < urb->actual_length ; ++i) {
-                       /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */
-                       if(tty->flip.count >= TTY_FLIPBUF_SIZE) {
-                               tty_flip_buffer_push(tty);
-                       }
-                       /* this doesn't actually push the data through unless tty->low_latency is set */
-                       tty_insert_flip_char(tty, data[i], 0);
-               }
+               tty_buffer_request_room(tty, urb->actual_length);
+               tty_insert_flip_string(tty, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
 
@@ -399,16 +391,21 @@ static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int
                dbg("%s - write request of 0 bytes", __FUNCTION__);
                return 0;
        }
-       
-       /* Racy and broken, FIXME properly! */
-       if (port->write_urb->status == -EINPROGRESS)
+
+       spin_lock(&port->lock);
+       if (port->write_urb_busy) {
+               spin_unlock(&port->lock);
+               dbg("%s - already writing", __FUNCTION__);
                return 0;
+       }
+       port->write_urb_busy = 1;
+       spin_unlock(&port->lock);
 
        count = min(count, port->bulk_out_size);
        memcpy(port->bulk_out_buffer, buf, count);
 
        dbg("%s count now:%d", __FUNCTION__, count);
-       
+
        usb_fill_bulk_urb(port->write_urb, dev,
                          usb_sndbulkpipe(dev, port->bulk_out_endpointAddress),
                          port->write_urb->transfer_buffer,
@@ -418,6 +415,7 @@ static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int
 
        ret = usb_submit_urb(port->write_urb, GFP_ATOMIC);
        if (ret != 0) {
+               port->write_urb_busy = 0;
                dbg("%s - usb_submit_urb(write bulk) failed with error = %d", __FUNCTION__, ret);
                return ret;
        }
@@ -437,10 +435,12 @@ static int ipw_disconnect(struct usb_serial_port *port)
        return 0;
 }
 
-static struct usb_serial_device_type ipw_device = {
-       .owner =                THIS_MODULE,
-       .name =                 "IPWireless converter",
-       .short_name =           "ipw",
+static struct usb_serial_driver ipw_device = {
+       .driver = {
+               .owner =        THIS_MODULE,
+               .name =         "ipw",
+       },
+       .description =          "IPWireless converter",
        .id_table =             usb_ipw_ids,
        .num_interrupt_in =     NUM_DONT_CARE,
        .num_bulk_in =          1,