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