USB: serial: refactor generic close
authorJohan Hovold <jhovold@gmail.com>
Wed, 17 Mar 2010 22:00:45 +0000 (23:00 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 20 May 2010 20:21:33 +0000 (13:21 -0700)
Export usb_serial_generic_close so that drivers can easily kill the read
and write urb and make sure that the write fifo is reset.

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

index 9b66bf19f751061ce998bde586908275dda40a99..0ae610efa23daf06ba71ba1f48d73e7c6b51c122 100644 (file)
@@ -355,14 +355,11 @@ static void ark3116_close(struct usb_serial_port *port)
                /* deactivate interrupts */
                ark3116_write_reg(serial, UART_IER, 0);
 
-               /* shutdown any bulk reads that might be going on */
-               if (serial->num_bulk_out)
-                       usb_kill_urb(port->write_urb);
-               if (serial->num_bulk_in)
-                       usb_kill_urb(port->read_urb);
+               usb_serial_generic_close(port);
                if (serial->num_interrupt_in)
                        usb_kill_urb(port->interrupt_in_urb);
        }
+
 }
 
 static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
index 1295e44e3f1ce9382c5c2dc138b230ccca2d9ddd..bdab31afc37d617b2f5e5d1b5bd8faada0caef65 100644 (file)
@@ -246,9 +246,7 @@ static void belkin_sa_close(struct usb_serial_port *port)
 {
        dbg("%s port %d", __func__, port->number);
 
-       /* shutdown our bulk reads and writes */
-       usb_kill_urb(port->write_urb);
-       usb_kill_urb(port->read_urb);
+       usb_serial_generic_close(port);
        usb_kill_urb(port->interrupt_in_urb);
 } /* belkin_sa_close */
 
index 7e8e398184145f3d36e14a4632c9984378c44469..63f7cc45bcaca15b34691ce081fdd30b7b0007d8 100644 (file)
@@ -305,10 +305,7 @@ static void ch341_close(struct usb_serial_port *port)
 {
        dbg("%s - port %d", __func__, port->number);
 
-       /* shutdown our urbs */
-       dbg("%s - shutting down urbs", __func__);
-       usb_kill_urb(port->write_urb);
-       usb_kill_urb(port->read_urb);
+       usb_serial_generic_close(port);
        usb_kill_urb(port->interrupt_in_urb);
 }
 
index 705a7e7a97466a9590b88ed835d94864db3ebb80..fa4fb5e0cf124f32177cab20214b7375667e3e66 100644 (file)
@@ -422,10 +422,7 @@ static void cp210x_close(struct usb_serial_port *port)
 {
        dbg("%s - port %d", __func__, port->number);
 
-       /* shutdown our urbs */
-       dbg("%s - shutting down urbs", __func__);
-       usb_kill_urb(port->write_urb);
-       usb_kill_urb(port->read_urb);
+       usb_serial_generic_close(port);
 
        mutex_lock(&port->serial->disc_mutex);
        if (!port->serial->disconnected)
index 583244bd84b19d8a1b0aeb02c7c91e8991e37e1b..e1d245aa4a1d9cb9e925c99f931233d2a25b5b81 100644 (file)
@@ -179,6 +179,7 @@ void usb_serial_generic_close(struct usb_serial_port *port)
        dbg("%s - port %d", __func__, port->number);
        generic_cleanup(port);
 }
+EXPORT_SYMBOL_GPL(usb_serial_generic_close);
 
 static int usb_serial_multi_urb_write(struct tty_struct *tty,
        struct usb_serial_port *port, const unsigned char *buf, int count)
index 2849f8c320157e483504962b3ec16b13a0a4bd45..7aa01b95b1d45fce870ec7b1c7a419185ae5aeef 100644 (file)
@@ -549,12 +549,9 @@ static void mct_u232_close(struct usb_serial_port *port)
 {
        dbg("%s port %d", __func__, port->number);
 
-       if (port->serial->dev) {
-               /* shutdown our urbs */
-               usb_kill_urb(port->write_urb);
-               usb_kill_urb(port->read_urb);
+       usb_serial_generic_close(port);
+       if (port->serial->dev)
                usb_kill_urb(port->interrupt_in_urb);
-       }
 } /* mct_u232_close */