- if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup) {
- dbg("%s - write wakeup call.", __FUNCTION__);
- (tty->ldisc.write_wakeup)(tty);
- }
-
- wake_up_interruptible(&tty->write_wait);
-}
-
-static void destroy_serial(struct kref *kref)
-{
- struct usb_serial *serial;
- struct usb_serial_port *port;
- int i;
-
- serial = to_usb_serial(kref);
-
- dbg ("%s - %s", __FUNCTION__, serial->type->name);
- serial_shutdown (serial);
-
- /* return the minor range that this device had */
- return_serial(serial);
-
- for (i = 0; i < serial->num_ports; ++i)
- serial->port[i]->open_count = 0;
-
- /* the ports are cleaned up and released in port_release() */
- for (i = 0; i < serial->num_ports; ++i)
- if (serial->port[i]->dev.parent != NULL) {
- device_unregister(&serial->port[i]->dev);
- serial->port[i] = NULL;
- }
-
- /* If this is a "fake" port, we have to clean it up here, as it will
- * not get cleaned up in port_release() as it was never registered with
- * the driver core */
- if (serial->num_ports < serial->num_port_pointers) {
- for (i = serial->num_ports; i < serial->num_port_pointers; ++i) {
- port = serial->port[i];
- if (!port)
- continue;
- if (port->read_urb) {
- usb_unlink_urb(port->read_urb);
- usb_free_urb(port->read_urb);
- }
- if (port->write_urb) {
- usb_unlink_urb(port->write_urb);
- usb_free_urb(port->write_urb);
- }
- if (port->interrupt_in_urb) {
- usb_unlink_urb(port->interrupt_in_urb);
- usb_free_urb(port->interrupt_in_urb);
- }
- kfree(port->bulk_in_buffer);
- kfree(port->bulk_out_buffer);
- kfree(port->interrupt_in_buffer);
- }
- }
-
- usb_put_dev(serial->dev);
-
- /* free up any memory that we allocated */
- kfree (serial);