USB: serial: clear fifo on close
authorJohan Hovold <jhovold@gmail.com>
Wed, 17 Mar 2010 22:00:44 +0000 (23:00 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 20 May 2010 20:21:33 +0000 (13:21 -0700)
Make sure fifo is emptied on close.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/serial/generic.c

index 2a3196a2c66c4cbcc98579c7985d1b24c468ccf9..583244bd84b19d8a1b0aeb02c7c91e8991e37e1b 100644 (file)
@@ -156,13 +156,19 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_open);
 static void generic_cleanup(struct usb_serial_port *port)
 {
        struct usb_serial *serial = port->serial;
+       unsigned long flags;
 
        dbg("%s - port %d", __func__, port->number);
 
        if (serial->dev) {
                /* shutdown any bulk transfers that might be going on */
-               if (port->bulk_out_size)
+               if (port->bulk_out_size) {
                        usb_kill_urb(port->write_urb);
+
+                       spin_lock_irqsave(&port->lock, flags);
+                       kfifo_reset_out(&port->write_fifo);
+                       spin_unlock_irqrestore(&port->lock, flags);
+               }
                if (port->bulk_in_size)
                        usb_kill_urb(port->read_urb);
        }