[PATCH] cciss: fix for deregister_disk
[powerpc.git] / drivers / usb / serial / omninet.c
index b5f2c06..3caf970 100644 (file)
@@ -88,10 +88,12 @@ static struct usb_driver omninet_driver = {
 };
 
 
-static struct usb_serial_device_type zyxel_omninet_device = {
-       .owner =                THIS_MODULE,
-       .name =                 "ZyXEL - omni.net lcd plus usb",
-       .short_name =           "omninet",
+static struct usb_serial_driver zyxel_omninet_device = {
+       .driver = {
+               .owner =        THIS_MODULE,
+               .name =         "omninet",
+       },
+       .description =          "ZyXEL - omni.net lcd plus usb",
        .id_table =             id_table,
        .num_interrupt_in =     1,
        .num_bulk_in =          1,
@@ -254,10 +256,15 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
                dbg("%s - write request of 0 bytes", __FUNCTION__);
                return (0);
        }
-       if (wport->write_urb->status == -EINPROGRESS) {
+
+       spin_lock(&port->lock);
+       if (port->write_urb_busy) {
+               spin_unlock(&port->lock);
                dbg("%s - already writing", __FUNCTION__);
-               return (0);
+               return 0;
        }
+       port->write_urb_busy = 1;
+       spin_unlock(&port->lock);
 
        count = (count > OMNINET_BULKOUTSIZE) ? OMNINET_BULKOUTSIZE : count;
 
@@ -275,9 +282,10 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
 
        wport->write_urb->dev = serial->dev;
        result = usb_submit_urb(wport->write_urb, GFP_ATOMIC);
-       if (result)
+       if (result) {
+               port->write_urb_busy = 0;
                err("%s - failed submitting write urb, error %d", __FUNCTION__, result);
-       else
+       else
                result = count;
 
        return result;
@@ -291,7 +299,7 @@ static int omninet_write_room (struct usb_serial_port *port)
 
        int room = 0; // Default: no room
 
-       if (wport->write_urb->status != -EINPROGRESS)
+       if (wport->write_urb_busy)
                room = wport->bulk_out_size - OMNINET_HEADERLEN;
 
 //     dbg("omninet_write_room returns %d", room);
@@ -306,6 +314,7 @@ static void omninet_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
 
 //     dbg("omninet_write_bulk_callback, port %0x\n", port);
 
+       port->write_urb_busy = 0;
        if (urb->status) {
                dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
                return;