[PATCH] USB serial: encapsulate schedule_work, remove double-calling
authorPete Zaitcev <zaitcev@redhat.com>
Tue, 23 May 2006 04:58:49 +0000 (21:58 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 21 Jun 2006 22:04:13 +0000 (15:04 -0700)
I'm going to throw schedule_work away, it's retarded. But for starters,
let's have it encapsulated.

Also, generic and whiteheat were both calling usb_serial_port_softint
and scheduled work. Only one was necessary.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
18 files changed:
drivers/usb/serial/cyberjack.c
drivers/usb/serial/cypress_m8.c
drivers/usb/serial/empeg.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/garmin_gps.c
drivers/usb/serial/generic.c
drivers/usb/serial/ipaq.c
drivers/usb/serial/ipw.c
drivers/usb/serial/ir-usb.c
drivers/usb/serial/keyspan.c
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/omninet.c
drivers/usb/serial/option.c
drivers/usb/serial/pl2303.c
drivers/usb/serial/usb-serial.c
drivers/usb/serial/usb-serial.h
drivers/usb/serial/visor.c
drivers/usb/serial/whiteheat.c

index 2357b1d102d7e5fef562be87c47ca703d35d678c..1fd5c5a9f2efd45a38c9609f99642745dccf419c 100644 (file)
@@ -469,7 +469,7 @@ static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs
 
 exit:
        spin_unlock(&priv->lock);
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }
 
 static int __init cyberjack_init (void)
index 7212fbe3b6f28506b037475ed9be5bcae38f7d29..5de76efe1b37f986fb3f6623717dc6cccb8d4c67 100644 (file)
@@ -824,7 +824,7 @@ send:
        priv->bytes_out += count; /* do not count the line control and size bytes */
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 } /* cypress_send */
 
 
index 63f7c78a1152d05924711628be6c2e93b70ef555..afca1eae5fb52499dc20b9dcd1d4b9da48fc6592 100644 (file)
@@ -335,7 +335,7 @@ static void empeg_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
                return;
        }
 
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }
 
 
index 1122a0da41c1599cf83f82e808775b7ed402789b..590c7ec851db8a9b4f0368419143326b46019ec5 100644 (file)
@@ -1472,7 +1472,7 @@ static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
                return;
        }
 
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 } /* ftdi_write_bulk_callback */
 
 
index 5ec9bf5bac8dc635608dd195db4bc51277174b83..04767759cf8a8e5190a93b232d4fca7c76ba727c 100644 (file)
@@ -1012,7 +1012,7 @@ static void garmin_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
                garmin_data_p->flags |= CLEAR_HALT_REQUIRED;
        }
 
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }
 
 
index c62cc2876519629a6bd39e8b6284b84a51d201ab..07a478c59fb2bd43b3a31df788430dc5b696ff6c 100644 (file)
@@ -299,9 +299,7 @@ void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *re
                return;
        }
 
-       usb_serial_port_softint((void *)port);
-
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }
 EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback);
 
index 9a5c979895629c727fdef8d377261b30efa21944..9da6d2a8f2b0c692a03186a6a2110ef40419b0e4 100644 (file)
@@ -870,7 +870,7 @@ static void ipaq_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
                spin_unlock_irqrestore(&write_list_lock, flags);
        }
 
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }
 
 static int ipaq_write_room(struct usb_serial_port *port)
index e760a70242c1ccace3664f1b2e46d72e67bb6386..a4a0bfeaab00ba88a4f31d35da5dd4d5cb566c56 100644 (file)
@@ -376,7 +376,7 @@ static void ipw_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
        if (urb->status)
                dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
 
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }
 
 static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int count)
index 426182ddc42a871d758ae8fc400f460138fd38f5..9432c73022758435fd9dbfaf1c374aee31079bbf 100644 (file)
@@ -408,7 +408,7 @@ static void ir_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
                urb->actual_length,
                urb->transfer_buffer);
 
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }
 
 static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
index 052b735c4fbddd20daae7b80a6ad65768894ad31..2cf6ade704e41b77a267eba82c4250100a54786e 100644 (file)
@@ -481,7 +481,7 @@ static void usa2x_outdat_callback(struct urb *urb, struct pt_regs *regs)
        dbg ("%s - urb %d", __FUNCTION__, urb == p_priv->out_urbs[1]); 
 
        if (port->open_count)
-               schedule_work(&port->work);
+               usb_serial_port_softint(port);
 }
 
 static void    usa26_inack_callback(struct urb *urb, struct pt_regs *regs)
index 78335a5f77430e18a1d97e7b22e177f79ee07147..65d79f630fa4b8012435d5c6e6700810f33dd011 100644 (file)
@@ -569,8 +569,7 @@ static void klsi_105_write_bulk_callback ( struct urb *urb, struct pt_regs *regs
                return;
        }
 
-       /* from generic_write_bulk_callback */
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 } /* klsi_105_write_bulk_completion_callback */
 
 
index 238033a87092fc841c7c6ac225ff921ec381139a..6dcdb5f598b88b4ae211f9a0b1590d546be7a9ad 100644 (file)
@@ -320,7 +320,7 @@ static void omninet_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
                return;
        }
 
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }
 
 
index 5cf2b80add7aa01ede3b1a588dc5c002d6dbccb8..759d3608718446fff87648845993440af04f6d64 100644 (file)
@@ -365,8 +365,7 @@ static void option_outdat_callback(struct urb *urb, struct pt_regs *regs)
 
        port = (struct usb_serial_port *) urb->context;
 
-       if (port->open_count)
-               schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }
 
 static void option_instat_callback(struct urb *urb, struct pt_regs *regs)
index c96714bb1cb829be62f012527da26d74cb0b9c65..2ca6dd94796f1f2180bdae27cc4e33a33ac6f036 100644 (file)
@@ -314,7 +314,7 @@ static void pl2303_send(struct usb_serial_port *port)
                // TODO: reschedule pl2303_send
        }
 
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }
 
 static int pl2303_write_room(struct usb_serial_port *port)
index 92200f05b5310d914f2860f162b8d3146c7d98e8..7a1cc1b04979c3ebbb38bdeab1d6fd4c3e696cbf 100644 (file)
@@ -531,7 +531,17 @@ exit:
        return -EINVAL;
 }
 
-void usb_serial_port_softint(void *private)
+/*
+ * We would be calling tty_wakeup here, but unfortunately some line
+ * disciplines have an annoying habit of calling tty->write from
+ * the write wakeup callback (e.g. n_hdlc.c).
+ */
+void usb_serial_port_softint(struct usb_serial_port *port)
+{
+       schedule_work(&port->work);
+}
+
+static void usb_serial_port_work(void *private)
 {
        struct usb_serial_port *port = private;
        struct tty_struct *tty;
@@ -794,7 +804,7 @@ int usb_serial_probe(struct usb_interface *interface,
                port->serial = serial;
                spin_lock_init(&port->lock);
                mutex_init(&port->mutex);
-               INIT_WORK(&port->work, usb_serial_port_softint, port);
+               INIT_WORK(&port->work, usb_serial_port_work, port);
                serial->port[i] = port;
        }
 
index c07ece3fef1dffba910245aa66ed50882d5df8be..d53ea9b11e816c1609a11c8729f67cc1ab622c62 100644 (file)
@@ -236,7 +236,7 @@ struct usb_serial_driver {
 
 extern int  usb_serial_register(struct usb_serial_driver *driver);
 extern void usb_serial_deregister(struct usb_serial_driver *driver);
-extern void usb_serial_port_softint(void *private);
+extern void usb_serial_port_softint(struct usb_serial_port *port);
 
 extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id);
 extern void usb_serial_disconnect(struct usb_interface *iface);
index f5c3841d4843f7dc1cec0d681ee62dd42dfad322..9e89b8d54f725a19276e075d69a2b814db69d386 100644 (file)
@@ -480,7 +480,7 @@ static void visor_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
        --priv->outstanding_urbs;
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }
 
 
index f806553cd9a4c8929a65b0d3826de27441da5977..582860ac87646a218205614d851cc1b684133b37 100644 (file)
@@ -1089,9 +1089,7 @@ static void whiteheat_write_callback(struct urb *urb, struct pt_regs *regs)
                return;
        }
 
-       usb_serial_port_softint((void *)port);
-
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }