Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * USB Serial Converter Generic functions |
| 3 | * |
| 4 | * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License version |
| 8 | * 2 as published by the Free Software Foundation. |
| 9 | * |
| 10 | */ |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/kernel.h> |
| 13 | #include <linux/errno.h> |
| 14 | #include <linux/slab.h> |
| 15 | #include <linux/tty.h> |
| 16 | #include <linux/tty_flip.h> |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/moduleparam.h> |
| 19 | #include <linux/usb.h> |
Greg Kroah-Hartman | a969888 | 2006-07-11 21:22:58 -0700 | [diff] [blame] | 20 | #include <linux/usb/serial.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <asm/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Johannes Hölzl | d9b1b78 | 2006-12-17 21:50:24 +0100 | [diff] [blame] | 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | static int debug; |
| 25 | |
| 26 | #ifdef CONFIG_USB_SERIAL_GENERIC |
David Brownell | b46d60f | 2007-03-23 12:51:55 -0700 | [diff] [blame] | 27 | |
| 28 | static int generic_probe(struct usb_interface *interface, |
| 29 | const struct usb_device_id *id); |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | static __u16 vendor = 0x05f9; |
| 32 | static __u16 product = 0xffff; |
| 33 | |
| 34 | module_param(vendor, ushort, 0); |
| 35 | MODULE_PARM_DESC(vendor, "User specified USB idVendor"); |
| 36 | |
| 37 | module_param(product, ushort, 0); |
| 38 | MODULE_PARM_DESC(product, "User specified USB idProduct"); |
| 39 | |
| 40 | static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */ |
| 41 | |
Johannes Hölzl | d9b1b78 | 2006-12-17 21:50:24 +0100 | [diff] [blame] | 42 | /* we want to look at all devices, as the vendor/product id can change |
| 43 | * depending on the command line argument */ |
| 44 | static struct usb_device_id generic_serial_ids[] = { |
| 45 | {.driver_info = 42}, |
| 46 | {} |
| 47 | }; |
| 48 | |
| 49 | static struct usb_driver generic_driver = { |
| 50 | .name = "usbserial_generic", |
| 51 | .probe = generic_probe, |
| 52 | .disconnect = usb_serial_disconnect, |
| 53 | .id_table = generic_serial_ids, |
| 54 | .no_dynamic_id = 1, |
| 55 | }; |
| 56 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | /* All of the device info needed for the Generic Serial Converter */ |
Greg Kroah-Hartman | ea65370 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 58 | struct usb_serial_driver usb_serial_generic_device = { |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 59 | .driver = { |
| 60 | .owner = THIS_MODULE, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 61 | .name = "generic", |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 62 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | .id_table = generic_device_ids, |
Johannes Hölzl | d9b1b78 | 2006-12-17 21:50:24 +0100 | [diff] [blame] | 64 | .usb_driver = &generic_driver, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | .num_interrupt_in = NUM_DONT_CARE, |
| 66 | .num_bulk_in = NUM_DONT_CARE, |
| 67 | .num_bulk_out = NUM_DONT_CARE, |
| 68 | .num_ports = 1, |
| 69 | .shutdown = usb_serial_generic_shutdown, |
Joris van Rantwijk | 253ca92 | 2007-02-01 20:08:18 +0100 | [diff] [blame] | 70 | .throttle = usb_serial_generic_throttle, |
| 71 | .unthrottle = usb_serial_generic_unthrottle, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | static int generic_probe(struct usb_interface *interface, |
| 75 | const struct usb_device_id *id) |
| 76 | { |
| 77 | const struct usb_device_id *id_pattern; |
| 78 | |
| 79 | id_pattern = usb_match_id(interface, generic_device_ids); |
| 80 | if (id_pattern != NULL) |
| 81 | return usb_serial_probe(interface, id); |
| 82 | return -ENODEV; |
| 83 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | #endif |
| 85 | |
| 86 | int usb_serial_generic_register (int _debug) |
| 87 | { |
| 88 | int retval = 0; |
| 89 | |
| 90 | debug = _debug; |
| 91 | #ifdef CONFIG_USB_SERIAL_GENERIC |
| 92 | generic_device_ids[0].idVendor = vendor; |
| 93 | generic_device_ids[0].idProduct = product; |
| 94 | generic_device_ids[0].match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; |
| 95 | |
| 96 | /* register our generic driver with ourselves */ |
| 97 | retval = usb_serial_register (&usb_serial_generic_device); |
| 98 | if (retval) |
| 99 | goto exit; |
| 100 | retval = usb_register(&generic_driver); |
| 101 | if (retval) |
| 102 | usb_serial_deregister(&usb_serial_generic_device); |
| 103 | exit: |
| 104 | #endif |
| 105 | return retval; |
| 106 | } |
| 107 | |
| 108 | void usb_serial_generic_deregister (void) |
| 109 | { |
| 110 | #ifdef CONFIG_USB_SERIAL_GENERIC |
| 111 | /* remove our generic driver */ |
| 112 | usb_deregister(&generic_driver); |
| 113 | usb_serial_deregister (&usb_serial_generic_device); |
| 114 | #endif |
| 115 | } |
| 116 | |
| 117 | int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) |
| 118 | { |
| 119 | struct usb_serial *serial = port->serial; |
| 120 | int result = 0; |
Joris van Rantwijk | 253ca92 | 2007-02-01 20:08:18 +0100 | [diff] [blame] | 121 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | |
| 123 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 124 | |
| 125 | /* force low_latency on so that our tty_push actually forces the data through, |
| 126 | otherwise it is scheduled, and with high data rates (like with OHCI) data |
| 127 | can get lost. */ |
| 128 | if (port->tty) |
| 129 | port->tty->low_latency = 1; |
| 130 | |
Joris van Rantwijk | 253ca92 | 2007-02-01 20:08:18 +0100 | [diff] [blame] | 131 | /* clear the throttle flags */ |
| 132 | spin_lock_irqsave(&port->lock, flags); |
| 133 | port->throttled = 0; |
| 134 | port->throttle_req = 0; |
| 135 | spin_unlock_irqrestore(&port->lock, flags); |
| 136 | |
| 137 | /* if we have a bulk endpoint, start reading from it */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | if (serial->num_bulk_in) { |
| 139 | /* Start reading from the device */ |
| 140 | usb_fill_bulk_urb (port->read_urb, serial->dev, |
| 141 | usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), |
| 142 | port->read_urb->transfer_buffer, |
| 143 | port->read_urb->transfer_buffer_length, |
| 144 | ((serial->type->read_bulk_callback) ? |
| 145 | serial->type->read_bulk_callback : |
| 146 | usb_serial_generic_read_bulk_callback), |
| 147 | port); |
| 148 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
| 149 | if (result) |
| 150 | dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); |
| 151 | } |
| 152 | |
| 153 | return result; |
| 154 | } |
Greg Kroah-Hartman | 815ddc9 | 2006-05-12 11:05:29 -0700 | [diff] [blame] | 155 | EXPORT_SYMBOL_GPL(usb_serial_generic_open); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | |
| 157 | static void generic_cleanup (struct usb_serial_port *port) |
| 158 | { |
| 159 | struct usb_serial *serial = port->serial; |
| 160 | |
| 161 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 162 | |
| 163 | if (serial->dev) { |
| 164 | /* shutdown any bulk reads that might be going on */ |
| 165 | if (serial->num_bulk_out) |
| 166 | usb_kill_urb(port->write_urb); |
| 167 | if (serial->num_bulk_in) |
| 168 | usb_kill_urb(port->read_urb); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | void usb_serial_generic_close (struct usb_serial_port *port, struct file * filp) |
| 173 | { |
| 174 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 175 | generic_cleanup (port); |
| 176 | } |
| 177 | |
| 178 | int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *buf, int count) |
| 179 | { |
| 180 | struct usb_serial *serial = port->serial; |
| 181 | int result; |
| 182 | unsigned char *data; |
| 183 | |
| 184 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 185 | |
| 186 | if (count == 0) { |
| 187 | dbg("%s - write request of 0 bytes", __FUNCTION__); |
| 188 | return (0); |
| 189 | } |
| 190 | |
| 191 | /* only do something if we have a bulk out endpoint */ |
| 192 | if (serial->num_bulk_out) { |
Peter Zijlstra | e81ee63 | 2006-09-25 12:51:41 +0200 | [diff] [blame] | 193 | spin_lock_bh(&port->lock); |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 194 | if (port->write_urb_busy) { |
Peter Zijlstra | e81ee63 | 2006-09-25 12:51:41 +0200 | [diff] [blame] | 195 | spin_unlock_bh(&port->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | dbg("%s - already writing", __FUNCTION__); |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 197 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | } |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 199 | port->write_urb_busy = 1; |
Peter Zijlstra | e81ee63 | 2006-09-25 12:51:41 +0200 | [diff] [blame] | 200 | spin_unlock_bh(&port->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | |
| 202 | count = (count > port->bulk_out_size) ? port->bulk_out_size : count; |
| 203 | |
| 204 | memcpy (port->write_urb->transfer_buffer, buf, count); |
| 205 | data = port->write_urb->transfer_buffer; |
| 206 | usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, data); |
| 207 | |
| 208 | /* set up our urb */ |
| 209 | usb_fill_bulk_urb (port->write_urb, serial->dev, |
| 210 | usb_sndbulkpipe (serial->dev, |
| 211 | port->bulk_out_endpointAddress), |
| 212 | port->write_urb->transfer_buffer, count, |
| 213 | ((serial->type->write_bulk_callback) ? |
| 214 | serial->type->write_bulk_callback : |
| 215 | usb_serial_generic_write_bulk_callback), port); |
| 216 | |
| 217 | /* send the data out the bulk port */ |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 218 | port->write_urb_busy = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 220 | if (result) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 222 | /* don't have to grab the lock here, as we will retry if != 0 */ |
| 223 | port->write_urb_busy = 0; |
| 224 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | result = count; |
| 226 | |
| 227 | return result; |
| 228 | } |
| 229 | |
| 230 | /* no bulk out, so return 0 bytes written */ |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 231 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | int usb_serial_generic_write_room (struct usb_serial_port *port) |
| 235 | { |
| 236 | struct usb_serial *serial = port->serial; |
| 237 | int room = 0; |
| 238 | |
| 239 | dbg("%s - port %d", __FUNCTION__, port->number); |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 240 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | if (serial->num_bulk_out) { |
Randall Nortman | 7a3ca7d | 2005-10-14 17:21:50 -0700 | [diff] [blame] | 242 | if (!(port->write_urb_busy)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | room = port->bulk_out_size; |
| 244 | } |
| 245 | |
| 246 | dbg("%s - returns %d", __FUNCTION__, room); |
| 247 | return (room); |
| 248 | } |
| 249 | |
| 250 | int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) |
| 251 | { |
| 252 | struct usb_serial *serial = port->serial; |
| 253 | int chars = 0; |
| 254 | |
| 255 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 256 | |
| 257 | if (serial->num_bulk_out) { |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 258 | if (port->write_urb_busy) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | chars = port->write_urb->transfer_buffer_length; |
| 260 | } |
| 261 | |
| 262 | dbg("%s - returns %d", __FUNCTION__, chars); |
| 263 | return (chars); |
| 264 | } |
| 265 | |
Joris van Rantwijk | 253ca92 | 2007-02-01 20:08:18 +0100 | [diff] [blame] | 266 | /* Push data to tty layer and resubmit the bulk read URB */ |
| 267 | static void flush_and_resubmit_read_urb (struct usb_serial_port *port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | struct usb_serial *serial = port->serial; |
Joris van Rantwijk | 253ca92 | 2007-02-01 20:08:18 +0100 | [diff] [blame] | 270 | struct urb *urb = port->read_urb; |
| 271 | struct tty_struct *tty = port->tty; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | int result; |
| 273 | |
Joris van Rantwijk | 253ca92 | 2007-02-01 20:08:18 +0100 | [diff] [blame] | 274 | /* Push data to tty */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | if (tty && urb->actual_length) { |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 276 | tty_buffer_request_room(tty, urb->actual_length); |
Joris van Rantwijk | 253ca92 | 2007-02-01 20:08:18 +0100 | [diff] [blame] | 277 | tty_insert_flip_string(tty, urb->transfer_buffer, urb->actual_length); |
| 278 | tty_flip_buffer_push(tty); /* is this allowed from an URB callback ? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Joris van Rantwijk | 253ca92 | 2007-02-01 20:08:18 +0100 | [diff] [blame] | 281 | /* Continue reading from device */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | usb_fill_bulk_urb (port->read_urb, serial->dev, |
| 283 | usb_rcvbulkpipe (serial->dev, |
| 284 | port->bulk_in_endpointAddress), |
| 285 | port->read_urb->transfer_buffer, |
| 286 | port->read_urb->transfer_buffer_length, |
| 287 | ((serial->type->read_bulk_callback) ? |
| 288 | serial->type->read_bulk_callback : |
| 289 | usb_serial_generic_read_bulk_callback), port); |
| 290 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
| 291 | if (result) |
| 292 | dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); |
| 293 | } |
Joris van Rantwijk | 253ca92 | 2007-02-01 20:08:18 +0100 | [diff] [blame] | 294 | |
| 295 | void usb_serial_generic_read_bulk_callback (struct urb *urb) |
| 296 | { |
| 297 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; |
| 298 | unsigned char *data = urb->transfer_buffer; |
| 299 | int is_throttled; |
| 300 | unsigned long flags; |
| 301 | |
| 302 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 303 | |
| 304 | if (urb->status) { |
| 305 | dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); |
| 306 | return; |
| 307 | } |
| 308 | |
| 309 | usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); |
| 310 | |
| 311 | /* Throttle the device if requested by tty */ |
| 312 | if (urb->actual_length) { |
| 313 | spin_lock_irqsave(&port->lock, flags); |
| 314 | is_throttled = port->throttled = port->throttle_req; |
| 315 | spin_unlock_irqrestore(&port->lock, flags); |
| 316 | if (is_throttled) { |
| 317 | /* Let the received data linger in the read URB; |
| 318 | * usb_serial_generic_unthrottle() will pick it |
| 319 | * up later. */ |
| 320 | dbg("%s - throttling device", __FUNCTION__); |
| 321 | return; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | /* Handle data and continue reading from device */ |
| 326 | flush_and_resubmit_read_urb(port); |
| 327 | } |
Luiz Fernando N. Capitulino | 166ffcc | 2006-07-11 14:19:25 -0300 | [diff] [blame] | 328 | EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 330 | void usb_serial_generic_write_bulk_callback (struct urb *urb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | { |
| 332 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; |
| 333 | |
| 334 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 335 | |
Greg Kroah-Hartman | 507ca9b | 2005-04-23 12:49:16 -0700 | [diff] [blame] | 336 | port->write_urb_busy = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | if (urb->status) { |
| 338 | dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); |
| 339 | return; |
| 340 | } |
| 341 | |
Pete Zaitcev | cf2c748 | 2006-05-22 21:58:49 -0700 | [diff] [blame] | 342 | usb_serial_port_softint(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | } |
Greg Kroah-Hartman | bb83398 | 2005-11-17 09:48:18 -0800 | [diff] [blame] | 344 | EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | |
Joris van Rantwijk | 253ca92 | 2007-02-01 20:08:18 +0100 | [diff] [blame] | 346 | void usb_serial_generic_throttle (struct usb_serial_port *port) |
| 347 | { |
| 348 | unsigned long flags; |
| 349 | |
| 350 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 351 | |
| 352 | /* Set the throttle request flag. It will be picked up |
| 353 | * by usb_serial_generic_read_bulk_callback(). */ |
| 354 | spin_lock_irqsave(&port->lock, flags); |
| 355 | port->throttle_req = 1; |
| 356 | spin_unlock_irqrestore(&port->lock, flags); |
| 357 | } |
| 358 | |
| 359 | void usb_serial_generic_unthrottle (struct usb_serial_port *port) |
| 360 | { |
| 361 | int was_throttled; |
| 362 | unsigned long flags; |
| 363 | |
| 364 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 365 | |
| 366 | /* Clear the throttle flags */ |
| 367 | spin_lock_irqsave(&port->lock, flags); |
| 368 | was_throttled = port->throttled; |
| 369 | port->throttled = port->throttle_req = 0; |
| 370 | spin_unlock_irqrestore(&port->lock, flags); |
| 371 | |
| 372 | if (was_throttled) { |
| 373 | /* Handle pending data and resume reading from device */ |
| 374 | flush_and_resubmit_read_urb(port); |
| 375 | } |
| 376 | } |
| 377 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | void usb_serial_generic_shutdown (struct usb_serial *serial) |
| 379 | { |
| 380 | int i; |
| 381 | |
| 382 | dbg("%s", __FUNCTION__); |
| 383 | |
| 384 | /* stop reads and writes on all ports */ |
| 385 | for (i=0; i < serial->num_ports; ++i) { |
| 386 | generic_cleanup(serial->port[i]); |
| 387 | } |
| 388 | } |
| 389 | |