Move complex packages to their own menu,
[openwrt.git] / package / linux / kernel-patches / 402-pl2303-backport-2-4-29
1 diff -rNu linux-2.4.29.old/drivers/usb/serial/pl2303.c linux-2.4.29/drivers/usb/serial/pl2303.c
2 --- linux-2.4.29.old/drivers/usb/serial/pl2303.c 2005-03-22 14:48:04.000000000 +0100
3 +++ linux-2.4.29/drivers/usb/serial/pl2303.c 2005-03-22 15:33:05.735943352 +0100
4 @@ -1,7 +1,7 @@
5 /*
6 * Prolific PL2303 USB to serial adaptor driver
7 *
8 - * Copyright (C) 2001-2003 Greg Kroah-Hartman (greg@kroah.com)
9 + * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
10 * Copyright (C) 2003 IBM Corp.
11 *
12 * Original driver for 2.2.x by anonymous
13 @@ -12,8 +12,16 @@
14 * (at your option) any later version.
15 *
16 * See Documentation/usb/usb-serial.txt for more information on using this driver
17 - * 2003_Apr_24 gkh
18 - * Added line error reporting support. Hopefully it is correct...
19 + *
20 + *
21 + * 2005_Mar_05 grsch
22 + * ported 2.6.8 pl2303.c to 2.4.20 format
23 + * (HX model works fine now, ID table should be brought up to date)
24 + * Gregor Schaffrath <gschaff@ran-dom.org>
25 + *
26 + * 2002_Mar_26 gkh
27 + * allowed driver to work properly if there is no tty assigned to a port
28 + * (this happens for serial console devices.)
29 *
30 * 2001_Oct_06 gkh
31 * Added RTS and DTR line control. Thanks to joe@bndlg.de for parts of it.
32 @@ -33,6 +41,9 @@
33 *
34 */
35
36 +static int debug;
37 +
38 +
39 #include <linux/config.h>
40 #include <linux/kernel.h>
41 #include <linux/errno.h>
42 @@ -46,43 +57,44 @@
43 #include <linux/spinlock.h>
44 #include <asm/uaccess.h>
45 #include <linux/usb.h>
46 -
47 -#ifdef CONFIG_USB_SERIAL_DEBUG
48 - static int debug = 1;
49 -#else
50 - static int debug;
51 -#endif
52 -
53 #include "usb-serial.h"
54 #include "pl2303.h"
55
56 /*
57 * Version Information
58 */
59 -#define DRIVER_VERSION "v0.10"
60 +#define DRIVER_VERSION "v0.11"
61 #define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver"
62
63 -
64 -
65 static struct usb_device_id id_table [] = {
66 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) },
67 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) },
68 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
69 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
70 - { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) },
71 { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) },
72 { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID) },
73 { USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) },
74 - { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) },
75 - { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) },
76 - { USB_DEVICE(RADIOSHACK_VENDOR_ID, RADIOSHACK_PRODUCT_ID) },
77 - { USB_DEVICE(DCU10_VENDOR_ID, DCU10_PRODUCT_ID) },
78 - { USB_DEVICE(SITECOM_VENDOR_ID, SITECOM_PRODUCT_ID) },
79 + { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) },
80 + { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) },
81 + { USB_DEVICE(RADIOSHACK_VENDOR_ID, RADIOSHACK_PRODUCT_ID) },
82 + { USB_DEVICE(DCU10_VENDOR_ID, DCU10_PRODUCT_ID) },
83 + { USB_DEVICE(SITECOM_VENDOR_ID, SITECOM_PRODUCT_ID) },
84 + { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) },
85 + { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) },
86 { } /* Terminating entry */
87 };
88
89 MODULE_DEVICE_TABLE (usb, id_table);
90
91 +/*
92 +static struct usb_driver pl2303_driver = {
93 + .owner = THIS_MODULE,
94 + .name = "pl2303",
95 + .probe = usb_serial_probe,
96 + .disconnect = usb_serial_disconnect,
97 + .id_table = id_table,
98 +};
99 +*/
100
101 #define SET_LINE_REQUEST_TYPE 0x21
102 #define SET_LINE_REQUEST 0x20
103 @@ -130,6 +142,9 @@
104 static int pl2303_write (struct usb_serial_port *port, int from_user,
105 const unsigned char *buf, int count);
106 static void pl2303_break_ctl(struct usb_serial_port *port,int break_state);
107 +static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file);
108 +static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
109 + unsigned int set, unsigned int clear);
110 static int pl2303_startup (struct usb_serial *serial);
111 static void pl2303_shutdown (struct usb_serial *serial);
112
113 @@ -149,27 +164,48 @@
114 .ioctl = pl2303_ioctl,
115 .break_ctl = pl2303_break_ctl,
116 .set_termios = pl2303_set_termios,
117 + //.tiocmget = pl2303_tiocmget,
118 + //.tiocmset = pl2303_tiocmset,
119 .read_bulk_callback = pl2303_read_bulk_callback,
120 .read_int_callback = pl2303_read_int_callback,
121 .write_bulk_callback = pl2303_write_bulk_callback,
122 + //.attach = pl2303_startup,
123 .startup = pl2303_startup,
124 .shutdown = pl2303_shutdown,
125 };
126
127 +enum pl2303_type {
128 + type_0, /* don't know the difference between type 0 and */
129 + type_1, /* type 1, until someone from prolific tells us... */
130 + HX, /* HX version of the pl2303 chip */
131 +};
132 +
133 struct pl2303_private {
134 spinlock_t lock;
135 wait_queue_head_t delta_msr_wait;
136 u8 line_control;
137 u8 line_status;
138 u8 termios_initialized;
139 + enum pl2303_type type;
140 };
141
142
143 static int pl2303_startup (struct usb_serial *serial)
144 {
145 struct pl2303_private *priv;
146 + enum pl2303_type type = type_0;
147 int i;
148
149 + if (serial->dev->descriptor.bDeviceClass == 0x02)
150 + type = type_0;
151 + else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40)
152 + type = HX;
153 + else if (serial->dev->descriptor.bDeviceClass == 0x00)
154 + type = type_1;
155 + else if (serial->dev->descriptor.bDeviceClass == 0xFF)
156 + type = type_1;
157 + dbg("device type: %d", type);
158 +
159 for (i = 0; i < serial->num_ports; ++i) {
160 priv = kmalloc (sizeof (struct pl2303_private), GFP_KERNEL);
161 if (!priv)
162 @@ -177,7 +213,8 @@
163 memset (priv, 0x00, sizeof (struct pl2303_private));
164 spin_lock_init(&priv->lock);
165 init_waitqueue_head(&priv->delta_msr_wait);
166 - usb_set_serial_port_data(&serial->port[i], priv);
167 + priv->type = type;
168 + serial->port[i].private = priv;
169 }
170 return 0;
171 }
172 @@ -215,13 +252,13 @@
173 memcpy (port->write_urb->transfer_buffer, buf, count);
174 }
175
176 - usb_serial_debug_data (__FILE__, __FUNCTION__, count, port->write_urb->transfer_buffer);
177 + usb_serial_debug_data(__FILE__, __FUNCTION__, count, port->write_urb->transfer_buffer);
178
179 port->write_urb->transfer_buffer_length = count;
180 port->write_urb->dev = port->serial->dev;
181 result = usb_submit_urb (port->write_urb);
182 if (result)
183 - err("%s - failed submitting write urb, error %d", __FUNCTION__, result);
184 + err("%s - failed submitting write urb, error %d\n", __FUNCTION__, result);
185 else
186 result = count;
187
188 @@ -233,7 +270,7 @@
189 static void pl2303_set_termios (struct usb_serial_port *port, struct termios *old_termios)
190 {
191 struct usb_serial *serial = port->serial;
192 - struct pl2303_private *priv = usb_get_serial_port_data(port);
193 + struct pl2303_private *priv = port->private;
194 unsigned long flags;
195 unsigned int cflag;
196 unsigned char *buf;
197 @@ -241,8 +278,7 @@
198 int i;
199 u8 control;
200
201 - dbg("%s - port %d, initialized = %d", __FUNCTION__, port->number,
202 - priv->termios_initialized);
203 + dbg("%s - port %d", __FUNCTION__, port->number);
204
205 if ((!port->tty) || (!port->tty->termios)) {
206 dbg("%s - no tty structures", __FUNCTION__);
207 @@ -269,7 +305,7 @@
208
209 buf = kmalloc (7, GFP_KERNEL);
210 if (!buf) {
211 - err("%s - out of memory.", __FUNCTION__);
212 + err("%s - out of memory.\n", __FUNCTION__);
213 return;
214 }
215 memset (buf, 0x00, 0x07);
216 @@ -311,7 +347,7 @@
217 case B230400: baud = 230400; break;
218 case B460800: baud = 460800; break;
219 default:
220 - err ("pl2303 driver does not support the baudrate requested (fix it)");
221 + err("pl2303 driver does not support the baudrate requested (fix it)\n");
222 break;
223 }
224 dbg("%s - baud = %d", __FUNCTION__, baud);
225 @@ -380,26 +416,30 @@
226 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
227
228 if (cflag & CRTSCTS) {
229 - i = usb_control_msg (serial->dev, usb_sndctrlpipe (serial->dev, 0),
230 - VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE,
231 - 0x0, 0x41, NULL, 0, 100);
232 - dbg ("0x40:0x1:0x0:0x41 %d", i);
233 + __u16 index;
234 + if (priv->type == HX)
235 + index = 0x61;
236 + else
237 + index = 0x41;
238 + i = usb_control_msg(serial->dev,
239 + usb_sndctrlpipe(serial->dev, 0),
240 + VENDOR_WRITE_REQUEST,
241 + VENDOR_WRITE_REQUEST_TYPE,
242 + 0x0, index, NULL, 0, 100);
243 + dbg ("0x40:0x1:0x0:0x%x %d", index, i);
244 }
245
246 kfree (buf);
247 -}
248 -
249 +}
250
251 static int pl2303_open (struct usb_serial_port *port, struct file *filp)
252 {
253 struct termios tmp_termios;
254 struct usb_serial *serial = port->serial;
255 + struct pl2303_private *priv = port->private;
256 unsigned char *buf;
257 int result;
258
259 - if (port_paranoia_check (port, __FUNCTION__))
260 - return -ENODEV;
261 -
262 dbg("%s - port %d", __FUNCTION__, port->number);
263
264 usb_clear_halt(serial->dev, port->write_urb->pipe);
265 @@ -427,6 +467,18 @@
266 SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0x0404, 1);
267 FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0);
268 FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8383, 0);
269 + SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0, 1);
270 + SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 1, 0);
271 +
272 + if (priv->type == HX) {
273 + /* HX chip */
274 + SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 2, 0x44);
275 + /* reset upstream data pipes */
276 + SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 8, 0);
277 + SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 9, 0);
278 + } else {
279 + SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 2, 0x24);
280 + }
281
282 kfree(buf);
283
284 @@ -441,7 +493,7 @@
285 port->read_urb->dev = serial->dev;
286 result = usb_submit_urb (port->read_urb);
287 if (result) {
288 - err("%s - failed submitting read urb, error %d", __FUNCTION__, result);
289 + err("%s - failed submitting read urb, error %d\n", __FUNCTION__, result);
290 pl2303_close (port, NULL);
291 return -EPROTO;
292 }
293 @@ -450,7 +502,7 @@
294 port->interrupt_in_urb->dev = serial->dev;
295 result = usb_submit_urb (port->interrupt_in_urb);
296 if (result) {
297 - err("%s - failed submitting interrupt urb, error %d", __FUNCTION__, result);
298 + err("%s - failed submitting interrupt urb, error %d\n", __FUNCTION__, result);
299 pl2303_close (port, NULL);
300 return -EPROTO;
301 }
302 @@ -460,125 +512,103 @@
303
304 static void pl2303_close (struct usb_serial_port *port, struct file *filp)
305 {
306 - struct usb_serial *serial;
307 struct pl2303_private *priv;
308 unsigned long flags;
309 unsigned int c_cflag;
310 int result;
311
312 - if (port_paranoia_check (port, __FUNCTION__))
313 - return;
314 - serial = get_usb_serial (port, __FUNCTION__);
315 - if (!serial)
316 - return;
317 -
318 dbg("%s - port %d", __FUNCTION__, port->number);
319
320 - if (serial->dev) {
321 - if (port->tty) {
322 - c_cflag = port->tty->termios->c_cflag;
323 - if (c_cflag & HUPCL) {
324 - /* drop DTR and RTS */
325 - priv = usb_get_serial_port_data(port);
326 - spin_lock_irqsave(&priv->lock, flags);
327 - priv->line_control = 0;
328 - spin_unlock_irqrestore (&priv->lock, flags);
329 - set_control_lines (port->serial->dev, 0);
330 - }
331 - }
332 + /* shutdown our urbs */
333 + dbg("%s - shutting down urbs", __FUNCTION__);
334 + result = usb_unlink_urb (port->write_urb);
335 + if (result)
336 + dbg("%s - usb_unlink_urb (write_urb)"
337 + " failed with reason: %d", __FUNCTION__,
338 + result);
339
340 - /* shutdown our urbs */
341 - dbg("%s - shutting down urbs", __FUNCTION__);
342 - result = usb_unlink_urb (port->write_urb);
343 - if (result)
344 - dbg("%s - usb_unlink_urb (write_urb)"
345 - " failed with reason: %d", __FUNCTION__,
346 - result);
347 + result = usb_unlink_urb (port->read_urb);
348 + if (result)
349 + dbg("%s - usb_unlink_urb (read_urb) "
350 + "failed with reason: %d", __FUNCTION__,
351 + result);
352
353 - result = usb_unlink_urb (port->read_urb);
354 - if (result)
355 - dbg("%s - usb_unlink_urb (read_urb) "
356 - "failed with reason: %d", __FUNCTION__,
357 - result);
358 + result = usb_unlink_urb (port->interrupt_in_urb);
359 + if (result)
360 + dbg("%s - usb_unlink_urb (interrupt_in_urb)"
361 + " failed with reason: %d", __FUNCTION__,
362 + result);
363
364 - result = usb_unlink_urb (port->interrupt_in_urb);
365 - if (result)
366 - dbg("%s - usb_unlink_urb (interrupt_in_urb)"
367 - " failed with reason: %d", __FUNCTION__,
368 - result);
369 + if (port->tty) {
370 + c_cflag = port->tty->termios->c_cflag;
371 + if (c_cflag & HUPCL) {
372 + /* drop DTR and RTS */
373 + priv = port->private;
374 + spin_lock_irqsave(&priv->lock, flags);
375 + priv->line_control = 0;
376 + spin_unlock_irqrestore (&priv->lock, flags);
377 + set_control_lines (port->serial->dev, 0);
378 + }
379 }
380 +
381 }
382
383 +/* taken from 2.4.20 driver */
384 static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsigned int *value)
385 {
386 - struct pl2303_private *priv = usb_get_serial_port_data(port);
387 - unsigned long flags;
388 - unsigned int arg;
389 - u8 control;
390 -
391 - if (copy_from_user(&arg, value, sizeof(int)))
392 - return -EFAULT;
393 -
394 - spin_lock_irqsave (&priv->lock, flags);
395 - switch (cmd) {
396 - case TIOCMBIS:
397 - if (arg & TIOCM_RTS)
398 - priv->line_control |= CONTROL_RTS;
399 - if (arg & TIOCM_DTR)
400 - priv->line_control |= CONTROL_DTR;
401 - break;
402 -
403 - case TIOCMBIC:
404 - if (arg & TIOCM_RTS)
405 - priv->line_control &= ~CONTROL_RTS;
406 - if (arg & TIOCM_DTR)
407 - priv->line_control &= ~CONTROL_DTR;
408 - break;
409 + struct pl2303_private *priv = port->private;
410 + unsigned int arg;
411
412 - case TIOCMSET:
413 - /* turn off RTS and DTR and then only turn
414 - on what was asked to */
415 - priv->line_control &= ~(CONTROL_RTS | CONTROL_DTR);
416 - priv->line_control |= ((arg & TIOCM_RTS) ? CONTROL_RTS : 0);
417 - priv->line_control |= ((arg & TIOCM_DTR) ? CONTROL_DTR : 0);
418 - break;
419 - }
420 - control = priv->line_control;
421 - spin_unlock_irqrestore (&priv->lock, flags);
422 -
423 - return set_control_lines (port->serial->dev, control);
424 + if (copy_from_user(&arg, value, sizeof(int)))
425 + return -EFAULT;
426 +
427 + switch (cmd) {
428 + case TIOCMBIS:
429 + if (arg & TIOCM_RTS)
430 + priv->line_control |= CONTROL_RTS;
431 + if (arg & TIOCM_DTR)
432 + priv->line_control |= CONTROL_DTR;
433 + break;
434 +
435 + case TIOCMBIC:
436 + if (arg & TIOCM_RTS)
437 + priv->line_control &= ~CONTROL_RTS;
438 + if (arg & TIOCM_DTR)
439 + priv->line_control &= ~CONTROL_DTR;
440 + break;
441 +
442 + case TIOCMSET:
443 + /* turn off RTS and DTR and then only turn
444 + on what was asked to */
445 + priv->line_control &= ~(CONTROL_RTS | CONTROL_DTR);
446 + priv->line_control |= ((arg & TIOCM_RTS) ? CONTROL_RTS : 0);
447 + priv->line_control |= ((arg & TIOCM_DTR) ? CONTROL_DTR : 0);
448 + break;
449 + }
450 +
451 + return set_control_lines (port->serial->dev, priv->line_control);
452 }
453
454 static int get_modem_info (struct usb_serial_port *port, unsigned int *value)
455 {
456 - struct pl2303_private *priv = usb_get_serial_port_data(port);
457 - unsigned long flags;
458 - unsigned int mcr;
459 - unsigned int status;
460 - unsigned int result;
461 -
462 - spin_lock_irqsave (&priv->lock, flags);
463 - mcr = priv->line_control;
464 - status = priv->line_status;
465 - spin_unlock_irqrestore (&priv->lock, flags);
466 -
467 - result = ((mcr & CONTROL_DTR) ? TIOCM_DTR : 0)
468 - | ((mcr & CONTROL_RTS) ? TIOCM_RTS : 0)
469 - | ((status & UART_CTS) ? TIOCM_CTS : 0)
470 - | ((status & UART_DSR) ? TIOCM_DSR : 0)
471 - | ((status & UART_RING) ? TIOCM_RI : 0)
472 - | ((status & UART_DCD) ? TIOCM_CD : 0);
473 -
474 - dbg("%s - result = %x", __FUNCTION__, result);
475 -
476 - if (copy_to_user(value, &result, sizeof(int)))
477 - return -EFAULT;
478 - return 0;
479 + struct pl2303_private *priv = port->private;
480 + unsigned int mcr = priv->line_control;
481 + unsigned int result;
482 +
483 + result = ((mcr & CONTROL_DTR) ? TIOCM_DTR : 0)
484 + | ((mcr & CONTROL_RTS) ? TIOCM_RTS : 0);
485 +
486 + dbg("%s - result = %x", __FUNCTION__, result);
487 +
488 + if (copy_to_user(value, &result, sizeof(int)))
489 + return -EFAULT;
490 + return 0;
491 }
492 +/* end of 2.4.20 kernel part - grsch */
493
494 static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
495 {
496 - struct pl2303_private *priv = usb_get_serial_port_data(port);
497 + struct pl2303_private *priv = port->private;
498 unsigned long flags;
499 unsigned int prevstatus;
500 unsigned int status;
501 @@ -617,21 +647,10 @@
502 dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd);
503
504 switch (cmd) {
505 -
506 - case TIOCMGET:
507 - dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
508 - return get_modem_info (port, (unsigned int *)arg);
509 -
510 - case TIOCMBIS:
511 - case TIOCMBIC:
512 - case TIOCMSET:
513 - dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, port->number);
514 - return set_modem_info(port, cmd, (unsigned int *) arg);
515 -
516 case TIOCMIWAIT:
517 dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number);
518 return wait_modem_info(port, arg);
519 -
520 +
521 default:
522 dbg("%s not supported = 0x%04x", __FUNCTION__, cmd);
523 break;
524 @@ -652,7 +671,7 @@
525 state = BREAK_OFF;
526 else
527 state = BREAK_ON;
528 - dbg("%s - turning break %s", __FUNCTION__, state==BREAK_OFF ? "off" : "on");
529 + dbg("%s - turning break %s", state==BREAK_OFF ? "off" : "on", __FUNCTION__);
530
531 result = usb_control_msg (serial->dev, usb_sndctrlpipe (serial->dev, 0),
532 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
533 @@ -669,8 +688,8 @@
534 dbg("%s", __FUNCTION__);
535
536 for (i = 0; i < serial->num_ports; ++i) {
537 - kfree (usb_get_serial_port_data(&serial->port[i]));
538 - usb_set_serial_port_data(&serial->port[i], NULL);
539 + kfree (serial->port[i].private);
540 + serial->port[i].private = NULL;
541 }
542 }
543
544 @@ -678,16 +697,14 @@
545 static void pl2303_read_int_callback (struct urb *urb)
546 {
547 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
548 - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
549 - struct pl2303_private *priv = usb_get_serial_port_data(port);
550 + struct pl2303_private *priv = port->private;
551 unsigned char *data = urb->transfer_buffer;
552 unsigned long flags;
553 + int status;
554 u8 uart_state;
555
556 dbg("%s (%d)", __FUNCTION__, port->number);
557
558 - /* ints auto restart... */
559 -
560 switch (urb->status) {
561 case 0:
562 /* success */
563 @@ -700,17 +717,14 @@
564 return;
565 default:
566 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
567 - return;
568 + goto exit;
569 }
570
571 - if (!serial) {
572 - return;
573 - }
574
575 - usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer);
576 + usb_serial_debug_data(__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer);
577
578 if (urb->actual_length < UART_STATE)
579 - return;
580 + goto exit;
581
582 /* Save off the uart status for others to look at */
583 uart_state = data[UART_STATE];
584 @@ -718,17 +732,19 @@
585 uart_state |= (priv->line_status & UART_STATE_TRANSIENT_MASK);
586 priv->line_status = uart_state;
587 spin_unlock_irqrestore(&priv->lock, flags);
588 - wake_up_interruptible (&priv->delta_msr_wait);
589 -
590 - return;
591 +
592 +exit:
593 + status = usb_submit_urb (urb);
594 + if (status)
595 + err("%s - usb_submit_urb failed with result %d\n",
596 + __FUNCTION__, status);
597 }
598
599
600 static void pl2303_read_bulk_callback (struct urb *urb)
601 {
602 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
603 - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
604 - struct pl2303_private *priv = usb_get_serial_port_data(port);
605 + struct pl2303_private *priv = port->private;
606 struct tty_struct *tty;
607 unsigned char *data = urb->transfer_buffer;
608 unsigned long flags;
609 @@ -737,16 +753,8 @@
610 u8 status;
611 char tty_flag;
612
613 - if (port_paranoia_check (port, __FUNCTION__))
614 - return;
615 -
616 dbg("%s - port %d", __FUNCTION__, port->number);
617
618 - if (!serial) {
619 - dbg("%s - bad serial pointer, exiting", __FUNCTION__);
620 - return;
621 - }
622 -
623 if (urb->status) {
624 dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
625 if (!port->open_count) {
626 @@ -757,17 +765,17 @@
627 /* PL2303 mysteriously fails with -EPROTO reschedule the read */
628 dbg("%s - caught -EPROTO, resubmitting the urb", __FUNCTION__);
629 urb->status = 0;
630 - urb->dev = serial->dev;
631 + urb->dev = port->serial->dev;
632 result = usb_submit_urb(urb);
633 if (result)
634 - err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
635 + err("%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
636 return;
637 }
638 dbg("%s - unable to handle the error, exiting.", __FUNCTION__);
639 return;
640 }
641
642 - usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data);
643 + usb_serial_debug_data(__FILE__, __FUNCTION__, urb->actual_length, data);
644
645 /* get tty_flag from status */
646 tty_flag = TTY_NORMAL;
647 @@ -776,7 +784,7 @@
648 status = priv->line_status;
649 priv->line_status &= ~UART_STATE_TRANSIENT_MASK;
650 spin_unlock_irqrestore(&priv->lock, flags);
651 - wake_up_interruptible (&priv->delta_msr_wait); //AF from 2.6
652 + wake_up_interruptible (&priv->delta_msr_wait);
653
654 /* break takes precedence over parity, */
655 /* which takes precedence over framing errors */
656 @@ -805,10 +813,10 @@
657
658 /* Schedule the next read _if_ we are still open */
659 if (port->open_count) {
660 - urb->dev = serial->dev;
661 + urb->dev = port->serial->dev;
662 result = usb_submit_urb(urb);
663 if (result)
664 - err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
665 + err("%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
666 }
667
668 return;
669 @@ -821,44 +829,32 @@
670 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
671 int result;
672
673 - if (port_paranoia_check (port, __FUNCTION__))
674 - return;
675 -
676 dbg("%s - port %d", __FUNCTION__, port->number);
677
678 if (urb->status) {
679 /* error in the urb, so we have to resubmit it */
680 - if (serial_paranoia_check (port->serial, __FUNCTION__)) {
681 - return;
682 - }
683 dbg("%s - Overflow in write", __FUNCTION__);
684 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
685 port->write_urb->transfer_buffer_length = 1;
686 port->write_urb->dev = port->serial->dev;
687 result = usb_submit_urb (port->write_urb);
688 if (result)
689 - err("%s - failed resubmitting write urb, error %d", __FUNCTION__, result);
690 + err("%s - failed resubmitting write urb, error %d\n", __FUNCTION__, result);
691
692 return;
693 }
694
695 - queue_task(&port->tqueue, &tq_immediate);
696 - mark_bh(IMMEDIATE_BH);
697
698 - return;
699 + queue_task(&port->tqueue, &tq_immediate);
700 + mark_bh(IMMEDIATE_BH);
701 }
702
703
704 static int __init pl2303_init (void)
705 {
706 - int retval;
707 - retval = usb_serial_register(&pl2303_device);
708 - if (retval)
709 - goto failed_usb_serial_register;
710 + usb_serial_register(&pl2303_device);
711 info(DRIVER_DESC " " DRIVER_VERSION);
712 return 0;
713 -failed_usb_serial_register:
714 - return retval;
715 }
716
717
718 @@ -877,3 +873,4 @@
719 MODULE_PARM(debug, "i");
720 MODULE_PARM_DESC(debug, "Debug enabled or not");
721
722 +//this is an error
723 diff -rNu linux-2.4.29.old/drivers/usb/serial/pl2303.h linux-2.4.29/drivers/usb/serial/pl2303.h
724 --- linux-2.4.29.old/drivers/usb/serial/pl2303.h 2005-03-22 14:48:04.000000000 +0100
725 +++ linux-2.4.29/drivers/usb/serial/pl2303.h 2005-03-22 15:33:05.758939856 +0100
726 @@ -41,3 +41,12 @@
727
728 #define SITECOM_VENDOR_ID 0x6189
729 #define SITECOM_PRODUCT_ID 0x2068
730 +
731 +/* Alcatel OT535/735 USB cable */
732 +#define ALCATEL_VENDOR_ID 0x11f7
733 +#define ALCATEL_PRODUCT_ID 0x02df
734 +
735 +/* Samsung I330 phone cradle */
736 +#define SAMSUNG_VENDOR_ID 0x04e8
737 +#define SAMSUNG_PRODUCT_ID 0x8001
738 +
This page took 0.08167 seconds and 5 git commands to generate.