Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] Option Card driver update, Maintainer entry

This patch updates the Option Card driver:
- remove a deadlock
- add sponsor notice
- add new card
- renamed the device to what's usually printed on it
- removed some dead code
- clean up a bunch of irregular whitespace (end-of-line, tabs)

Also add a MAINTAINERS entry for the Option Card driver.

Signed-Off-By: Matthias Urlichs <smurf@smurf.noris.de>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Matthias Urlichs and committed by
Linus Torvalds
ba460e48 98848fa8

+117 -115
+6
MAINTAINERS
··· 2420 2420 L: linux-usb-devel@lists.sourceforge.net 2421 2421 S: Maintained 2422 2422 2423 + USB OPTION-CARD DRIVER 2424 + P: Matthias Urlichs 2425 + M: smurf@smurf.noris.de 2426 + L: linux-usb-devel@lists.sourceforge.net 2427 + S: Maintained 2428 + 2423 2429 USB OV511 DRIVER 2424 2430 P: Mark McClelland 2425 2431 M: mmcclell@bigfoot.com
+111 -115
drivers/usb/serial/option.c
··· 12 12 History: 13 13 14 14 2005-05-19 v0.1 Initial version, based on incomplete docs 15 - and analysis of misbehavior of the standard driver 15 + and analysis of misbehavior with the standard driver 16 16 2005-05-20 v0.2 Extended the input buffer to avoid losing 17 17 random 64-byte chunks of data 18 18 2005-05-21 v0.3 implemented chars_in_buffer() 19 19 turned on low_latency 20 20 simplified the code somewhat 21 + 2005-05-24 v0.4 option_write() sometimes deadlocked under heavy load 22 + removed some dead code 23 + added sponsor notice 24 + coding style clean-up 25 + 2005-06-20 v0.4.1 add missing braces :-/ 26 + killed end-of-line whitespace 27 + 2005-07-15 v0.4.2 rename WLAN product to FUSION, add FUSION2 28 + 29 + Work sponsored by: Sigos GmbH, Germany <info@sigos.de> 30 + 21 31 */ 22 - #define DRIVER_VERSION "v0.3" 32 + 33 + #define DRIVER_VERSION "v0.4" 23 34 #define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" 24 35 #define DRIVER_DESC "Option Card (PC-Card to) USB to Serial Driver" 25 36 ··· 55 44 56 45 static void option_instat_callback(struct urb *urb, struct pt_regs *regs); 57 46 58 - 59 47 static int option_write (struct usb_serial_port *port, 60 48 const unsigned char *buf, int count); 61 49 ··· 70 60 static int option_send_setup (struct usb_serial_port *port); 71 61 72 62 /* Vendor and product IDs */ 73 - #define OPTION_VENDOR_ID 0x0AF0 63 + #define OPTION_VENDOR_ID 0x0AF0 74 64 75 - #define OPTION_PRODUCT_OLD 0x5000 76 - #define OPTION_PRODUCT_WLAN 0x6000 65 + #define OPTION_PRODUCT_OLD 0x5000 66 + #define OPTION_PRODUCT_FUSION 0x6000 67 + #define OPTION_PRODUCT_FUSION2 0x6300 68 + 77 69 78 70 static struct usb_device_id option_ids[] = { 79 71 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) }, 80 - { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_WLAN) }, 72 + { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) }, 73 + { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) }, 81 74 { } /* Terminating entry */ 82 75 }; 83 76 ··· 98 85 * recognizes separately, thus num_port=1. 99 86 */ 100 87 static struct usb_serial_device_type option_3port_device = { 101 - .owner = THIS_MODULE, 102 - .name = "Option 3-port card", 103 - .short_name = "option", 104 - .id_table = option_ids, 105 - .num_interrupt_in = NUM_DONT_CARE, 106 - .num_bulk_in = NUM_DONT_CARE, 107 - .num_bulk_out = NUM_DONT_CARE, 108 - .num_ports = 1, /* 3 */ 109 - .open = option_open, 110 - .close = option_close, 111 - .write = option_write, 112 - .write_room = option_write_room, 113 - .chars_in_buffer = option_chars_in_buffer, 114 - .throttle = option_rx_throttle, 115 - .unthrottle = option_rx_unthrottle, 116 - .ioctl = option_ioctl, 117 - .set_termios = option_set_termios, 118 - .break_ctl = option_break_ctl, 119 - .tiocmget = option_tiocmget, 120 - .tiocmset = option_tiocmset, 121 - .attach = option_startup, 122 - .shutdown = option_shutdown, 123 - .read_int_callback = option_instat_callback, 88 + .owner = THIS_MODULE, 89 + .name = "Option 3G data card", 90 + .short_name = "option", 91 + .id_table = option_ids, 92 + .num_interrupt_in = NUM_DONT_CARE, 93 + .num_bulk_in = NUM_DONT_CARE, 94 + .num_bulk_out = NUM_DONT_CARE, 95 + .num_ports = 1, /* 3, but the card reports its ports separately */ 96 + .open = option_open, 97 + .close = option_close, 98 + .write = option_write, 99 + .write_room = option_write_room, 100 + .chars_in_buffer = option_chars_in_buffer, 101 + .throttle = option_rx_throttle, 102 + .unthrottle = option_rx_unthrottle, 103 + .ioctl = option_ioctl, 104 + .set_termios = option_set_termios, 105 + .break_ctl = option_break_ctl, 106 + .tiocmget = option_tiocmget, 107 + .tiocmset = option_tiocmset, 108 + .attach = option_startup, 109 + .shutdown = option_shutdown, 110 + .read_int_callback = option_instat_callback, 124 111 }; 125 112 113 + #ifdef CONFIG_USB_DEBUG 126 114 static int debug; 115 + #else 116 + #define debug 0 117 + #endif 118 + 127 119 128 120 /* per port private data */ 129 121 130 - #define N_IN_URB 4 131 - #define N_OUT_URB 1 132 - #define IN_BUFLEN 1024 133 - #define OUT_BUFLEN 1024 122 + #define N_IN_URB 4 123 + #define N_OUT_URB 1 124 + #define IN_BUFLEN 1024 125 + #define OUT_BUFLEN 128 134 126 135 127 struct option_port_private { 136 128 /* Input endpoints and buffer for this port */ 137 - struct urb *in_urbs[N_IN_URB]; 138 - char in_buffer[N_IN_URB][IN_BUFLEN]; 129 + struct urb *in_urbs[N_IN_URB]; 130 + char in_buffer[N_IN_URB][IN_BUFLEN]; 139 131 /* Output endpoints and buffer for this port */ 140 - struct urb *out_urbs[N_OUT_URB]; 141 - char out_buffer[N_OUT_URB][OUT_BUFLEN]; 132 + struct urb *out_urbs[N_OUT_URB]; 133 + char out_buffer[N_OUT_URB][OUT_BUFLEN]; 142 134 143 135 /* Settings for the port */ 144 - int rts_state; /* Handshaking pins (outputs) */ 145 - int dtr_state; 146 - int cts_state; /* Handshaking pins (inputs) */ 147 - int dsr_state; 148 - int dcd_state; 149 - int ri_state; 150 - // int break_on; 136 + int rts_state; /* Handshaking pins (outputs) */ 137 + int dtr_state; 138 + int cts_state; /* Handshaking pins (inputs) */ 139 + int dsr_state; 140 + int dcd_state; 141 + int ri_state; 151 142 152 - unsigned long tx_start_time[N_OUT_URB]; 143 + unsigned long tx_start_time[N_OUT_URB]; 153 144 }; 154 145 155 146 ··· 207 190 option_break_ctl (struct usb_serial_port *port, int break_state) 208 191 { 209 192 /* Unfortunately, I don't know how to send a break */ 210 - dbg("%s", __FUNCTION__); 193 + dbg("%s", __FUNCTION__); 211 194 } 212 195 213 196 214 197 static void 215 198 option_set_termios (struct usb_serial_port *port, 216 - struct termios *old_termios) 199 + struct termios *old_termios) 217 200 { 218 201 dbg("%s", __FUNCTION__); 219 202 ··· 221 204 } 222 205 223 206 static int 224 - option_tiocmget(struct usb_serial_port *port, struct file *file) 207 + option_tiocmget (struct usb_serial_port *port, struct file *file) 225 208 { 226 - unsigned int value; 227 - struct option_port_private *portdata; 209 + unsigned int value; 210 + struct option_port_private *portdata; 228 211 229 212 portdata = usb_get_serial_port_data(port); 230 213 ··· 242 225 option_tiocmset (struct usb_serial_port *port, struct file *file, 243 226 unsigned int set, unsigned int clear) 244 227 { 245 - struct option_port_private *portdata; 228 + struct option_port_private *portdata; 246 229 247 230 portdata = usb_get_serial_port_data(port); 248 231 ··· 267 250 268 251 /* Write */ 269 252 static int 270 - option_write(struct usb_serial_port *port, 271 - const unsigned char *buf, int count) 253 + option_write (struct usb_serial_port *port, 254 + const unsigned char *buf, int count) 272 255 { 273 - struct option_port_private *portdata; 274 - int i; 275 - int left, todo; 276 - struct urb *this_urb = NULL; /* spurious */ 277 - int err; 256 + struct option_port_private *portdata; 257 + int i; 258 + int left, todo; 259 + struct urb *this_urb = NULL; /* spurious */ 260 + int err; 278 261 279 262 portdata = usb_get_serial_port_data(port); 280 263 281 264 dbg("%s: write (%d chars)", __FUNCTION__, count); 282 265 283 - #if 0 284 - spin_lock(&port->lock); 285 - if (port->write_urb_busy) { 286 - spin_unlock(&port->lock); 287 - dbg("%s: already writing", __FUNCTION__); 288 - return 0; 289 - } 290 - port->write_urb_busy = 1; 291 - spin_unlock(&port->lock); 292 - #endif 293 - 294 266 i = 0; 295 267 left = count; 296 - while (left>0) { 268 + for (i=0; left > 0 && i < N_OUT_URB; i++) { 297 269 todo = left; 298 270 if (todo > OUT_BUFLEN) 299 271 todo = OUT_BUFLEN; 300 272 301 - for (;i < N_OUT_URB; i++) { 302 - /* Check we have a valid urb/endpoint before we use it... */ 303 - this_urb = portdata->out_urbs[i]; 304 - if (this_urb->status != -EINPROGRESS) 305 - break; 273 + this_urb = portdata->out_urbs[i]; 274 + if (this_urb->status == -EINPROGRESS) { 306 275 if (this_urb->transfer_flags & URB_ASYNC_UNLINK) 307 276 continue; 308 277 if (time_before(jiffies, portdata->tx_start_time[i] + 10 * HZ)) 309 278 continue; 310 279 this_urb->transfer_flags |= URB_ASYNC_UNLINK; 311 280 usb_unlink_urb(this_urb); 281 + continue; 312 282 } 313 - 314 - if (i == N_OUT_URB) { 315 - /* no bulk out free! */ 316 - dbg("%s: no output urb -- left %d", __FUNCTION__,count-left); 317 - #if 0 318 - port->write_urb_busy = 0; 319 - #endif 320 - return count-left; 321 - } 283 + if (this_urb->status != 0) 284 + dbg("usb_write %p failed (err=%d)", this_urb, this_urb->status); 322 285 323 286 dbg("%s: endpoint %d buf %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe), i); 324 287 288 + /* send the data */ 325 289 memcpy (this_urb->transfer_buffer, buf, todo); 326 - 327 - /* send the data out the bulk port */ 328 290 this_urb->transfer_buffer_length = todo; 329 291 330 292 this_urb->transfer_flags &= ~URB_ASYNC_UNLINK; 331 293 this_urb->dev = port->serial->dev; 332 294 err = usb_submit_urb(this_urb, GFP_ATOMIC); 333 295 if (err) { 334 - dbg("usb_submit_urb %p (write bulk) failed (%d,, has %d)", this_urb, err, this_urb->status); 296 + dbg("usb_submit_urb %p (write bulk) failed (%d, has %d)", this_urb, err, this_urb->status); 335 297 continue; 336 298 } 337 299 portdata->tx_start_time[i] = jiffies; ··· 319 323 } 320 324 321 325 count -= left; 322 - #if 0 323 - port->write_urb_busy = 0; 324 - #endif 325 326 dbg("%s: wrote (did %d)", __FUNCTION__, count); 326 327 return count; 327 328 } ··· 326 333 static void 327 334 option_indat_callback (struct urb *urb, struct pt_regs *regs) 328 335 { 329 - int i, err; 336 + int i, err; 330 337 int endpoint; 331 338 struct usb_serial_port *port; 332 339 struct tty_struct *tty; ··· 437 444 438 445 portdata = usb_get_serial_port_data(port); 439 446 440 - for (i=0; i < N_OUT_URB; i++) 447 + for (i=0; i < N_OUT_URB; i++) { 441 448 this_urb = portdata->out_urbs[i]; 442 449 if (this_urb && this_urb->status != -EINPROGRESS) 443 450 data_len += OUT_BUFLEN; 451 + } 444 452 445 453 dbg("%s: %d", __FUNCTION__, data_len); 446 454 return data_len; ··· 458 464 459 465 portdata = usb_get_serial_port_data(port); 460 466 461 - for (i=0; i < N_OUT_URB; i++) 467 + for (i=0; i < N_OUT_URB; i++) { 462 468 this_urb = portdata->out_urbs[i]; 463 469 if (this_urb && this_urb->status == -EINPROGRESS) 464 470 data_len += this_urb->transfer_buffer_length; 465 - 471 + } 466 472 dbg("%s: %d", __FUNCTION__, data_len); 467 473 return data_len; 468 474 } ··· 471 477 static int 472 478 option_open (struct usb_serial_port *port, struct file *filp) 473 479 { 474 - struct option_port_private *portdata; 475 - struct usb_serial *serial = port->serial; 476 - int i, err; 477 - struct urb *urb; 480 + struct option_port_private *portdata; 481 + struct usb_serial *serial = port->serial; 482 + int i, err; 483 + struct urb *urb; 478 484 479 485 portdata = usb_get_serial_port_data(port); 480 486 ··· 522 528 } 523 529 524 530 static inline void 525 - stop_urb(struct urb *urb) 531 + stop_urb (struct urb *urb) 526 532 { 527 533 if (urb && urb->status == -EINPROGRESS) { 528 534 urb->transfer_flags &= ~URB_ASYNC_UNLINK; ··· 531 537 } 532 538 533 539 static void 534 - option_close(struct usb_serial_port *port, struct file *filp) 540 + option_close (struct usb_serial_port *port, struct file *filp) 535 541 { 536 - int i; 537 - struct usb_serial *serial = port->serial; 538 - struct option_port_private *portdata; 542 + int i; 543 + struct usb_serial *serial = port->serial; 544 + struct option_port_private *portdata; 539 545 540 546 dbg("%s", __FUNCTION__); 541 547 portdata = usb_get_serial_port_data(port); ··· 583 589 584 590 /* Setup urbs */ 585 591 static void 586 - option_setup_urbs(struct usb_serial *serial) 592 + option_setup_urbs (struct usb_serial *serial) 587 593 { 588 - int j; 589 - struct usb_serial_port *port; 590 - struct option_port_private *portdata; 594 + int j; 595 + struct usb_serial_port *port; 596 + struct option_port_private *portdata; 591 597 592 598 dbg("%s", __FUNCTION__); 593 599 ··· 611 617 612 618 613 619 static int 614 - option_send_setup(struct usb_serial_port *port) 620 + option_send_setup (struct usb_serial_port *port) 615 621 { 616 622 struct usb_serial *serial = port->serial; 617 623 struct option_port_private *portdata; ··· 638 644 static int 639 645 option_startup (struct usb_serial *serial) 640 646 { 641 - int i, err; 642 - struct usb_serial_port *port; 643 - struct option_port_private *portdata; 647 + int i, err; 648 + struct usb_serial_port *port; 649 + struct option_port_private *portdata; 644 650 645 651 dbg("%s", __FUNCTION__); 646 652 ··· 671 677 static void 672 678 option_shutdown (struct usb_serial *serial) 673 679 { 674 - int i, j; 675 - struct usb_serial_port *port; 676 - struct option_port_private *portdata; 680 + int i, j; 681 + struct usb_serial_port *port; 682 + struct option_port_private *portdata; 677 683 678 684 dbg("%s", __FUNCTION__); 679 685 ··· 718 724 MODULE_VERSION(DRIVER_VERSION); 719 725 MODULE_LICENSE("GPL"); 720 726 727 + #ifdef CONFIG_USB_DEBUG 721 728 module_param(debug, bool, S_IRUGO | S_IWUSR); 722 729 MODULE_PARM_DESC(debug, "Debug messages"); 730 + #endif 723 731