diff options
Diffstat (limited to 'drivers/usb/serial')
38 files changed, 1024 insertions, 626 deletions
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 6d106e74265e..2cbfab3716e5 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c | |||
@@ -364,7 +364,7 @@ static int aircable_attach(struct usb_serial *serial) | |||
364 | return 0; | 364 | return 0; |
365 | } | 365 | } |
366 | 366 | ||
367 | static void aircable_shutdown(struct usb_serial *serial) | 367 | static void aircable_release(struct usb_serial *serial) |
368 | { | 368 | { |
369 | 369 | ||
370 | struct usb_serial_port *port = serial->port[0]; | 370 | struct usb_serial_port *port = serial->port[0]; |
@@ -375,7 +375,6 @@ static void aircable_shutdown(struct usb_serial *serial) | |||
375 | if (priv) { | 375 | if (priv) { |
376 | serial_buf_free(priv->tx_buf); | 376 | serial_buf_free(priv->tx_buf); |
377 | serial_buf_free(priv->rx_buf); | 377 | serial_buf_free(priv->rx_buf); |
378 | usb_set_serial_port_data(port, NULL); | ||
379 | kfree(priv); | 378 | kfree(priv); |
380 | } | 379 | } |
381 | } | 380 | } |
@@ -601,7 +600,7 @@ static struct usb_serial_driver aircable_device = { | |||
601 | .num_ports = 1, | 600 | .num_ports = 1, |
602 | .attach = aircable_attach, | 601 | .attach = aircable_attach, |
603 | .probe = aircable_probe, | 602 | .probe = aircable_probe, |
604 | .shutdown = aircable_shutdown, | 603 | .release = aircable_release, |
605 | .write = aircable_write, | 604 | .write = aircable_write, |
606 | .write_room = aircable_write_room, | 605 | .write_room = aircable_write_room, |
607 | .write_bulk_callback = aircable_write_bulk_callback, | 606 | .write_bulk_callback = aircable_write_bulk_callback, |
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 2bfd6dd85b5a..7033b031b443 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -90,7 +90,7 @@ static int debug; | |||
90 | 90 | ||
91 | /* function prototypes for a Belkin USB Serial Adapter F5U103 */ | 91 | /* function prototypes for a Belkin USB Serial Adapter F5U103 */ |
92 | static int belkin_sa_startup(struct usb_serial *serial); | 92 | static int belkin_sa_startup(struct usb_serial *serial); |
93 | static void belkin_sa_shutdown(struct usb_serial *serial); | 93 | static void belkin_sa_release(struct usb_serial *serial); |
94 | static int belkin_sa_open(struct tty_struct *tty, | 94 | static int belkin_sa_open(struct tty_struct *tty, |
95 | struct usb_serial_port *port, struct file *filp); | 95 | struct usb_serial_port *port, struct file *filp); |
96 | static void belkin_sa_close(struct usb_serial_port *port); | 96 | static void belkin_sa_close(struct usb_serial_port *port); |
@@ -142,7 +142,7 @@ static struct usb_serial_driver belkin_device = { | |||
142 | .tiocmget = belkin_sa_tiocmget, | 142 | .tiocmget = belkin_sa_tiocmget, |
143 | .tiocmset = belkin_sa_tiocmset, | 143 | .tiocmset = belkin_sa_tiocmset, |
144 | .attach = belkin_sa_startup, | 144 | .attach = belkin_sa_startup, |
145 | .shutdown = belkin_sa_shutdown, | 145 | .release = belkin_sa_release, |
146 | }; | 146 | }; |
147 | 147 | ||
148 | 148 | ||
@@ -197,14 +197,13 @@ static int belkin_sa_startup(struct usb_serial *serial) | |||
197 | } | 197 | } |
198 | 198 | ||
199 | 199 | ||
200 | static void belkin_sa_shutdown(struct usb_serial *serial) | 200 | static void belkin_sa_release(struct usb_serial *serial) |
201 | { | 201 | { |
202 | struct belkin_sa_private *priv; | 202 | struct belkin_sa_private *priv; |
203 | int i; | 203 | int i; |
204 | 204 | ||
205 | dbg("%s", __func__); | 205 | dbg("%s", __func__); |
206 | 206 | ||
207 | /* stop reads and writes on all ports */ | ||
208 | for (i = 0; i < serial->num_ports; ++i) { | 207 | for (i = 0; i < serial->num_ports; ++i) { |
209 | /* My special items, the standard routines free my urbs */ | 208 | /* My special items, the standard routines free my urbs */ |
210 | priv = usb_get_serial_port_data(serial->port[i]); | 209 | priv = usb_get_serial_port_data(serial->port[i]); |
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index 83bbb5bca2ef..ba555c528cc6 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c | |||
@@ -59,23 +59,22 @@ static int usb_serial_device_probe(struct device *dev) | |||
59 | retval = -ENODEV; | 59 | retval = -ENODEV; |
60 | goto exit; | 60 | goto exit; |
61 | } | 61 | } |
62 | if (port->dev_state != PORT_REGISTERING) | ||
63 | goto exit; | ||
62 | 64 | ||
63 | driver = port->serial->type; | 65 | driver = port->serial->type; |
64 | if (driver->port_probe) { | 66 | if (driver->port_probe) { |
65 | if (!try_module_get(driver->driver.owner)) { | ||
66 | dev_err(dev, "module get failed, exiting\n"); | ||
67 | retval = -EIO; | ||
68 | goto exit; | ||
69 | } | ||
70 | retval = driver->port_probe(port); | 67 | retval = driver->port_probe(port); |
71 | module_put(driver->driver.owner); | ||
72 | if (retval) | 68 | if (retval) |
73 | goto exit; | 69 | goto exit; |
74 | } | 70 | } |
75 | 71 | ||
76 | retval = device_create_file(dev, &dev_attr_port_number); | 72 | retval = device_create_file(dev, &dev_attr_port_number); |
77 | if (retval) | 73 | if (retval) { |
74 | if (driver->port_remove) | ||
75 | retval = driver->port_remove(port); | ||
78 | goto exit; | 76 | goto exit; |
77 | } | ||
79 | 78 | ||
80 | minor = port->number; | 79 | minor = port->number; |
81 | tty_register_device(usb_serial_tty_driver, minor, dev); | 80 | tty_register_device(usb_serial_tty_driver, minor, dev); |
@@ -98,19 +97,15 @@ static int usb_serial_device_remove(struct device *dev) | |||
98 | if (!port) | 97 | if (!port) |
99 | return -ENODEV; | 98 | return -ENODEV; |
100 | 99 | ||
100 | if (port->dev_state != PORT_UNREGISTERING) | ||
101 | return retval; | ||
102 | |||
101 | device_remove_file(&port->dev, &dev_attr_port_number); | 103 | device_remove_file(&port->dev, &dev_attr_port_number); |
102 | 104 | ||
103 | driver = port->serial->type; | 105 | driver = port->serial->type; |
104 | if (driver->port_remove) { | 106 | if (driver->port_remove) |
105 | if (!try_module_get(driver->driver.owner)) { | ||
106 | dev_err(dev, "module get failed, exiting\n"); | ||
107 | retval = -EIO; | ||
108 | goto exit; | ||
109 | } | ||
110 | retval = driver->port_remove(port); | 107 | retval = driver->port_remove(port); |
111 | module_put(driver->driver.owner); | 108 | |
112 | } | ||
113 | exit: | ||
114 | minor = port->number; | 109 | minor = port->number; |
115 | tty_unregister_device(usb_serial_tty_driver, minor); | 110 | tty_unregister_device(usb_serial_tty_driver, minor); |
116 | dev_info(dev, "%s converter now disconnected from ttyUSB%d\n", | 111 | dev_info(dev, "%s converter now disconnected from ttyUSB%d\n", |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 16a154d3b2fe..2b9eeda62bfe 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -50,7 +50,7 @@ static int cp210x_tiocmset_port(struct usb_serial_port *port, struct file *, | |||
50 | unsigned int, unsigned int); | 50 | unsigned int, unsigned int); |
51 | static void cp210x_break_ctl(struct tty_struct *, int); | 51 | static void cp210x_break_ctl(struct tty_struct *, int); |
52 | static int cp210x_startup(struct usb_serial *); | 52 | static int cp210x_startup(struct usb_serial *); |
53 | static void cp210x_shutdown(struct usb_serial *); | 53 | static void cp210x_disconnect(struct usb_serial *); |
54 | 54 | ||
55 | static int debug; | 55 | static int debug; |
56 | 56 | ||
@@ -137,7 +137,7 @@ static struct usb_serial_driver cp210x_device = { | |||
137 | .tiocmget = cp210x_tiocmget, | 137 | .tiocmget = cp210x_tiocmget, |
138 | .tiocmset = cp210x_tiocmset, | 138 | .tiocmset = cp210x_tiocmset, |
139 | .attach = cp210x_startup, | 139 | .attach = cp210x_startup, |
140 | .shutdown = cp210x_shutdown, | 140 | .disconnect = cp210x_disconnect, |
141 | }; | 141 | }; |
142 | 142 | ||
143 | /* Config request types */ | 143 | /* Config request types */ |
@@ -792,7 +792,7 @@ static int cp210x_startup(struct usb_serial *serial) | |||
792 | return 0; | 792 | return 0; |
793 | } | 793 | } |
794 | 794 | ||
795 | static void cp210x_shutdown(struct usb_serial *serial) | 795 | static void cp210x_disconnect(struct usb_serial *serial) |
796 | { | 796 | { |
797 | int i; | 797 | int i; |
798 | 798 | ||
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 933ba913e66c..336523fd7366 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -58,7 +58,8 @@ static int debug; | |||
58 | 58 | ||
59 | /* Function prototypes */ | 59 | /* Function prototypes */ |
60 | static int cyberjack_startup(struct usb_serial *serial); | 60 | static int cyberjack_startup(struct usb_serial *serial); |
61 | static void cyberjack_shutdown(struct usb_serial *serial); | 61 | static void cyberjack_disconnect(struct usb_serial *serial); |
62 | static void cyberjack_release(struct usb_serial *serial); | ||
62 | static int cyberjack_open(struct tty_struct *tty, | 63 | static int cyberjack_open(struct tty_struct *tty, |
63 | struct usb_serial_port *port, struct file *filp); | 64 | struct usb_serial_port *port, struct file *filp); |
64 | static void cyberjack_close(struct usb_serial_port *port); | 65 | static void cyberjack_close(struct usb_serial_port *port); |
@@ -94,7 +95,8 @@ static struct usb_serial_driver cyberjack_device = { | |||
94 | .id_table = id_table, | 95 | .id_table = id_table, |
95 | .num_ports = 1, | 96 | .num_ports = 1, |
96 | .attach = cyberjack_startup, | 97 | .attach = cyberjack_startup, |
97 | .shutdown = cyberjack_shutdown, | 98 | .disconnect = cyberjack_disconnect, |
99 | .release = cyberjack_release, | ||
98 | .open = cyberjack_open, | 100 | .open = cyberjack_open, |
99 | .close = cyberjack_close, | 101 | .close = cyberjack_close, |
100 | .write = cyberjack_write, | 102 | .write = cyberjack_write, |
@@ -148,17 +150,25 @@ static int cyberjack_startup(struct usb_serial *serial) | |||
148 | return 0; | 150 | return 0; |
149 | } | 151 | } |
150 | 152 | ||
151 | static void cyberjack_shutdown(struct usb_serial *serial) | 153 | static void cyberjack_disconnect(struct usb_serial *serial) |
152 | { | 154 | { |
153 | int i; | 155 | int i; |
154 | 156 | ||
155 | dbg("%s", __func__); | 157 | dbg("%s", __func__); |
156 | 158 | ||
157 | for (i = 0; i < serial->num_ports; ++i) { | 159 | for (i = 0; i < serial->num_ports; ++i) |
158 | usb_kill_urb(serial->port[i]->interrupt_in_urb); | 160 | usb_kill_urb(serial->port[i]->interrupt_in_urb); |
161 | } | ||
162 | |||
163 | static void cyberjack_release(struct usb_serial *serial) | ||
164 | { | ||
165 | int i; | ||
166 | |||
167 | dbg("%s", __func__); | ||
168 | |||
169 | for (i = 0; i < serial->num_ports; ++i) { | ||
159 | /* My special items, the standard routines free my urbs */ | 170 | /* My special items, the standard routines free my urbs */ |
160 | kfree(usb_get_serial_port_data(serial->port[i])); | 171 | kfree(usb_get_serial_port_data(serial->port[i])); |
161 | usb_set_serial_port_data(serial->port[i], NULL); | ||
162 | } | 172 | } |
163 | } | 173 | } |
164 | 174 | ||
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 669f93848539..9734085fd2fe 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -171,7 +171,7 @@ struct cypress_buf { | |||
171 | static int cypress_earthmate_startup(struct usb_serial *serial); | 171 | static int cypress_earthmate_startup(struct usb_serial *serial); |
172 | static int cypress_hidcom_startup(struct usb_serial *serial); | 172 | static int cypress_hidcom_startup(struct usb_serial *serial); |
173 | static int cypress_ca42v2_startup(struct usb_serial *serial); | 173 | static int cypress_ca42v2_startup(struct usb_serial *serial); |
174 | static void cypress_shutdown(struct usb_serial *serial); | 174 | static void cypress_release(struct usb_serial *serial); |
175 | static int cypress_open(struct tty_struct *tty, | 175 | static int cypress_open(struct tty_struct *tty, |
176 | struct usb_serial_port *port, struct file *filp); | 176 | struct usb_serial_port *port, struct file *filp); |
177 | static void cypress_close(struct usb_serial_port *port); | 177 | static void cypress_close(struct usb_serial_port *port); |
@@ -215,7 +215,7 @@ static struct usb_serial_driver cypress_earthmate_device = { | |||
215 | .id_table = id_table_earthmate, | 215 | .id_table = id_table_earthmate, |
216 | .num_ports = 1, | 216 | .num_ports = 1, |
217 | .attach = cypress_earthmate_startup, | 217 | .attach = cypress_earthmate_startup, |
218 | .shutdown = cypress_shutdown, | 218 | .release = cypress_release, |
219 | .open = cypress_open, | 219 | .open = cypress_open, |
220 | .close = cypress_close, | 220 | .close = cypress_close, |
221 | .dtr_rts = cypress_dtr_rts, | 221 | .dtr_rts = cypress_dtr_rts, |
@@ -242,7 +242,7 @@ static struct usb_serial_driver cypress_hidcom_device = { | |||
242 | .id_table = id_table_cyphidcomrs232, | 242 | .id_table = id_table_cyphidcomrs232, |
243 | .num_ports = 1, | 243 | .num_ports = 1, |
244 | .attach = cypress_hidcom_startup, | 244 | .attach = cypress_hidcom_startup, |
245 | .shutdown = cypress_shutdown, | 245 | .release = cypress_release, |
246 | .open = cypress_open, | 246 | .open = cypress_open, |
247 | .close = cypress_close, | 247 | .close = cypress_close, |
248 | .dtr_rts = cypress_dtr_rts, | 248 | .dtr_rts = cypress_dtr_rts, |
@@ -269,7 +269,7 @@ static struct usb_serial_driver cypress_ca42v2_device = { | |||
269 | .id_table = id_table_nokiaca42v2, | 269 | .id_table = id_table_nokiaca42v2, |
270 | .num_ports = 1, | 270 | .num_ports = 1, |
271 | .attach = cypress_ca42v2_startup, | 271 | .attach = cypress_ca42v2_startup, |
272 | .shutdown = cypress_shutdown, | 272 | .release = cypress_release, |
273 | .open = cypress_open, | 273 | .open = cypress_open, |
274 | .close = cypress_close, | 274 | .close = cypress_close, |
275 | .dtr_rts = cypress_dtr_rts, | 275 | .dtr_rts = cypress_dtr_rts, |
@@ -616,7 +616,7 @@ static int cypress_ca42v2_startup(struct usb_serial *serial) | |||
616 | } /* cypress_ca42v2_startup */ | 616 | } /* cypress_ca42v2_startup */ |
617 | 617 | ||
618 | 618 | ||
619 | static void cypress_shutdown(struct usb_serial *serial) | 619 | static void cypress_release(struct usb_serial *serial) |
620 | { | 620 | { |
621 | struct cypress_private *priv; | 621 | struct cypress_private *priv; |
622 | 622 | ||
@@ -629,7 +629,6 @@ static void cypress_shutdown(struct usb_serial *serial) | |||
629 | if (priv) { | 629 | if (priv) { |
630 | cypress_buf_free(priv->buf); | 630 | cypress_buf_free(priv->buf); |
631 | kfree(priv); | 631 | kfree(priv); |
632 | usb_set_serial_port_data(serial->port[0], NULL); | ||
633 | } | 632 | } |
634 | } | 633 | } |
635 | 634 | ||
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 30f5140eff03..f4808091c47c 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -460,7 +460,8 @@ static int digi_carrier_raised(struct usb_serial_port *port); | |||
460 | static void digi_dtr_rts(struct usb_serial_port *port, int on); | 460 | static void digi_dtr_rts(struct usb_serial_port *port, int on); |
461 | static int digi_startup_device(struct usb_serial *serial); | 461 | static int digi_startup_device(struct usb_serial *serial); |
462 | static int digi_startup(struct usb_serial *serial); | 462 | static int digi_startup(struct usb_serial *serial); |
463 | static void digi_shutdown(struct usb_serial *serial); | 463 | static void digi_disconnect(struct usb_serial *serial); |
464 | static void digi_release(struct usb_serial *serial); | ||
464 | static void digi_read_bulk_callback(struct urb *urb); | 465 | static void digi_read_bulk_callback(struct urb *urb); |
465 | static int digi_read_inb_callback(struct urb *urb); | 466 | static int digi_read_inb_callback(struct urb *urb); |
466 | static int digi_read_oob_callback(struct urb *urb); | 467 | static int digi_read_oob_callback(struct urb *urb); |
@@ -524,7 +525,8 @@ static struct usb_serial_driver digi_acceleport_2_device = { | |||
524 | .tiocmget = digi_tiocmget, | 525 | .tiocmget = digi_tiocmget, |
525 | .tiocmset = digi_tiocmset, | 526 | .tiocmset = digi_tiocmset, |
526 | .attach = digi_startup, | 527 | .attach = digi_startup, |
527 | .shutdown = digi_shutdown, | 528 | .disconnect = digi_disconnect, |
529 | .release = digi_release, | ||
528 | }; | 530 | }; |
529 | 531 | ||
530 | static struct usb_serial_driver digi_acceleport_4_device = { | 532 | static struct usb_serial_driver digi_acceleport_4_device = { |
@@ -550,7 +552,8 @@ static struct usb_serial_driver digi_acceleport_4_device = { | |||
550 | .tiocmget = digi_tiocmget, | 552 | .tiocmget = digi_tiocmget, |
551 | .tiocmset = digi_tiocmset, | 553 | .tiocmset = digi_tiocmset, |
552 | .attach = digi_startup, | 554 | .attach = digi_startup, |
553 | .shutdown = digi_shutdown, | 555 | .disconnect = digi_disconnect, |
556 | .release = digi_release, | ||
554 | }; | 557 | }; |
555 | 558 | ||
556 | 559 | ||
@@ -1556,16 +1559,23 @@ static int digi_startup(struct usb_serial *serial) | |||
1556 | } | 1559 | } |
1557 | 1560 | ||
1558 | 1561 | ||
1559 | static void digi_shutdown(struct usb_serial *serial) | 1562 | static void digi_disconnect(struct usb_serial *serial) |
1560 | { | 1563 | { |
1561 | int i; | 1564 | int i; |
1562 | dbg("digi_shutdown: TOP, in_interrupt()=%ld", in_interrupt()); | 1565 | dbg("digi_disconnect: TOP, in_interrupt()=%ld", in_interrupt()); |
1563 | 1566 | ||
1564 | /* stop reads and writes on all ports */ | 1567 | /* stop reads and writes on all ports */ |
1565 | for (i = 0; i < serial->type->num_ports + 1; i++) { | 1568 | for (i = 0; i < serial->type->num_ports + 1; i++) { |
1566 | usb_kill_urb(serial->port[i]->read_urb); | 1569 | usb_kill_urb(serial->port[i]->read_urb); |
1567 | usb_kill_urb(serial->port[i]->write_urb); | 1570 | usb_kill_urb(serial->port[i]->write_urb); |
1568 | } | 1571 | } |
1572 | } | ||
1573 | |||
1574 | |||
1575 | static void digi_release(struct usb_serial *serial) | ||
1576 | { | ||
1577 | int i; | ||
1578 | dbg("digi_release: TOP, in_interrupt()=%ld", in_interrupt()); | ||
1569 | 1579 | ||
1570 | /* free the private data structures for all ports */ | 1580 | /* free the private data structures for all ports */ |
1571 | /* number of regular ports + 1 for the out-of-band port */ | 1581 | /* number of regular ports + 1 for the out-of-band port */ |
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 2b141ccb0cd9..80cb3471adbe 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c | |||
@@ -90,7 +90,6 @@ static int empeg_chars_in_buffer(struct tty_struct *tty); | |||
90 | static void empeg_throttle(struct tty_struct *tty); | 90 | static void empeg_throttle(struct tty_struct *tty); |
91 | static void empeg_unthrottle(struct tty_struct *tty); | 91 | static void empeg_unthrottle(struct tty_struct *tty); |
92 | static int empeg_startup(struct usb_serial *serial); | 92 | static int empeg_startup(struct usb_serial *serial); |
93 | static void empeg_shutdown(struct usb_serial *serial); | ||
94 | static void empeg_set_termios(struct tty_struct *tty, | 93 | static void empeg_set_termios(struct tty_struct *tty, |
95 | struct usb_serial_port *port, struct ktermios *old_termios); | 94 | struct usb_serial_port *port, struct ktermios *old_termios); |
96 | static void empeg_write_bulk_callback(struct urb *urb); | 95 | static void empeg_write_bulk_callback(struct urb *urb); |
@@ -124,7 +123,6 @@ static struct usb_serial_driver empeg_device = { | |||
124 | .throttle = empeg_throttle, | 123 | .throttle = empeg_throttle, |
125 | .unthrottle = empeg_unthrottle, | 124 | .unthrottle = empeg_unthrottle, |
126 | .attach = empeg_startup, | 125 | .attach = empeg_startup, |
127 | .shutdown = empeg_shutdown, | ||
128 | .set_termios = empeg_set_termios, | 126 | .set_termios = empeg_set_termios, |
129 | .write = empeg_write, | 127 | .write = empeg_write, |
130 | .write_room = empeg_write_room, | 128 | .write_room = empeg_write_room, |
@@ -427,12 +425,6 @@ static int empeg_startup(struct usb_serial *serial) | |||
427 | } | 425 | } |
428 | 426 | ||
429 | 427 | ||
430 | static void empeg_shutdown(struct usb_serial *serial) | ||
431 | { | ||
432 | dbg("%s", __func__); | ||
433 | } | ||
434 | |||
435 | |||
436 | static void empeg_set_termios(struct tty_struct *tty, | 428 | static void empeg_set_termios(struct tty_struct *tty, |
437 | struct usb_serial_port *port, struct ktermios *old_termios) | 429 | struct usb_serial_port *port, struct ktermios *old_termios) |
438 | { | 430 | { |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 683304d60615..3dc3768ca71c 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -47,7 +47,7 @@ | |||
47 | /* | 47 | /* |
48 | * Version Information | 48 | * Version Information |
49 | */ | 49 | */ |
50 | #define DRIVER_VERSION "v1.4.3" | 50 | #define DRIVER_VERSION "v1.5.0" |
51 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>" | 51 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>" |
52 | #define DRIVER_DESC "USB FTDI Serial Converters Driver" | 52 | #define DRIVER_DESC "USB FTDI Serial Converters Driver" |
53 | 53 | ||
@@ -82,7 +82,8 @@ struct ftdi_private { | |||
82 | int rx_processed; | 82 | int rx_processed; |
83 | unsigned long rx_bytes; | 83 | unsigned long rx_bytes; |
84 | 84 | ||
85 | __u16 interface; /* FT2232C port interface (0 for FT232/245) */ | 85 | __u16 interface; /* FT2232C, FT2232H or FT4232H port interface |
86 | (0 for FT232/245) */ | ||
86 | 87 | ||
87 | speed_t force_baud; /* if non-zero, force the baud rate to | 88 | speed_t force_baud; /* if non-zero, force the baud rate to |
88 | this value */ | 89 | this value */ |
@@ -94,6 +95,7 @@ struct ftdi_private { | |||
94 | unsigned long tx_bytes; | 95 | unsigned long tx_bytes; |
95 | unsigned long tx_outstanding_bytes; | 96 | unsigned long tx_outstanding_bytes; |
96 | unsigned long tx_outstanding_urbs; | 97 | unsigned long tx_outstanding_urbs; |
98 | unsigned short max_packet_size; | ||
97 | }; | 99 | }; |
98 | 100 | ||
99 | /* struct ftdi_sio_quirk is used by devices requiring special attention. */ | 101 | /* struct ftdi_sio_quirk is used by devices requiring special attention. */ |
@@ -164,6 +166,7 @@ static struct usb_device_id id_table_combined [] = { | |||
164 | { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, | 166 | { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, |
165 | { USB_DEVICE(FTDI_VID, FTDI_232RL_PID) }, | 167 | { USB_DEVICE(FTDI_VID, FTDI_232RL_PID) }, |
166 | { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) }, | 168 | { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) }, |
169 | { USB_DEVICE(FTDI_VID, FTDI_4232H_PID) }, | ||
167 | { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) }, | 170 | { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) }, |
168 | { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, | 171 | { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, |
169 | { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) }, | 172 | { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) }, |
@@ -673,6 +676,7 @@ static struct usb_device_id id_table_combined [] = { | |||
673 | { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) }, | 676 | { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) }, |
674 | { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID), | 677 | { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID), |
675 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 678 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
679 | { USB_DEVICE(LARSENBRUSGAARD_VID, LB_ALTITRACK_PID) }, | ||
676 | { }, /* Optional parameter entry */ | 680 | { }, /* Optional parameter entry */ |
677 | { } /* Terminating entry */ | 681 | { } /* Terminating entry */ |
678 | }; | 682 | }; |
@@ -693,12 +697,13 @@ static const char *ftdi_chip_name[] = { | |||
693 | [FT232BM] = "FT232BM", | 697 | [FT232BM] = "FT232BM", |
694 | [FT2232C] = "FT2232C", | 698 | [FT2232C] = "FT2232C", |
695 | [FT232RL] = "FT232RL", | 699 | [FT232RL] = "FT232RL", |
700 | [FT2232H] = "FT2232H", | ||
701 | [FT4232H] = "FT4232H" | ||
696 | }; | 702 | }; |
697 | 703 | ||
698 | 704 | ||
699 | /* Constants for read urb and write urb */ | 705 | /* Constants for read urb and write urb */ |
700 | #define BUFSZ 512 | 706 | #define BUFSZ 512 |
701 | #define PKTSZ 64 | ||
702 | 707 | ||
703 | /* rx_flags */ | 708 | /* rx_flags */ |
704 | #define THROTTLED 0x01 | 709 | #define THROTTLED 0x01 |
@@ -715,7 +720,6 @@ static const char *ftdi_chip_name[] = { | |||
715 | /* function prototypes for a FTDI serial converter */ | 720 | /* function prototypes for a FTDI serial converter */ |
716 | static int ftdi_sio_probe(struct usb_serial *serial, | 721 | static int ftdi_sio_probe(struct usb_serial *serial, |
717 | const struct usb_device_id *id); | 722 | const struct usb_device_id *id); |
718 | static void ftdi_shutdown(struct usb_serial *serial); | ||
719 | static int ftdi_sio_port_probe(struct usb_serial_port *port); | 723 | static int ftdi_sio_port_probe(struct usb_serial_port *port); |
720 | static int ftdi_sio_port_remove(struct usb_serial_port *port); | 724 | static int ftdi_sio_port_remove(struct usb_serial_port *port); |
721 | static int ftdi_open(struct tty_struct *tty, | 725 | static int ftdi_open(struct tty_struct *tty, |
@@ -744,6 +748,8 @@ static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base); | |||
744 | static unsigned short int ftdi_232am_baud_to_divisor(int baud); | 748 | static unsigned short int ftdi_232am_baud_to_divisor(int baud); |
745 | static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base); | 749 | static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base); |
746 | static __u32 ftdi_232bm_baud_to_divisor(int baud); | 750 | static __u32 ftdi_232bm_baud_to_divisor(int baud); |
751 | static __u32 ftdi_2232h_baud_base_to_divisor(int baud, int base); | ||
752 | static __u32 ftdi_2232h_baud_to_divisor(int baud); | ||
747 | 753 | ||
748 | static struct usb_serial_driver ftdi_sio_device = { | 754 | static struct usb_serial_driver ftdi_sio_device = { |
749 | .driver = { | 755 | .driver = { |
@@ -772,7 +778,6 @@ static struct usb_serial_driver ftdi_sio_device = { | |||
772 | .ioctl = ftdi_ioctl, | 778 | .ioctl = ftdi_ioctl, |
773 | .set_termios = ftdi_set_termios, | 779 | .set_termios = ftdi_set_termios, |
774 | .break_ctl = ftdi_break_ctl, | 780 | .break_ctl = ftdi_break_ctl, |
775 | .shutdown = ftdi_shutdown, | ||
776 | }; | 781 | }; |
777 | 782 | ||
778 | 783 | ||
@@ -838,6 +843,36 @@ static __u32 ftdi_232bm_baud_to_divisor(int baud) | |||
838 | return ftdi_232bm_baud_base_to_divisor(baud, 48000000); | 843 | return ftdi_232bm_baud_base_to_divisor(baud, 48000000); |
839 | } | 844 | } |
840 | 845 | ||
846 | static __u32 ftdi_2232h_baud_base_to_divisor(int baud, int base) | ||
847 | { | ||
848 | static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 }; | ||
849 | __u32 divisor; | ||
850 | int divisor3; | ||
851 | |||
852 | /* hi-speed baud rate is 10-bit sampling instead of 16-bit */ | ||
853 | divisor3 = (base / 10 / baud) * 8; | ||
854 | |||
855 | divisor = divisor3 >> 3; | ||
856 | divisor |= (__u32)divfrac[divisor3 & 0x7] << 14; | ||
857 | /* Deal with special cases for highest baud rates. */ | ||
858 | if (divisor == 1) | ||
859 | divisor = 0; | ||
860 | else if (divisor == 0x4001) | ||
861 | divisor = 1; | ||
862 | /* | ||
863 | * Set this bit to turn off a divide by 2.5 on baud rate generator | ||
864 | * This enables baud rates up to 12Mbaud but cannot reach below 1200 | ||
865 | * baud with this bit set | ||
866 | */ | ||
867 | divisor |= 0x00020000; | ||
868 | return divisor; | ||
869 | } | ||
870 | |||
871 | static __u32 ftdi_2232h_baud_to_divisor(int baud) | ||
872 | { | ||
873 | return ftdi_2232h_baud_base_to_divisor(baud, 120000000); | ||
874 | } | ||
875 | |||
841 | #define set_mctrl(port, set) update_mctrl((port), (set), 0) | 876 | #define set_mctrl(port, set) update_mctrl((port), (set), 0) |
842 | #define clear_mctrl(port, clear) update_mctrl((port), 0, (clear)) | 877 | #define clear_mctrl(port, clear) update_mctrl((port), 0, (clear)) |
843 | 878 | ||
@@ -996,6 +1031,19 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, | |||
996 | baud = 9600; | 1031 | baud = 9600; |
997 | } | 1032 | } |
998 | break; | 1033 | break; |
1034 | case FT2232H: /* FT2232H chip */ | ||
1035 | case FT4232H: /* FT4232H chip */ | ||
1036 | if ((baud <= 12000000) & (baud >= 1200)) { | ||
1037 | div_value = ftdi_2232h_baud_to_divisor(baud); | ||
1038 | } else if (baud < 1200) { | ||
1039 | div_value = ftdi_232bm_baud_to_divisor(baud); | ||
1040 | } else { | ||
1041 | dbg("%s - Baud rate too high!", __func__); | ||
1042 | div_value = ftdi_232bm_baud_to_divisor(9600); | ||
1043 | div_okay = 0; | ||
1044 | baud = 9600; | ||
1045 | } | ||
1046 | break; | ||
999 | } /* priv->chip_type */ | 1047 | } /* priv->chip_type */ |
1000 | 1048 | ||
1001 | if (div_okay) { | 1049 | if (div_okay) { |
@@ -1196,14 +1244,29 @@ static void ftdi_determine_type(struct usb_serial_port *port) | |||
1196 | if (interfaces > 1) { | 1244 | if (interfaces > 1) { |
1197 | int inter; | 1245 | int inter; |
1198 | 1246 | ||
1199 | /* Multiple interfaces. Assume FT2232C. */ | 1247 | /* Multiple interfaces.*/ |
1200 | priv->chip_type = FT2232C; | 1248 | if (version == 0x0800) { |
1249 | priv->chip_type = FT4232H; | ||
1250 | /* Hi-speed - baud clock runs at 120MHz */ | ||
1251 | priv->baud_base = 120000000 / 2; | ||
1252 | } else if (version == 0x0700) { | ||
1253 | priv->chip_type = FT2232H; | ||
1254 | /* Hi-speed - baud clock runs at 120MHz */ | ||
1255 | priv->baud_base = 120000000 / 2; | ||
1256 | } else | ||
1257 | priv->chip_type = FT2232C; | ||
1258 | |||
1201 | /* Determine interface code. */ | 1259 | /* Determine interface code. */ |
1202 | inter = serial->interface->altsetting->desc.bInterfaceNumber; | 1260 | inter = serial->interface->altsetting->desc.bInterfaceNumber; |
1203 | if (inter == 0) | 1261 | if (inter == 0) { |
1204 | priv->interface = PIT_SIOA; | 1262 | priv->interface = INTERFACE_A; |
1205 | else | 1263 | } else if (inter == 1) { |
1206 | priv->interface = PIT_SIOB; | 1264 | priv->interface = INTERFACE_B; |
1265 | } else if (inter == 2) { | ||
1266 | priv->interface = INTERFACE_C; | ||
1267 | } else if (inter == 3) { | ||
1268 | priv->interface = INTERFACE_D; | ||
1269 | } | ||
1207 | /* BM-type devices have a bug where bcdDevice gets set | 1270 | /* BM-type devices have a bug where bcdDevice gets set |
1208 | * to 0x200 when iSerialNumber is 0. */ | 1271 | * to 0x200 when iSerialNumber is 0. */ |
1209 | if (version < 0x500) { | 1272 | if (version < 0x500) { |
@@ -1231,6 +1294,45 @@ static void ftdi_determine_type(struct usb_serial_port *port) | |||
1231 | } | 1294 | } |
1232 | 1295 | ||
1233 | 1296 | ||
1297 | /* Determine the maximum packet size for the device. This depends on the chip | ||
1298 | * type and the USB host capabilities. The value should be obtained from the | ||
1299 | * device descriptor as the chip will use the appropriate values for the host.*/ | ||
1300 | static void ftdi_set_max_packet_size(struct usb_serial_port *port) | ||
1301 | { | ||
1302 | struct ftdi_private *priv = usb_get_serial_port_data(port); | ||
1303 | struct usb_serial *serial = port->serial; | ||
1304 | struct usb_device *udev = serial->dev; | ||
1305 | |||
1306 | struct usb_interface *interface = serial->interface; | ||
1307 | struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc; | ||
1308 | |||
1309 | unsigned num_endpoints; | ||
1310 | int i = 0; | ||
1311 | |||
1312 | num_endpoints = interface->cur_altsetting->desc.bNumEndpoints; | ||
1313 | dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints); | ||
1314 | |||
1315 | /* NOTE: some customers have programmed FT232R/FT245R devices | ||
1316 | * with an endpoint size of 0 - not good. In this case, we | ||
1317 | * want to override the endpoint descriptor setting and use a | ||
1318 | * value of 64 for wMaxPacketSize */ | ||
1319 | for (i = 0; i < num_endpoints; i++) { | ||
1320 | dev_info(&udev->dev, "Endpoint %d MaxPacketSize %d\n", i+1, | ||
1321 | interface->cur_altsetting->endpoint[i].desc.wMaxPacketSize); | ||
1322 | ep_desc = &interface->cur_altsetting->endpoint[i].desc; | ||
1323 | if (ep_desc->wMaxPacketSize == 0) { | ||
1324 | ep_desc->wMaxPacketSize = cpu_to_le16(0x40); | ||
1325 | dev_info(&udev->dev, "Overriding wMaxPacketSize on endpoint %d\n", i); | ||
1326 | } | ||
1327 | } | ||
1328 | |||
1329 | /* set max packet size based on descriptor */ | ||
1330 | priv->max_packet_size = ep_desc->wMaxPacketSize; | ||
1331 | |||
1332 | dev_info(&udev->dev, "Setting MaxPacketSize %d\n", priv->max_packet_size); | ||
1333 | } | ||
1334 | |||
1335 | |||
1234 | /* | 1336 | /* |
1235 | * *************************************************************************** | 1337 | * *************************************************************************** |
1236 | * Sysfs Attribute | 1338 | * Sysfs Attribute |
@@ -1314,7 +1416,9 @@ static int create_sysfs_attrs(struct usb_serial_port *port) | |||
1314 | if ((!retval) && | 1416 | if ((!retval) && |
1315 | (priv->chip_type == FT232BM || | 1417 | (priv->chip_type == FT232BM || |
1316 | priv->chip_type == FT2232C || | 1418 | priv->chip_type == FT2232C || |
1317 | priv->chip_type == FT232RL)) { | 1419 | priv->chip_type == FT232RL || |
1420 | priv->chip_type == FT2232H || | ||
1421 | priv->chip_type == FT4232H)) { | ||
1318 | retval = device_create_file(&port->dev, | 1422 | retval = device_create_file(&port->dev, |
1319 | &dev_attr_latency_timer); | 1423 | &dev_attr_latency_timer); |
1320 | } | 1424 | } |
@@ -1333,7 +1437,9 @@ static void remove_sysfs_attrs(struct usb_serial_port *port) | |||
1333 | device_remove_file(&port->dev, &dev_attr_event_char); | 1437 | device_remove_file(&port->dev, &dev_attr_event_char); |
1334 | if (priv->chip_type == FT232BM || | 1438 | if (priv->chip_type == FT232BM || |
1335 | priv->chip_type == FT2232C || | 1439 | priv->chip_type == FT2232C || |
1336 | priv->chip_type == FT232RL) { | 1440 | priv->chip_type == FT232RL || |
1441 | priv->chip_type == FT2232H || | ||
1442 | priv->chip_type == FT4232H) { | ||
1337 | device_remove_file(&port->dev, &dev_attr_latency_timer); | 1443 | device_remove_file(&port->dev, &dev_attr_latency_timer); |
1338 | } | 1444 | } |
1339 | } | 1445 | } |
@@ -1416,6 +1522,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) | |||
1416 | usb_set_serial_port_data(port, priv); | 1522 | usb_set_serial_port_data(port, priv); |
1417 | 1523 | ||
1418 | ftdi_determine_type(port); | 1524 | ftdi_determine_type(port); |
1525 | ftdi_set_max_packet_size(port); | ||
1419 | read_latency_timer(port); | 1526 | read_latency_timer(port); |
1420 | create_sysfs_attrs(port); | 1527 | create_sysfs_attrs(port); |
1421 | return 0; | 1528 | return 0; |
@@ -1485,18 +1592,6 @@ static int ftdi_mtxorb_hack_setup(struct usb_serial *serial) | |||
1485 | return 0; | 1592 | return 0; |
1486 | } | 1593 | } |
1487 | 1594 | ||
1488 | /* ftdi_shutdown is called from usbserial:usb_serial_disconnect | ||
1489 | * it is called when the usb device is disconnected | ||
1490 | * | ||
1491 | * usbserial:usb_serial_disconnect | ||
1492 | * calls __serial_close for each open of the port | ||
1493 | * shutdown is called then (ie ftdi_shutdown) | ||
1494 | */ | ||
1495 | static void ftdi_shutdown(struct usb_serial *serial) | ||
1496 | { | ||
1497 | dbg("%s", __func__); | ||
1498 | } | ||
1499 | |||
1500 | static void ftdi_sio_priv_release(struct kref *k) | 1595 | static void ftdi_sio_priv_release(struct kref *k) |
1501 | { | 1596 | { |
1502 | struct ftdi_private *priv = container_of(k, struct ftdi_private, kref); | 1597 | struct ftdi_private *priv = container_of(k, struct ftdi_private, kref); |
@@ -1671,8 +1766,8 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1671 | if (data_offset > 0) { | 1766 | if (data_offset > 0) { |
1672 | /* Original sio needs control bytes too... */ | 1767 | /* Original sio needs control bytes too... */ |
1673 | transfer_size += (data_offset * | 1768 | transfer_size += (data_offset * |
1674 | ((count + (PKTSZ - 1 - data_offset)) / | 1769 | ((count + (priv->max_packet_size - 1 - data_offset)) / |
1675 | (PKTSZ - data_offset))); | 1770 | (priv->max_packet_size - data_offset))); |
1676 | } | 1771 | } |
1677 | 1772 | ||
1678 | buffer = kmalloc(transfer_size, GFP_ATOMIC); | 1773 | buffer = kmalloc(transfer_size, GFP_ATOMIC); |
@@ -1694,7 +1789,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1694 | if (data_offset > 0) { | 1789 | if (data_offset > 0) { |
1695 | /* Original sio requires control byte at start of | 1790 | /* Original sio requires control byte at start of |
1696 | each packet. */ | 1791 | each packet. */ |
1697 | int user_pktsz = PKTSZ - data_offset; | 1792 | int user_pktsz = priv->max_packet_size - data_offset; |
1698 | int todo = count; | 1793 | int todo = count; |
1699 | unsigned char *first_byte = buffer; | 1794 | unsigned char *first_byte = buffer; |
1700 | const unsigned char *current_position = buf; | 1795 | const unsigned char *current_position = buf; |
@@ -1775,11 +1870,6 @@ static void ftdi_write_bulk_callback(struct urb *urb) | |||
1775 | 1870 | ||
1776 | dbg("%s - port %d", __func__, port->number); | 1871 | dbg("%s - port %d", __func__, port->number); |
1777 | 1872 | ||
1778 | if (status) { | ||
1779 | dbg("nonzero write bulk status received: %d", status); | ||
1780 | return; | ||
1781 | } | ||
1782 | |||
1783 | priv = usb_get_serial_port_data(port); | 1873 | priv = usb_get_serial_port_data(port); |
1784 | if (!priv) { | 1874 | if (!priv) { |
1785 | dbg("%s - bad port private data pointer - exiting", __func__); | 1875 | dbg("%s - bad port private data pointer - exiting", __func__); |
@@ -1790,13 +1880,18 @@ static void ftdi_write_bulk_callback(struct urb *urb) | |||
1790 | data_offset = priv->write_offset; | 1880 | data_offset = priv->write_offset; |
1791 | if (data_offset > 0) { | 1881 | if (data_offset > 0) { |
1792 | /* Subtract the control bytes */ | 1882 | /* Subtract the control bytes */ |
1793 | countback -= (data_offset * DIV_ROUND_UP(countback, PKTSZ)); | 1883 | countback -= (data_offset * DIV_ROUND_UP(countback, priv->max_packet_size)); |
1794 | } | 1884 | } |
1795 | spin_lock_irqsave(&priv->tx_lock, flags); | 1885 | spin_lock_irqsave(&priv->tx_lock, flags); |
1796 | --priv->tx_outstanding_urbs; | 1886 | --priv->tx_outstanding_urbs; |
1797 | priv->tx_outstanding_bytes -= countback; | 1887 | priv->tx_outstanding_bytes -= countback; |
1798 | spin_unlock_irqrestore(&priv->tx_lock, flags); | 1888 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
1799 | 1889 | ||
1890 | if (status) { | ||
1891 | dbg("nonzero write bulk status received: %d", status); | ||
1892 | return; | ||
1893 | } | ||
1894 | |||
1800 | usb_serial_port_softint(port); | 1895 | usb_serial_port_softint(port); |
1801 | } /* ftdi_write_bulk_callback */ | 1896 | } /* ftdi_write_bulk_callback */ |
1802 | 1897 | ||
@@ -1892,7 +1987,7 @@ static void ftdi_read_bulk_callback(struct urb *urb) | |||
1892 | 1987 | ||
1893 | /* count data bytes, but not status bytes */ | 1988 | /* count data bytes, but not status bytes */ |
1894 | countread = urb->actual_length; | 1989 | countread = urb->actual_length; |
1895 | countread -= 2 * DIV_ROUND_UP(countread, PKTSZ); | 1990 | countread -= 2 * DIV_ROUND_UP(countread, priv->max_packet_size); |
1896 | spin_lock_irqsave(&priv->rx_lock, flags); | 1991 | spin_lock_irqsave(&priv->rx_lock, flags); |
1897 | priv->rx_bytes += countread; | 1992 | priv->rx_bytes += countread; |
1898 | spin_unlock_irqrestore(&priv->rx_lock, flags); | 1993 | spin_unlock_irqrestore(&priv->rx_lock, flags); |
@@ -1965,7 +2060,7 @@ static void ftdi_process_read(struct work_struct *work) | |||
1965 | 2060 | ||
1966 | need_flip = 0; | 2061 | need_flip = 0; |
1967 | for (packet_offset = priv->rx_processed; | 2062 | for (packet_offset = priv->rx_processed; |
1968 | packet_offset < urb->actual_length; packet_offset += PKTSZ) { | 2063 | packet_offset < urb->actual_length; packet_offset += priv->max_packet_size) { |
1969 | int length; | 2064 | int length; |
1970 | 2065 | ||
1971 | /* Compare new line status to the old one, signal if different/ | 2066 | /* Compare new line status to the old one, signal if different/ |
@@ -1980,7 +2075,7 @@ static void ftdi_process_read(struct work_struct *work) | |||
1980 | priv->prev_status = new_status; | 2075 | priv->prev_status = new_status; |
1981 | } | 2076 | } |
1982 | 2077 | ||
1983 | length = min_t(u32, PKTSZ, urb->actual_length-packet_offset)-2; | 2078 | length = min_t(u32, priv->max_packet_size, urb->actual_length-packet_offset)-2; |
1984 | if (length < 0) { | 2079 | if (length < 0) { |
1985 | dev_err(&port->dev, "%s - bad packet length: %d\n", | 2080 | dev_err(&port->dev, "%s - bad packet length: %d\n", |
1986 | __func__, length+2); | 2081 | __func__, length+2); |
@@ -2011,6 +2106,7 @@ static void ftdi_process_read(struct work_struct *work) | |||
2011 | if (data[packet_offset+1] & FTDI_RS_BI) { | 2106 | if (data[packet_offset+1] & FTDI_RS_BI) { |
2012 | error_flag = TTY_BREAK; | 2107 | error_flag = TTY_BREAK; |
2013 | dbg("BREAK received"); | 2108 | dbg("BREAK received"); |
2109 | usb_serial_handle_break(port); | ||
2014 | } | 2110 | } |
2015 | if (data[packet_offset+1] & FTDI_RS_PE) { | 2111 | if (data[packet_offset+1] & FTDI_RS_PE) { |
2016 | error_flag = TTY_PARITY; | 2112 | error_flag = TTY_PARITY; |
@@ -2025,8 +2121,11 @@ static void ftdi_process_read(struct work_struct *work) | |||
2025 | /* Note that the error flag is duplicated for | 2121 | /* Note that the error flag is duplicated for |
2026 | every character received since we don't know | 2122 | every character received since we don't know |
2027 | which character it applied to */ | 2123 | which character it applied to */ |
2028 | tty_insert_flip_char(tty, | 2124 | if (!usb_serial_handle_sysrq_char(port, |
2029 | data[packet_offset + i], error_flag); | 2125 | data[packet_offset + i])) |
2126 | tty_insert_flip_char(tty, | ||
2127 | data[packet_offset + i], | ||
2128 | error_flag); | ||
2030 | } | 2129 | } |
2031 | need_flip = 1; | 2130 | need_flip = 1; |
2032 | } | 2131 | } |
@@ -2332,6 +2431,8 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file) | |||
2332 | case FT232BM: | 2431 | case FT232BM: |
2333 | case FT2232C: | 2432 | case FT2232C: |
2334 | case FT232RL: | 2433 | case FT232RL: |
2434 | case FT2232H: | ||
2435 | case FT4232H: | ||
2335 | /* the 8U232AM returns a two byte value (the sio is a 1 byte | 2436 | /* the 8U232AM returns a two byte value (the sio is a 1 byte |
2336 | value) - in the same format as the data returned from the in | 2437 | value) - in the same format as the data returned from the in |
2337 | point */ | 2438 | point */ |
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 12330fa1c095..f1d440a728a3 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h | |||
@@ -10,7 +10,7 @@ | |||
10 | * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side, | 10 | * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side, |
11 | * USB on the other. | 11 | * USB on the other. |
12 | * | 12 | * |
13 | * Thanx to FTDI (http://www.ftdi.co.uk) for so kindly providing details | 13 | * Thanx to FTDI (http://www.ftdichip.com) for so kindly providing details |
14 | * of the protocol required to talk to the device and ongoing assistence | 14 | * of the protocol required to talk to the device and ongoing assistence |
15 | * during development. | 15 | * during development. |
16 | * | 16 | * |
@@ -28,11 +28,15 @@ | |||
28 | #define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */ | 28 | #define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */ |
29 | #define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ | 29 | #define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ |
30 | #define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */ | 30 | #define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */ |
31 | #define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */ | ||
31 | #define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */ | 32 | #define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */ |
32 | #define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */ | 33 | #define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */ |
33 | #define FTDI_NF_RIC_PID 0x0001 /* Product Id */ | 34 | #define FTDI_NF_RIC_PID 0x0001 /* Product Id */ |
34 | #define FTDI_USBX_707_PID 0xF857 /* ADSTech IR Blaster USBX-707 */ | 35 | #define FTDI_USBX_707_PID 0xF857 /* ADSTech IR Blaster USBX-707 */ |
35 | 36 | ||
37 | /* Larsen and Brusgaard AltiTrack/USBtrack */ | ||
38 | #define LARSENBRUSGAARD_VID 0x0FD8 | ||
39 | #define LB_ALTITRACK_PID 0x0001 | ||
36 | 40 | ||
37 | /* www.canusb.com Lawicel CANUSB device */ | 41 | /* www.canusb.com Lawicel CANUSB device */ |
38 | #define FTDI_CANUSB_PID 0xFFA8 /* Product Id */ | 42 | #define FTDI_CANUSB_PID 0xFFA8 /* Product Id */ |
@@ -873,6 +877,11 @@ | |||
873 | #define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */ | 877 | #define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */ |
874 | #define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */ | 878 | #define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */ |
875 | 879 | ||
880 | /* Interface indicies for FT2232, FT2232H and FT4232H devices*/ | ||
881 | #define INTERFACE_A 1 | ||
882 | #define INTERFACE_B 2 | ||
883 | #define INTERFACE_C 3 | ||
884 | #define INTERFACE_D 4 | ||
876 | 885 | ||
877 | /* | 886 | /* |
878 | * FIC / OpenMoko, Inc. http://wiki.openmoko.org/wiki/Neo1973_Debug_Board_v3 | 887 | * FIC / OpenMoko, Inc. http://wiki.openmoko.org/wiki/Neo1973_Debug_Board_v3 |
@@ -1036,6 +1045,8 @@ typedef enum { | |||
1036 | FT232BM = 3, | 1045 | FT232BM = 3, |
1037 | FT2232C = 4, | 1046 | FT2232C = 4, |
1038 | FT232RL = 5, | 1047 | FT232RL = 5, |
1048 | FT2232H = 6, | ||
1049 | FT4232H = 7 | ||
1039 | } ftdi_chip_type_t; | 1050 | } ftdi_chip_type_t; |
1040 | 1051 | ||
1041 | typedef enum { | 1052 | typedef enum { |
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index ee25a3fe3b09..8839f1c70b7f 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Garmin GPS driver | 2 | * Garmin GPS driver |
3 | * | 3 | * |
4 | * Copyright (C) 2006,2007 Hermann Kneissel herkne@users.sourceforge.net | 4 | * Copyright (C) 2006-2009 Hermann Kneissel herkne@users.sourceforge.net |
5 | * | 5 | * |
6 | * The latest version of the driver can be found at | 6 | * The latest version of the driver can be found at |
7 | * http://sourceforge.net/projects/garmin-gps/ | 7 | * http://sourceforge.net/projects/garmin-gps/ |
@@ -51,7 +51,7 @@ static int debug; | |||
51 | */ | 51 | */ |
52 | 52 | ||
53 | #define VERSION_MAJOR 0 | 53 | #define VERSION_MAJOR 0 |
54 | #define VERSION_MINOR 31 | 54 | #define VERSION_MINOR 33 |
55 | 55 | ||
56 | #define _STR(s) #s | 56 | #define _STR(s) #s |
57 | #define _DRIVER_VERSION(a, b) "v" _STR(a) "." _STR(b) | 57 | #define _DRIVER_VERSION(a, b) "v" _STR(a) "." _STR(b) |
@@ -129,7 +129,6 @@ struct garmin_data { | |||
129 | __u8 state; | 129 | __u8 state; |
130 | __u16 flags; | 130 | __u16 flags; |
131 | __u8 mode; | 131 | __u8 mode; |
132 | __u8 ignorePkts; | ||
133 | __u8 count; | 132 | __u8 count; |
134 | __u8 pkt_id; | 133 | __u8 pkt_id; |
135 | __u32 serial_num; | 134 | __u32 serial_num; |
@@ -141,8 +140,6 @@ struct garmin_data { | |||
141 | __u8 inbuffer [GPS_IN_BUFSIZ]; /* tty -> usb */ | 140 | __u8 inbuffer [GPS_IN_BUFSIZ]; /* tty -> usb */ |
142 | __u8 outbuffer[GPS_OUT_BUFSIZ]; /* usb -> tty */ | 141 | __u8 outbuffer[GPS_OUT_BUFSIZ]; /* usb -> tty */ |
143 | __u8 privpkt[4*6]; | 142 | __u8 privpkt[4*6]; |
144 | atomic_t req_count; | ||
145 | atomic_t resp_count; | ||
146 | spinlock_t lock; | 143 | spinlock_t lock; |
147 | struct list_head pktlist; | 144 | struct list_head pktlist; |
148 | }; | 145 | }; |
@@ -170,6 +167,8 @@ struct garmin_data { | |||
170 | #define FLAGS_BULK_IN_ACTIVE 0x0020 | 167 | #define FLAGS_BULK_IN_ACTIVE 0x0020 |
171 | #define FLAGS_BULK_IN_RESTART 0x0010 | 168 | #define FLAGS_BULK_IN_RESTART 0x0010 |
172 | #define FLAGS_THROTTLED 0x0008 | 169 | #define FLAGS_THROTTLED 0x0008 |
170 | #define APP_REQ_SEEN 0x0004 | ||
171 | #define APP_RESP_SEEN 0x0002 | ||
173 | #define CLEAR_HALT_REQUIRED 0x0001 | 172 | #define CLEAR_HALT_REQUIRED 0x0001 |
174 | 173 | ||
175 | #define FLAGS_QUEUING 0x0100 | 174 | #define FLAGS_QUEUING 0x0100 |
@@ -184,20 +183,16 @@ struct garmin_data { | |||
184 | 183 | ||
185 | 184 | ||
186 | /* function prototypes */ | 185 | /* function prototypes */ |
187 | static void gsp_next_packet(struct garmin_data *garmin_data_p); | 186 | static int gsp_next_packet(struct garmin_data *garmin_data_p); |
188 | static int garmin_write_bulk(struct usb_serial_port *port, | 187 | static int garmin_write_bulk(struct usb_serial_port *port, |
189 | const unsigned char *buf, int count, | 188 | const unsigned char *buf, int count, |
190 | int dismiss_ack); | 189 | int dismiss_ack); |
191 | 190 | ||
192 | /* some special packets to be send or received */ | 191 | /* some special packets to be send or received */ |
193 | static unsigned char const GARMIN_START_SESSION_REQ[] | 192 | static unsigned char const GARMIN_START_SESSION_REQ[] |
194 | = { 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0 }; | 193 | = { 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0 }; |
195 | static unsigned char const GARMIN_START_SESSION_REQ2[] | ||
196 | = { 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0 }; | ||
197 | static unsigned char const GARMIN_START_SESSION_REPLY[] | 194 | static unsigned char const GARMIN_START_SESSION_REPLY[] |
198 | = { 0, 0, 0, 0, 6, 0, 0, 0, 4, 0, 0, 0 }; | 195 | = { 0, 0, 0, 0, 6, 0, 0, 0, 4, 0, 0, 0 }; |
199 | static unsigned char const GARMIN_SESSION_ACTIVE_REPLY[] | ||
200 | = { 0, 0, 0, 0, 17, 0, 0, 0, 4, 0, 0, 0, 0, 16, 0, 0 }; | ||
201 | static unsigned char const GARMIN_BULK_IN_AVAIL_REPLY[] | 196 | static unsigned char const GARMIN_BULK_IN_AVAIL_REPLY[] |
202 | = { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0 }; | 197 | = { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0 }; |
203 | static unsigned char const GARMIN_APP_LAYER_REPLY[] | 198 | static unsigned char const GARMIN_APP_LAYER_REPLY[] |
@@ -233,13 +228,6 @@ static struct usb_driver garmin_driver = { | |||
233 | }; | 228 | }; |
234 | 229 | ||
235 | 230 | ||
236 | static inline int noResponseFromAppLayer(struct garmin_data *garmin_data_p) | ||
237 | { | ||
238 | return atomic_read(&garmin_data_p->req_count) == | ||
239 | atomic_read(&garmin_data_p->resp_count); | ||
240 | } | ||
241 | |||
242 | |||
243 | static inline int getLayerId(const __u8 *usbPacket) | 231 | static inline int getLayerId(const __u8 *usbPacket) |
244 | { | 232 | { |
245 | return __le32_to_cpup((__le32 *)(usbPacket)); | 233 | return __le32_to_cpup((__le32 *)(usbPacket)); |
@@ -325,8 +313,11 @@ static int pkt_add(struct garmin_data *garmin_data_p, | |||
325 | state = garmin_data_p->state; | 313 | state = garmin_data_p->state; |
326 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 314 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
327 | 315 | ||
316 | dbg("%s - added: pkt: %d - %d bytes", | ||
317 | __func__, pkt->seq, data_length); | ||
318 | |||
328 | /* in serial mode, if someone is waiting for data from | 319 | /* in serial mode, if someone is waiting for data from |
329 | the device, iconvert and send the next packet to tty. */ | 320 | the device, convert and send the next packet to tty. */ |
330 | if (result && (state == STATE_GSP_WAIT_DATA)) | 321 | if (result && (state == STATE_GSP_WAIT_DATA)) |
331 | gsp_next_packet(garmin_data_p); | 322 | gsp_next_packet(garmin_data_p); |
332 | } | 323 | } |
@@ -411,7 +402,7 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id) | |||
411 | /* | 402 | /* |
412 | * called for a complete packet received from tty layer | 403 | * called for a complete packet received from tty layer |
413 | * | 404 | * |
414 | * the complete packet (pkzid ... cksum) is in garmin_data_p->inbuf starting | 405 | * the complete packet (pktid ... cksum) is in garmin_data_p->inbuf starting |
415 | * at GSP_INITIAL_OFFSET. | 406 | * at GSP_INITIAL_OFFSET. |
416 | * | 407 | * |
417 | * count - number of bytes in the input buffer including space reserved for | 408 | * count - number of bytes in the input buffer including space reserved for |
@@ -501,7 +492,6 @@ static int gsp_receive(struct garmin_data *garmin_data_p, | |||
501 | unsigned long flags; | 492 | unsigned long flags; |
502 | int offs = 0; | 493 | int offs = 0; |
503 | int ack_or_nak_seen = 0; | 494 | int ack_or_nak_seen = 0; |
504 | int i = 0; | ||
505 | __u8 *dest; | 495 | __u8 *dest; |
506 | int size; | 496 | int size; |
507 | /* dleSeen: set if last byte read was a DLE */ | 497 | /* dleSeen: set if last byte read was a DLE */ |
@@ -519,8 +509,8 @@ static int gsp_receive(struct garmin_data *garmin_data_p, | |||
519 | skip = garmin_data_p->flags & FLAGS_GSP_SKIP; | 509 | skip = garmin_data_p->flags & FLAGS_GSP_SKIP; |
520 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 510 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
521 | 511 | ||
522 | dbg("%s - dle=%d skip=%d size=%d count=%d", | 512 | /* dbg("%s - dle=%d skip=%d size=%d count=%d", |
523 | __func__, dleSeen, skip, size, count); | 513 | __func__, dleSeen, skip, size, count); */ |
524 | 514 | ||
525 | if (size == 0) | 515 | if (size == 0) |
526 | size = GSP_INITIAL_OFFSET; | 516 | size = GSP_INITIAL_OFFSET; |
@@ -568,7 +558,6 @@ static int gsp_receive(struct garmin_data *garmin_data_p, | |||
568 | } else if (!skip) { | 558 | } else if (!skip) { |
569 | 559 | ||
570 | if (dleSeen) { | 560 | if (dleSeen) { |
571 | dbg("non-masked DLE at %d - restarting", i); | ||
572 | size = GSP_INITIAL_OFFSET; | 561 | size = GSP_INITIAL_OFFSET; |
573 | dleSeen = 0; | 562 | dleSeen = 0; |
574 | } | 563 | } |
@@ -599,19 +588,19 @@ static int gsp_receive(struct garmin_data *garmin_data_p, | |||
599 | else | 588 | else |
600 | garmin_data_p->flags &= ~FLAGS_GSP_DLESEEN; | 589 | garmin_data_p->flags &= ~FLAGS_GSP_DLESEEN; |
601 | 590 | ||
602 | if (ack_or_nak_seen) | ||
603 | garmin_data_p->state = STATE_GSP_WAIT_DATA; | ||
604 | |||
605 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 591 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
606 | 592 | ||
607 | if (ack_or_nak_seen) | 593 | if (ack_or_nak_seen) { |
608 | gsp_next_packet(garmin_data_p); | 594 | if (gsp_next_packet(garmin_data_p) > 0) |
595 | garmin_data_p->state = STATE_ACTIVE; | ||
596 | else | ||
597 | garmin_data_p->state = STATE_GSP_WAIT_DATA; | ||
598 | } | ||
609 | return count; | 599 | return count; |
610 | } | 600 | } |
611 | 601 | ||
612 | 602 | ||
613 | 603 | ||
614 | |||
615 | /* | 604 | /* |
616 | * Sends a usb packet to the tty | 605 | * Sends a usb packet to the tty |
617 | * | 606 | * |
@@ -733,29 +722,28 @@ static int gsp_send(struct garmin_data *garmin_data_p, | |||
733 | } | 722 | } |
734 | 723 | ||
735 | 724 | ||
736 | |||
737 | |||
738 | |||
739 | /* | 725 | /* |
740 | * Process the next pending data packet - if there is one | 726 | * Process the next pending data packet - if there is one |
741 | */ | 727 | */ |
742 | static void gsp_next_packet(struct garmin_data *garmin_data_p) | 728 | static int gsp_next_packet(struct garmin_data *garmin_data_p) |
743 | { | 729 | { |
730 | int result = 0; | ||
744 | struct garmin_packet *pkt = NULL; | 731 | struct garmin_packet *pkt = NULL; |
745 | 732 | ||
746 | while ((pkt = pkt_pop(garmin_data_p)) != NULL) { | 733 | while ((pkt = pkt_pop(garmin_data_p)) != NULL) { |
747 | dbg("%s - next pkt: %d", __func__, pkt->seq); | 734 | dbg("%s - next pkt: %d", __func__, pkt->seq); |
748 | if (gsp_send(garmin_data_p, pkt->data, pkt->size) > 0) { | 735 | result = gsp_send(garmin_data_p, pkt->data, pkt->size); |
736 | if (result > 0) { | ||
749 | kfree(pkt); | 737 | kfree(pkt); |
750 | return; | 738 | return result; |
751 | } | 739 | } |
752 | kfree(pkt); | 740 | kfree(pkt); |
753 | } | 741 | } |
742 | return result; | ||
754 | } | 743 | } |
755 | 744 | ||
756 | 745 | ||
757 | 746 | ||
758 | |||
759 | /****************************************************************************** | 747 | /****************************************************************************** |
760 | * garmin native mode | 748 | * garmin native mode |
761 | ******************************************************************************/ | 749 | ******************************************************************************/ |
@@ -888,14 +876,6 @@ static int garmin_clear(struct garmin_data *garmin_data_p) | |||
888 | unsigned long flags; | 876 | unsigned long flags; |
889 | int status = 0; | 877 | int status = 0; |
890 | 878 | ||
891 | struct usb_serial_port *port = garmin_data_p->port; | ||
892 | |||
893 | if (port != NULL && atomic_read(&garmin_data_p->resp_count)) { | ||
894 | /* send a terminate command */ | ||
895 | status = garmin_write_bulk(port, GARMIN_STOP_TRANSFER_REQ, | ||
896 | sizeof(GARMIN_STOP_TRANSFER_REQ), 1); | ||
897 | } | ||
898 | |||
899 | /* flush all queued data */ | 879 | /* flush all queued data */ |
900 | pkt_clear(garmin_data_p); | 880 | pkt_clear(garmin_data_p); |
901 | 881 | ||
@@ -908,16 +888,12 @@ static int garmin_clear(struct garmin_data *garmin_data_p) | |||
908 | } | 888 | } |
909 | 889 | ||
910 | 890 | ||
911 | |||
912 | |||
913 | |||
914 | |||
915 | static int garmin_init_session(struct usb_serial_port *port) | 891 | static int garmin_init_session(struct usb_serial_port *port) |
916 | { | 892 | { |
917 | unsigned long flags; | ||
918 | struct usb_serial *serial = port->serial; | 893 | struct usb_serial *serial = port->serial; |
919 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); | 894 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); |
920 | int status = 0; | 895 | int status = 0; |
896 | int i = 0; | ||
921 | 897 | ||
922 | if (status == 0) { | 898 | if (status == 0) { |
923 | usb_kill_urb(port->interrupt_in_urb); | 899 | usb_kill_urb(port->interrupt_in_urb); |
@@ -931,30 +907,25 @@ static int garmin_init_session(struct usb_serial_port *port) | |||
931 | __func__, status); | 907 | __func__, status); |
932 | } | 908 | } |
933 | 909 | ||
910 | /* | ||
911 | * using the initialization method from gpsbabel. See comments in | ||
912 | * gpsbabel/jeeps/gpslibusb.c gusb_reset_toggles() | ||
913 | */ | ||
934 | if (status == 0) { | 914 | if (status == 0) { |
935 | dbg("%s - starting session ...", __func__); | 915 | dbg("%s - starting session ...", __func__); |
936 | garmin_data_p->state = STATE_ACTIVE; | 916 | garmin_data_p->state = STATE_ACTIVE; |
937 | status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ, | ||
938 | sizeof(GARMIN_START_SESSION_REQ), 0); | ||
939 | |||
940 | if (status >= 0) { | ||
941 | |||
942 | spin_lock_irqsave(&garmin_data_p->lock, flags); | ||
943 | garmin_data_p->ignorePkts++; | ||
944 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | ||
945 | 917 | ||
946 | /* not needed, but the win32 driver does it too ... */ | 918 | for (i = 0; i < 3; i++) { |
947 | status = garmin_write_bulk(port, | 919 | status = garmin_write_bulk(port, |
948 | GARMIN_START_SESSION_REQ2, | 920 | GARMIN_START_SESSION_REQ, |
949 | sizeof(GARMIN_START_SESSION_REQ2), 0); | 921 | sizeof(GARMIN_START_SESSION_REQ), 0); |
950 | if (status >= 0) { | 922 | |
951 | status = 0; | 923 | if (status < 0) |
952 | spin_lock_irqsave(&garmin_data_p->lock, flags); | 924 | break; |
953 | garmin_data_p->ignorePkts++; | ||
954 | spin_unlock_irqrestore(&garmin_data_p->lock, | ||
955 | flags); | ||
956 | } | ||
957 | } | 925 | } |
926 | |||
927 | if (status > 0) | ||
928 | status = 0; | ||
958 | } | 929 | } |
959 | 930 | ||
960 | return status; | 931 | return status; |
@@ -962,8 +933,6 @@ static int garmin_init_session(struct usb_serial_port *port) | |||
962 | 933 | ||
963 | 934 | ||
964 | 935 | ||
965 | |||
966 | |||
967 | static int garmin_open(struct tty_struct *tty, | 936 | static int garmin_open(struct tty_struct *tty, |
968 | struct usb_serial_port *port, struct file *filp) | 937 | struct usb_serial_port *port, struct file *filp) |
969 | { | 938 | { |
@@ -977,8 +946,6 @@ static int garmin_open(struct tty_struct *tty, | |||
977 | garmin_data_p->mode = initial_mode; | 946 | garmin_data_p->mode = initial_mode; |
978 | garmin_data_p->count = 0; | 947 | garmin_data_p->count = 0; |
979 | garmin_data_p->flags = 0; | 948 | garmin_data_p->flags = 0; |
980 | atomic_set(&garmin_data_p->req_count, 0); | ||
981 | atomic_set(&garmin_data_p->resp_count, 0); | ||
982 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 949 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
983 | 950 | ||
984 | /* shutdown any bulk reads that might be going on */ | 951 | /* shutdown any bulk reads that might be going on */ |
@@ -1006,6 +973,7 @@ static void garmin_close(struct usb_serial_port *port) | |||
1006 | return; | 973 | return; |
1007 | 974 | ||
1008 | mutex_lock(&port->serial->disc_mutex); | 975 | mutex_lock(&port->serial->disc_mutex); |
976 | |||
1009 | if (!port->serial->disconnected) | 977 | if (!port->serial->disconnected) |
1010 | garmin_clear(garmin_data_p); | 978 | garmin_clear(garmin_data_p); |
1011 | 979 | ||
@@ -1013,25 +981,17 @@ static void garmin_close(struct usb_serial_port *port) | |||
1013 | usb_kill_urb(port->read_urb); | 981 | usb_kill_urb(port->read_urb); |
1014 | usb_kill_urb(port->write_urb); | 982 | usb_kill_urb(port->write_urb); |
1015 | 983 | ||
1016 | if (!port->serial->disconnected) { | 984 | /* keep reset state so we know that we must start a new session */ |
1017 | if (noResponseFromAppLayer(garmin_data_p) || | 985 | if (garmin_data_p->state != STATE_RESET) |
1018 | ((garmin_data_p->flags & CLEAR_HALT_REQUIRED) != 0)) { | ||
1019 | process_resetdev_request(port); | ||
1020 | garmin_data_p->state = STATE_RESET; | ||
1021 | } else { | ||
1022 | garmin_data_p->state = STATE_DISCONNECTED; | ||
1023 | } | ||
1024 | } else { | ||
1025 | garmin_data_p->state = STATE_DISCONNECTED; | 986 | garmin_data_p->state = STATE_DISCONNECTED; |
1026 | } | 987 | |
1027 | mutex_unlock(&port->serial->disc_mutex); | 988 | mutex_unlock(&port->serial->disc_mutex); |
1028 | } | 989 | } |
1029 | 990 | ||
991 | |||
1030 | static void garmin_write_bulk_callback(struct urb *urb) | 992 | static void garmin_write_bulk_callback(struct urb *urb) |
1031 | { | 993 | { |
1032 | unsigned long flags; | ||
1033 | struct usb_serial_port *port = urb->context; | 994 | struct usb_serial_port *port = urb->context; |
1034 | int status = urb->status; | ||
1035 | 995 | ||
1036 | if (port) { | 996 | if (port) { |
1037 | struct garmin_data *garmin_data_p = | 997 | struct garmin_data *garmin_data_p = |
@@ -1039,20 +999,13 @@ static void garmin_write_bulk_callback(struct urb *urb) | |||
1039 | 999 | ||
1040 | dbg("%s - port %d", __func__, port->number); | 1000 | dbg("%s - port %d", __func__, port->number); |
1041 | 1001 | ||
1042 | if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer) | 1002 | if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer)) { |
1043 | && (garmin_data_p->mode == MODE_GARMIN_SERIAL)) { | ||
1044 | gsp_send_ack(garmin_data_p, | ||
1045 | ((__u8 *)urb->transfer_buffer)[4]); | ||
1046 | } | ||
1047 | 1003 | ||
1048 | if (status) { | 1004 | if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { |
1049 | dbg("%s - nonzero write bulk status received: %d", | 1005 | gsp_send_ack(garmin_data_p, |
1050 | __func__, status); | 1006 | ((__u8 *)urb->transfer_buffer)[4]); |
1051 | spin_lock_irqsave(&garmin_data_p->lock, flags); | 1007 | } |
1052 | garmin_data_p->flags |= CLEAR_HALT_REQUIRED; | ||
1053 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | ||
1054 | } | 1008 | } |
1055 | |||
1056 | usb_serial_port_softint(port); | 1009 | usb_serial_port_softint(port); |
1057 | } | 1010 | } |
1058 | 1011 | ||
@@ -1108,7 +1061,11 @@ static int garmin_write_bulk(struct usb_serial_port *port, | |||
1108 | urb->transfer_flags |= URB_ZERO_PACKET; | 1061 | urb->transfer_flags |= URB_ZERO_PACKET; |
1109 | 1062 | ||
1110 | if (GARMIN_LAYERID_APPL == getLayerId(buffer)) { | 1063 | if (GARMIN_LAYERID_APPL == getLayerId(buffer)) { |
1111 | atomic_inc(&garmin_data_p->req_count); | 1064 | |
1065 | spin_lock_irqsave(&garmin_data_p->lock, flags); | ||
1066 | garmin_data_p->flags |= APP_REQ_SEEN; | ||
1067 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | ||
1068 | |||
1112 | if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { | 1069 | if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { |
1113 | pkt_clear(garmin_data_p); | 1070 | pkt_clear(garmin_data_p); |
1114 | garmin_data_p->state = STATE_GSP_WAIT_DATA; | 1071 | garmin_data_p->state = STATE_GSP_WAIT_DATA; |
@@ -1140,6 +1097,9 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1140 | 1097 | ||
1141 | usb_serial_debug_data(debug, &port->dev, __func__, count, buf); | 1098 | usb_serial_debug_data(debug, &port->dev, __func__, count, buf); |
1142 | 1099 | ||
1100 | if (garmin_data_p->state == STATE_RESET) | ||
1101 | return -EIO; | ||
1102 | |||
1143 | /* check for our private packets */ | 1103 | /* check for our private packets */ |
1144 | if (count >= GARMIN_PKTHDR_LENGTH) { | 1104 | if (count >= GARMIN_PKTHDR_LENGTH) { |
1145 | len = PRIVPKTSIZ; | 1105 | len = PRIVPKTSIZ; |
@@ -1184,7 +1144,7 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1184 | break; | 1144 | break; |
1185 | 1145 | ||
1186 | case PRIV_PKTID_RESET_REQ: | 1146 | case PRIV_PKTID_RESET_REQ: |
1187 | atomic_inc(&garmin_data_p->req_count); | 1147 | process_resetdev_request(port); |
1188 | break; | 1148 | break; |
1189 | 1149 | ||
1190 | case PRIV_PKTID_SET_DEF_MODE: | 1150 | case PRIV_PKTID_SET_DEF_MODE: |
@@ -1200,8 +1160,6 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1200 | } | 1160 | } |
1201 | } | 1161 | } |
1202 | 1162 | ||
1203 | garmin_data_p->ignorePkts = 0; | ||
1204 | |||
1205 | if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { | 1163 | if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { |
1206 | return gsp_receive(garmin_data_p, buf, count); | 1164 | return gsp_receive(garmin_data_p, buf, count); |
1207 | } else { /* MODE_NATIVE */ | 1165 | } else { /* MODE_NATIVE */ |
@@ -1224,31 +1182,33 @@ static int garmin_write_room(struct tty_struct *tty) | |||
1224 | static void garmin_read_process(struct garmin_data *garmin_data_p, | 1182 | static void garmin_read_process(struct garmin_data *garmin_data_p, |
1225 | unsigned char *data, unsigned data_length) | 1183 | unsigned char *data, unsigned data_length) |
1226 | { | 1184 | { |
1185 | unsigned long flags; | ||
1186 | |||
1227 | if (garmin_data_p->flags & FLAGS_DROP_DATA) { | 1187 | if (garmin_data_p->flags & FLAGS_DROP_DATA) { |
1228 | /* abort-transfer cmd is actice */ | 1188 | /* abort-transfer cmd is actice */ |
1229 | dbg("%s - pkt dropped", __func__); | 1189 | dbg("%s - pkt dropped", __func__); |
1230 | } else if (garmin_data_p->state != STATE_DISCONNECTED && | 1190 | } else if (garmin_data_p->state != STATE_DISCONNECTED && |
1231 | garmin_data_p->state != STATE_RESET) { | 1191 | garmin_data_p->state != STATE_RESET) { |
1232 | 1192 | ||
1233 | /* remember any appl.layer packets, so we know | ||
1234 | if a reset is required or not when closing | ||
1235 | the device */ | ||
1236 | if (0 == memcmp(data, GARMIN_APP_LAYER_REPLY, | ||
1237 | sizeof(GARMIN_APP_LAYER_REPLY))) { | ||
1238 | atomic_inc(&garmin_data_p->resp_count); | ||
1239 | } | ||
1240 | |||
1241 | /* if throttling is active or postprecessing is required | 1193 | /* if throttling is active or postprecessing is required |
1242 | put the received data in the input queue, otherwise | 1194 | put the received data in the input queue, otherwise |
1243 | send it directly to the tty port */ | 1195 | send it directly to the tty port */ |
1244 | if (garmin_data_p->flags & FLAGS_QUEUING) { | 1196 | if (garmin_data_p->flags & FLAGS_QUEUING) { |
1245 | pkt_add(garmin_data_p, data, data_length); | 1197 | pkt_add(garmin_data_p, data, data_length); |
1246 | } else if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { | 1198 | } else if (getLayerId(data) == GARMIN_LAYERID_APPL) { |
1247 | if (getLayerId(data) == GARMIN_LAYERID_APPL) | 1199 | |
1200 | spin_lock_irqsave(&garmin_data_p->lock, flags); | ||
1201 | garmin_data_p->flags |= APP_RESP_SEEN; | ||
1202 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | ||
1203 | |||
1204 | if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { | ||
1248 | pkt_add(garmin_data_p, data, data_length); | 1205 | pkt_add(garmin_data_p, data, data_length); |
1249 | } else { | 1206 | } else { |
1250 | send_to_tty(garmin_data_p->port, data, data_length); | 1207 | send_to_tty(garmin_data_p->port, data, |
1208 | data_length); | ||
1209 | } | ||
1251 | } | 1210 | } |
1211 | /* ignore system layer packets ... */ | ||
1252 | } | 1212 | } |
1253 | } | 1213 | } |
1254 | 1214 | ||
@@ -1363,8 +1323,6 @@ static void garmin_read_int_callback(struct urb *urb) | |||
1363 | } else { | 1323 | } else { |
1364 | spin_lock_irqsave(&garmin_data_p->lock, flags); | 1324 | spin_lock_irqsave(&garmin_data_p->lock, flags); |
1365 | garmin_data_p->flags |= FLAGS_BULK_IN_ACTIVE; | 1325 | garmin_data_p->flags |= FLAGS_BULK_IN_ACTIVE; |
1366 | /* do not send this packet to the user */ | ||
1367 | garmin_data_p->ignorePkts = 1; | ||
1368 | spin_unlock_irqrestore(&garmin_data_p->lock, | 1326 | spin_unlock_irqrestore(&garmin_data_p->lock, |
1369 | flags); | 1327 | flags); |
1370 | } | 1328 | } |
@@ -1391,17 +1349,7 @@ static void garmin_read_int_callback(struct urb *urb) | |||
1391 | __func__, garmin_data_p->serial_num); | 1349 | __func__, garmin_data_p->serial_num); |
1392 | } | 1350 | } |
1393 | 1351 | ||
1394 | if (garmin_data_p->ignorePkts) { | 1352 | garmin_read_process(garmin_data_p, data, urb->actual_length); |
1395 | /* this reply belongs to a request generated by the driver, | ||
1396 | ignore it. */ | ||
1397 | dbg("%s - pkt ignored (%d)", | ||
1398 | __func__, garmin_data_p->ignorePkts); | ||
1399 | spin_lock_irqsave(&garmin_data_p->lock, flags); | ||
1400 | garmin_data_p->ignorePkts--; | ||
1401 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | ||
1402 | } else { | ||
1403 | garmin_read_process(garmin_data_p, data, urb->actual_length); | ||
1404 | } | ||
1405 | 1353 | ||
1406 | port->interrupt_in_urb->dev = port->serial->dev; | 1354 | port->interrupt_in_urb->dev = port->serial->dev; |
1407 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 1355 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -1527,7 +1475,7 @@ static int garmin_attach(struct usb_serial *serial) | |||
1527 | } | 1475 | } |
1528 | 1476 | ||
1529 | 1477 | ||
1530 | static void garmin_shutdown(struct usb_serial *serial) | 1478 | static void garmin_disconnect(struct usb_serial *serial) |
1531 | { | 1479 | { |
1532 | struct usb_serial_port *port = serial->port[0]; | 1480 | struct usb_serial_port *port = serial->port[0]; |
1533 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); | 1481 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); |
@@ -1536,8 +1484,17 @@ static void garmin_shutdown(struct usb_serial *serial) | |||
1536 | 1484 | ||
1537 | usb_kill_urb(port->interrupt_in_urb); | 1485 | usb_kill_urb(port->interrupt_in_urb); |
1538 | del_timer_sync(&garmin_data_p->timer); | 1486 | del_timer_sync(&garmin_data_p->timer); |
1487 | } | ||
1488 | |||
1489 | |||
1490 | static void garmin_release(struct usb_serial *serial) | ||
1491 | { | ||
1492 | struct usb_serial_port *port = serial->port[0]; | ||
1493 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); | ||
1494 | |||
1495 | dbg("%s", __func__); | ||
1496 | |||
1539 | kfree(garmin_data_p); | 1497 | kfree(garmin_data_p); |
1540 | usb_set_serial_port_data(port, NULL); | ||
1541 | } | 1498 | } |
1542 | 1499 | ||
1543 | 1500 | ||
@@ -1556,7 +1513,8 @@ static struct usb_serial_driver garmin_device = { | |||
1556 | .throttle = garmin_throttle, | 1513 | .throttle = garmin_throttle, |
1557 | .unthrottle = garmin_unthrottle, | 1514 | .unthrottle = garmin_unthrottle, |
1558 | .attach = garmin_attach, | 1515 | .attach = garmin_attach, |
1559 | .shutdown = garmin_shutdown, | 1516 | .disconnect = garmin_disconnect, |
1517 | .release = garmin_release, | ||
1560 | .write = garmin_write, | 1518 | .write = garmin_write, |
1561 | .write_room = garmin_write_room, | 1519 | .write_room = garmin_write_room, |
1562 | .write_bulk_callback = garmin_write_bulk_callback, | 1520 | .write_bulk_callback = garmin_write_bulk_callback, |
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index be82ea956720..932d6241b787 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -63,7 +63,8 @@ struct usb_serial_driver usb_serial_generic_device = { | |||
63 | .id_table = generic_device_ids, | 63 | .id_table = generic_device_ids, |
64 | .usb_driver = &generic_driver, | 64 | .usb_driver = &generic_driver, |
65 | .num_ports = 1, | 65 | .num_ports = 1, |
66 | .shutdown = usb_serial_generic_shutdown, | 66 | .disconnect = usb_serial_generic_disconnect, |
67 | .release = usb_serial_generic_release, | ||
67 | .throttle = usb_serial_generic_throttle, | 68 | .throttle = usb_serial_generic_throttle, |
68 | .unthrottle = usb_serial_generic_unthrottle, | 69 | .unthrottle = usb_serial_generic_unthrottle, |
69 | .resume = usb_serial_generic_resume, | 70 | .resume = usb_serial_generic_resume, |
@@ -190,6 +191,88 @@ void usb_serial_generic_close(struct usb_serial_port *port) | |||
190 | generic_cleanup(port); | 191 | generic_cleanup(port); |
191 | } | 192 | } |
192 | 193 | ||
194 | static int usb_serial_multi_urb_write(struct tty_struct *tty, | ||
195 | struct usb_serial_port *port, const unsigned char *buf, int count) | ||
196 | { | ||
197 | unsigned long flags; | ||
198 | struct urb *urb; | ||
199 | unsigned char *buffer; | ||
200 | int status; | ||
201 | int towrite; | ||
202 | int bwrite = 0; | ||
203 | |||
204 | dbg("%s - port %d", __func__, port->number); | ||
205 | |||
206 | if (count == 0) | ||
207 | dbg("%s - write request of 0 bytes", __func__); | ||
208 | |||
209 | while (count > 0) { | ||
210 | towrite = (count > port->bulk_out_size) ? | ||
211 | port->bulk_out_size : count; | ||
212 | spin_lock_irqsave(&port->lock, flags); | ||
213 | if (port->urbs_in_flight > | ||
214 | port->serial->type->max_in_flight_urbs) { | ||
215 | spin_unlock_irqrestore(&port->lock, flags); | ||
216 | dbg("%s - write limit hit\n", __func__); | ||
217 | return bwrite; | ||
218 | } | ||
219 | port->tx_bytes_flight += towrite; | ||
220 | port->urbs_in_flight++; | ||
221 | spin_unlock_irqrestore(&port->lock, flags); | ||
222 | |||
223 | buffer = kmalloc(towrite, GFP_ATOMIC); | ||
224 | if (!buffer) { | ||
225 | dev_err(&port->dev, | ||
226 | "%s ran out of kernel memory for urb ...\n", __func__); | ||
227 | goto error_no_buffer; | ||
228 | } | ||
229 | |||
230 | urb = usb_alloc_urb(0, GFP_ATOMIC); | ||
231 | if (!urb) { | ||
232 | dev_err(&port->dev, "%s - no more free urbs\n", | ||
233 | __func__); | ||
234 | goto error_no_urb; | ||
235 | } | ||
236 | |||
237 | /* Copy data */ | ||
238 | memcpy(buffer, buf + bwrite, towrite); | ||
239 | usb_serial_debug_data(debug, &port->dev, __func__, | ||
240 | towrite, buffer); | ||
241 | /* fill the buffer and send it */ | ||
242 | usb_fill_bulk_urb(urb, port->serial->dev, | ||
243 | usb_sndbulkpipe(port->serial->dev, | ||
244 | port->bulk_out_endpointAddress), | ||
245 | buffer, towrite, | ||
246 | usb_serial_generic_write_bulk_callback, port); | ||
247 | |||
248 | status = usb_submit_urb(urb, GFP_ATOMIC); | ||
249 | if (status) { | ||
250 | dev_err(&port->dev, | ||
251 | "%s - failed submitting write urb, error %d\n", | ||
252 | __func__, status); | ||
253 | goto error; | ||
254 | } | ||
255 | |||
256 | /* This urb is the responsibility of the host driver now */ | ||
257 | usb_free_urb(urb); | ||
258 | dbg("%s write: %d", __func__, towrite); | ||
259 | count -= towrite; | ||
260 | bwrite += towrite; | ||
261 | } | ||
262 | return bwrite; | ||
263 | |||
264 | error: | ||
265 | usb_free_urb(urb); | ||
266 | error_no_urb: | ||
267 | kfree(buffer); | ||
268 | error_no_buffer: | ||
269 | spin_lock_irqsave(&port->lock, flags); | ||
270 | port->urbs_in_flight--; | ||
271 | port->tx_bytes_flight -= towrite; | ||
272 | spin_unlock_irqrestore(&port->lock, flags); | ||
273 | return bwrite; | ||
274 | } | ||
275 | |||
193 | int usb_serial_generic_write(struct tty_struct *tty, | 276 | int usb_serial_generic_write(struct tty_struct *tty, |
194 | struct usb_serial_port *port, const unsigned char *buf, int count) | 277 | struct usb_serial_port *port, const unsigned char *buf, int count) |
195 | { | 278 | { |
@@ -207,6 +290,11 @@ int usb_serial_generic_write(struct tty_struct *tty, | |||
207 | /* only do something if we have a bulk out endpoint */ | 290 | /* only do something if we have a bulk out endpoint */ |
208 | if (serial->num_bulk_out) { | 291 | if (serial->num_bulk_out) { |
209 | unsigned long flags; | 292 | unsigned long flags; |
293 | |||
294 | if (serial->type->max_in_flight_urbs) | ||
295 | return usb_serial_multi_urb_write(tty, port, | ||
296 | buf, count); | ||
297 | |||
210 | spin_lock_irqsave(&port->lock, flags); | 298 | spin_lock_irqsave(&port->lock, flags); |
211 | if (port->write_urb_busy) { | 299 | if (port->write_urb_busy) { |
212 | spin_unlock_irqrestore(&port->lock, flags); | 300 | spin_unlock_irqrestore(&port->lock, flags); |
@@ -252,20 +340,26 @@ int usb_serial_generic_write(struct tty_struct *tty, | |||
252 | /* no bulk out, so return 0 bytes written */ | 340 | /* no bulk out, so return 0 bytes written */ |
253 | return 0; | 341 | return 0; |
254 | } | 342 | } |
343 | EXPORT_SYMBOL_GPL(usb_serial_generic_write); | ||
255 | 344 | ||
256 | int usb_serial_generic_write_room(struct tty_struct *tty) | 345 | int usb_serial_generic_write_room(struct tty_struct *tty) |
257 | { | 346 | { |
258 | struct usb_serial_port *port = tty->driver_data; | 347 | struct usb_serial_port *port = tty->driver_data; |
259 | struct usb_serial *serial = port->serial; | 348 | struct usb_serial *serial = port->serial; |
349 | unsigned long flags; | ||
260 | int room = 0; | 350 | int room = 0; |
261 | 351 | ||
262 | dbg("%s - port %d", __func__, port->number); | 352 | dbg("%s - port %d", __func__, port->number); |
263 | 353 | spin_lock_irqsave(&port->lock, flags); | |
264 | /* FIXME: Locking */ | 354 | if (serial->type->max_in_flight_urbs) { |
265 | if (serial->num_bulk_out) { | 355 | if (port->urbs_in_flight < serial->type->max_in_flight_urbs) |
266 | if (!(port->write_urb_busy)) | 356 | room = port->bulk_out_size * |
267 | room = port->bulk_out_size; | 357 | (serial->type->max_in_flight_urbs - |
358 | port->urbs_in_flight); | ||
359 | } else if (serial->num_bulk_out && !(port->write_urb_busy)) { | ||
360 | room = port->bulk_out_size; | ||
268 | } | 361 | } |
362 | spin_unlock_irqrestore(&port->lock, flags); | ||
269 | 363 | ||
270 | dbg("%s - returns %d", __func__, room); | 364 | dbg("%s - returns %d", __func__, room); |
271 | return room; | 365 | return room; |
@@ -276,11 +370,16 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty) | |||
276 | struct usb_serial_port *port = tty->driver_data; | 370 | struct usb_serial_port *port = tty->driver_data; |
277 | struct usb_serial *serial = port->serial; | 371 | struct usb_serial *serial = port->serial; |
278 | int chars = 0; | 372 | int chars = 0; |
373 | unsigned long flags; | ||
279 | 374 | ||
280 | dbg("%s - port %d", __func__, port->number); | 375 | dbg("%s - port %d", __func__, port->number); |
281 | 376 | ||
282 | /* FIXME: Locking */ | 377 | if (serial->type->max_in_flight_urbs) { |
283 | if (serial->num_bulk_out) { | 378 | spin_lock_irqsave(&port->lock, flags); |
379 | chars = port->tx_bytes_flight; | ||
380 | spin_unlock_irqrestore(&port->lock, flags); | ||
381 | } else if (serial->num_bulk_out) { | ||
382 | /* FIXME: Locking */ | ||
284 | if (port->write_urb_busy) | 383 | if (port->write_urb_busy) |
285 | chars = port->write_urb->transfer_buffer_length; | 384 | chars = port->write_urb->transfer_buffer_length; |
286 | } | 385 | } |
@@ -290,7 +389,8 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty) | |||
290 | } | 389 | } |
291 | 390 | ||
292 | 391 | ||
293 | static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags) | 392 | void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port, |
393 | gfp_t mem_flags) | ||
294 | { | 394 | { |
295 | struct urb *urb = port->read_urb; | 395 | struct urb *urb = port->read_urb; |
296 | struct usb_serial *serial = port->serial; | 396 | struct usb_serial *serial = port->serial; |
@@ -311,25 +411,28 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags) | |||
311 | "%s - failed resubmitting read urb, error %d\n", | 411 | "%s - failed resubmitting read urb, error %d\n", |
312 | __func__, result); | 412 | __func__, result); |
313 | } | 413 | } |
414 | EXPORT_SYMBOL_GPL(usb_serial_generic_resubmit_read_urb); | ||
314 | 415 | ||
315 | /* Push data to tty layer and resubmit the bulk read URB */ | 416 | /* Push data to tty layer and resubmit the bulk read URB */ |
316 | static void flush_and_resubmit_read_urb(struct usb_serial_port *port) | 417 | static void flush_and_resubmit_read_urb(struct usb_serial_port *port) |
317 | { | 418 | { |
318 | struct urb *urb = port->read_urb; | 419 | struct urb *urb = port->read_urb; |
319 | struct tty_struct *tty = tty_port_tty_get(&port->port); | 420 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
320 | int room; | 421 | char *ch = (char *)urb->transfer_buffer; |
422 | int i; | ||
423 | |||
424 | if (!tty) | ||
425 | goto done; | ||
321 | 426 | ||
322 | /* Push data to tty */ | 427 | /* Push data to tty */ |
323 | if (tty && urb->actual_length) { | 428 | for (i = 0; i < urb->actual_length; i++, ch++) { |
324 | room = tty_buffer_request_room(tty, urb->actual_length); | 429 | if (!usb_serial_handle_sysrq_char(port, *ch)) |
325 | if (room) { | 430 | tty_insert_flip_char(tty, *ch, TTY_NORMAL); |
326 | tty_insert_flip_string(tty, urb->transfer_buffer, room); | ||
327 | tty_flip_buffer_push(tty); | ||
328 | } | ||
329 | } | 431 | } |
432 | tty_flip_buffer_push(tty); | ||
330 | tty_kref_put(tty); | 433 | tty_kref_put(tty); |
331 | 434 | done: | |
332 | resubmit_read_urb(port, GFP_ATOMIC); | 435 | usb_serial_generic_resubmit_read_urb(port, GFP_ATOMIC); |
333 | } | 436 | } |
334 | 437 | ||
335 | void usb_serial_generic_read_bulk_callback(struct urb *urb) | 438 | void usb_serial_generic_read_bulk_callback(struct urb *urb) |
@@ -363,12 +466,24 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback); | |||
363 | 466 | ||
364 | void usb_serial_generic_write_bulk_callback(struct urb *urb) | 467 | void usb_serial_generic_write_bulk_callback(struct urb *urb) |
365 | { | 468 | { |
469 | unsigned long flags; | ||
366 | struct usb_serial_port *port = urb->context; | 470 | struct usb_serial_port *port = urb->context; |
367 | int status = urb->status; | 471 | int status = urb->status; |
368 | 472 | ||
369 | dbg("%s - port %d", __func__, port->number); | 473 | dbg("%s - port %d", __func__, port->number); |
370 | 474 | ||
371 | port->write_urb_busy = 0; | 475 | if (port->serial->type->max_in_flight_urbs) { |
476 | spin_lock_irqsave(&port->lock, flags); | ||
477 | --port->urbs_in_flight; | ||
478 | port->tx_bytes_flight -= urb->transfer_buffer_length; | ||
479 | if (port->urbs_in_flight < 0) | ||
480 | port->urbs_in_flight = 0; | ||
481 | spin_unlock_irqrestore(&port->lock, flags); | ||
482 | } else { | ||
483 | /* Handle the case for single urb mode */ | ||
484 | port->write_urb_busy = 0; | ||
485 | } | ||
486 | |||
372 | if (status) { | 487 | if (status) { |
373 | dbg("%s - nonzero write bulk status received: %d", | 488 | dbg("%s - nonzero write bulk status received: %d", |
374 | __func__, status); | 489 | __func__, status); |
@@ -408,11 +523,36 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty) | |||
408 | 523 | ||
409 | if (was_throttled) { | 524 | if (was_throttled) { |
410 | /* Resume reading from device */ | 525 | /* Resume reading from device */ |
411 | resubmit_read_urb(port, GFP_KERNEL); | 526 | usb_serial_generic_resubmit_read_urb(port, GFP_KERNEL); |
527 | } | ||
528 | } | ||
529 | |||
530 | int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) | ||
531 | { | ||
532 | if (port->sysrq && port->console) { | ||
533 | if (ch && time_before(jiffies, port->sysrq)) { | ||
534 | handle_sysrq(ch, tty_port_tty_get(&port->port)); | ||
535 | port->sysrq = 0; | ||
536 | return 1; | ||
537 | } | ||
538 | port->sysrq = 0; | ||
539 | } | ||
540 | return 0; | ||
541 | } | ||
542 | EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char); | ||
543 | |||
544 | int usb_serial_handle_break(struct usb_serial_port *port) | ||
545 | { | ||
546 | if (!port->sysrq) { | ||
547 | port->sysrq = jiffies + HZ*5; | ||
548 | return 1; | ||
412 | } | 549 | } |
550 | port->sysrq = 0; | ||
551 | return 0; | ||
413 | } | 552 | } |
553 | EXPORT_SYMBOL_GPL(usb_serial_handle_break); | ||
414 | 554 | ||
415 | void usb_serial_generic_shutdown(struct usb_serial *serial) | 555 | void usb_serial_generic_disconnect(struct usb_serial *serial) |
416 | { | 556 | { |
417 | int i; | 557 | int i; |
418 | 558 | ||
@@ -423,3 +563,7 @@ void usb_serial_generic_shutdown(struct usb_serial *serial) | |||
423 | generic_cleanup(serial->port[i]); | 563 | generic_cleanup(serial->port[i]); |
424 | } | 564 | } |
425 | 565 | ||
566 | void usb_serial_generic_release(struct usb_serial *serial) | ||
567 | { | ||
568 | dbg("%s", __func__); | ||
569 | } | ||
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 53ef5996e33d..0191693625d6 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -224,7 +224,8 @@ static int edge_tiocmget(struct tty_struct *tty, struct file *file); | |||
224 | static int edge_tiocmset(struct tty_struct *tty, struct file *file, | 224 | static int edge_tiocmset(struct tty_struct *tty, struct file *file, |
225 | unsigned int set, unsigned int clear); | 225 | unsigned int set, unsigned int clear); |
226 | static int edge_startup(struct usb_serial *serial); | 226 | static int edge_startup(struct usb_serial *serial); |
227 | static void edge_shutdown(struct usb_serial *serial); | 227 | static void edge_disconnect(struct usb_serial *serial); |
228 | static void edge_release(struct usb_serial *serial); | ||
228 | 229 | ||
229 | #include "io_tables.h" /* all of the devices that this driver supports */ | 230 | #include "io_tables.h" /* all of the devices that this driver supports */ |
230 | 231 | ||
@@ -3193,21 +3194,16 @@ static int edge_startup(struct usb_serial *serial) | |||
3193 | 3194 | ||
3194 | 3195 | ||
3195 | /**************************************************************************** | 3196 | /**************************************************************************** |
3196 | * edge_shutdown | 3197 | * edge_disconnect |
3197 | * This function is called whenever the device is removed from the usb bus. | 3198 | * This function is called whenever the device is removed from the usb bus. |
3198 | ****************************************************************************/ | 3199 | ****************************************************************************/ |
3199 | static void edge_shutdown(struct usb_serial *serial) | 3200 | static void edge_disconnect(struct usb_serial *serial) |
3200 | { | 3201 | { |
3201 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); | 3202 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); |
3202 | int i; | ||
3203 | 3203 | ||
3204 | dbg("%s", __func__); | 3204 | dbg("%s", __func__); |
3205 | 3205 | ||
3206 | /* stop reads and writes on all ports */ | 3206 | /* stop reads and writes on all ports */ |
3207 | for (i = 0; i < serial->num_ports; ++i) { | ||
3208 | kfree(usb_get_serial_port_data(serial->port[i])); | ||
3209 | usb_set_serial_port_data(serial->port[i], NULL); | ||
3210 | } | ||
3211 | /* free up our endpoint stuff */ | 3207 | /* free up our endpoint stuff */ |
3212 | if (edge_serial->is_epic) { | 3208 | if (edge_serial->is_epic) { |
3213 | usb_kill_urb(edge_serial->interrupt_read_urb); | 3209 | usb_kill_urb(edge_serial->interrupt_read_urb); |
@@ -3218,9 +3214,24 @@ static void edge_shutdown(struct usb_serial *serial) | |||
3218 | usb_free_urb(edge_serial->read_urb); | 3214 | usb_free_urb(edge_serial->read_urb); |
3219 | kfree(edge_serial->bulk_in_buffer); | 3215 | kfree(edge_serial->bulk_in_buffer); |
3220 | } | 3216 | } |
3217 | } | ||
3218 | |||
3219 | |||
3220 | /**************************************************************************** | ||
3221 | * edge_release | ||
3222 | * This function is called when the device structure is deallocated. | ||
3223 | ****************************************************************************/ | ||
3224 | static void edge_release(struct usb_serial *serial) | ||
3225 | { | ||
3226 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); | ||
3227 | int i; | ||
3228 | |||
3229 | dbg("%s", __func__); | ||
3230 | |||
3231 | for (i = 0; i < serial->num_ports; ++i) | ||
3232 | kfree(usb_get_serial_port_data(serial->port[i])); | ||
3221 | 3233 | ||
3222 | kfree(edge_serial); | 3234 | kfree(edge_serial); |
3223 | usb_set_serial_data(serial, NULL); | ||
3224 | } | 3235 | } |
3225 | 3236 | ||
3226 | 3237 | ||
diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h index 7eb9d67b81b6..9241d3147513 100644 --- a/drivers/usb/serial/io_tables.h +++ b/drivers/usb/serial/io_tables.h | |||
@@ -117,7 +117,8 @@ static struct usb_serial_driver edgeport_2port_device = { | |||
117 | .throttle = edge_throttle, | 117 | .throttle = edge_throttle, |
118 | .unthrottle = edge_unthrottle, | 118 | .unthrottle = edge_unthrottle, |
119 | .attach = edge_startup, | 119 | .attach = edge_startup, |
120 | .shutdown = edge_shutdown, | 120 | .disconnect = edge_disconnect, |
121 | .release = edge_release, | ||
121 | .ioctl = edge_ioctl, | 122 | .ioctl = edge_ioctl, |
122 | .set_termios = edge_set_termios, | 123 | .set_termios = edge_set_termios, |
123 | .tiocmget = edge_tiocmget, | 124 | .tiocmget = edge_tiocmget, |
@@ -145,7 +146,8 @@ static struct usb_serial_driver edgeport_4port_device = { | |||
145 | .throttle = edge_throttle, | 146 | .throttle = edge_throttle, |
146 | .unthrottle = edge_unthrottle, | 147 | .unthrottle = edge_unthrottle, |
147 | .attach = edge_startup, | 148 | .attach = edge_startup, |
148 | .shutdown = edge_shutdown, | 149 | .disconnect = edge_disconnect, |
150 | .release = edge_release, | ||
149 | .ioctl = edge_ioctl, | 151 | .ioctl = edge_ioctl, |
150 | .set_termios = edge_set_termios, | 152 | .set_termios = edge_set_termios, |
151 | .tiocmget = edge_tiocmget, | 153 | .tiocmget = edge_tiocmget, |
@@ -173,7 +175,8 @@ static struct usb_serial_driver edgeport_8port_device = { | |||
173 | .throttle = edge_throttle, | 175 | .throttle = edge_throttle, |
174 | .unthrottle = edge_unthrottle, | 176 | .unthrottle = edge_unthrottle, |
175 | .attach = edge_startup, | 177 | .attach = edge_startup, |
176 | .shutdown = edge_shutdown, | 178 | .disconnect = edge_disconnect, |
179 | .release = edge_release, | ||
177 | .ioctl = edge_ioctl, | 180 | .ioctl = edge_ioctl, |
178 | .set_termios = edge_set_termios, | 181 | .set_termios = edge_set_termios, |
179 | .tiocmget = edge_tiocmget, | 182 | .tiocmget = edge_tiocmget, |
@@ -200,7 +203,8 @@ static struct usb_serial_driver epic_device = { | |||
200 | .throttle = edge_throttle, | 203 | .throttle = edge_throttle, |
201 | .unthrottle = edge_unthrottle, | 204 | .unthrottle = edge_unthrottle, |
202 | .attach = edge_startup, | 205 | .attach = edge_startup, |
203 | .shutdown = edge_shutdown, | 206 | .disconnect = edge_disconnect, |
207 | .release = edge_release, | ||
204 | .ioctl = edge_ioctl, | 208 | .ioctl = edge_ioctl, |
205 | .set_termios = edge_set_termios, | 209 | .set_termios = edge_set_termios, |
206 | .tiocmget = edge_tiocmget, | 210 | .tiocmget = edge_tiocmget, |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index db964db42d3c..e8bc42f92e79 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -2663,7 +2663,7 @@ cleanup: | |||
2663 | return -ENOMEM; | 2663 | return -ENOMEM; |
2664 | } | 2664 | } |
2665 | 2665 | ||
2666 | static void edge_shutdown(struct usb_serial *serial) | 2666 | static void edge_disconnect(struct usb_serial *serial) |
2667 | { | 2667 | { |
2668 | int i; | 2668 | int i; |
2669 | struct edgeport_port *edge_port; | 2669 | struct edgeport_port *edge_port; |
@@ -2673,12 +2673,22 @@ static void edge_shutdown(struct usb_serial *serial) | |||
2673 | for (i = 0; i < serial->num_ports; ++i) { | 2673 | for (i = 0; i < serial->num_ports; ++i) { |
2674 | edge_port = usb_get_serial_port_data(serial->port[i]); | 2674 | edge_port = usb_get_serial_port_data(serial->port[i]); |
2675 | edge_remove_sysfs_attrs(edge_port->port); | 2675 | edge_remove_sysfs_attrs(edge_port->port); |
2676 | } | ||
2677 | } | ||
2678 | |||
2679 | static void edge_release(struct usb_serial *serial) | ||
2680 | { | ||
2681 | int i; | ||
2682 | struct edgeport_port *edge_port; | ||
2683 | |||
2684 | dbg("%s", __func__); | ||
2685 | |||
2686 | for (i = 0; i < serial->num_ports; ++i) { | ||
2687 | edge_port = usb_get_serial_port_data(serial->port[i]); | ||
2676 | edge_buf_free(edge_port->ep_out_buf); | 2688 | edge_buf_free(edge_port->ep_out_buf); |
2677 | kfree(edge_port); | 2689 | kfree(edge_port); |
2678 | usb_set_serial_port_data(serial->port[i], NULL); | ||
2679 | } | 2690 | } |
2680 | kfree(usb_get_serial_data(serial)); | 2691 | kfree(usb_get_serial_data(serial)); |
2681 | usb_set_serial_data(serial, NULL); | ||
2682 | } | 2692 | } |
2683 | 2693 | ||
2684 | 2694 | ||
@@ -2915,7 +2925,8 @@ static struct usb_serial_driver edgeport_1port_device = { | |||
2915 | .throttle = edge_throttle, | 2925 | .throttle = edge_throttle, |
2916 | .unthrottle = edge_unthrottle, | 2926 | .unthrottle = edge_unthrottle, |
2917 | .attach = edge_startup, | 2927 | .attach = edge_startup, |
2918 | .shutdown = edge_shutdown, | 2928 | .disconnect = edge_disconnect, |
2929 | .release = edge_release, | ||
2919 | .port_probe = edge_create_sysfs_attrs, | 2930 | .port_probe = edge_create_sysfs_attrs, |
2920 | .ioctl = edge_ioctl, | 2931 | .ioctl = edge_ioctl, |
2921 | .set_termios = edge_set_termios, | 2932 | .set_termios = edge_set_termios, |
@@ -2944,7 +2955,8 @@ static struct usb_serial_driver edgeport_2port_device = { | |||
2944 | .throttle = edge_throttle, | 2955 | .throttle = edge_throttle, |
2945 | .unthrottle = edge_unthrottle, | 2956 | .unthrottle = edge_unthrottle, |
2946 | .attach = edge_startup, | 2957 | .attach = edge_startup, |
2947 | .shutdown = edge_shutdown, | 2958 | .disconnect = edge_disconnect, |
2959 | .release = edge_release, | ||
2948 | .port_probe = edge_create_sysfs_attrs, | 2960 | .port_probe = edge_create_sysfs_attrs, |
2949 | .ioctl = edge_ioctl, | 2961 | .ioctl = edge_ioctl, |
2950 | .set_termios = edge_set_termios, | 2962 | .set_termios = edge_set_termios, |
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index c610a99fa477..2545d45ce16f 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -79,7 +79,6 @@ static int ipaq_open(struct tty_struct *tty, | |||
79 | static void ipaq_close(struct usb_serial_port *port); | 79 | static void ipaq_close(struct usb_serial_port *port); |
80 | static int ipaq_calc_num_ports(struct usb_serial *serial); | 80 | static int ipaq_calc_num_ports(struct usb_serial *serial); |
81 | static int ipaq_startup(struct usb_serial *serial); | 81 | static int ipaq_startup(struct usb_serial *serial); |
82 | static void ipaq_shutdown(struct usb_serial *serial); | ||
83 | static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port, | 82 | static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port, |
84 | const unsigned char *buf, int count); | 83 | const unsigned char *buf, int count); |
85 | static int ipaq_write_bulk(struct usb_serial_port *port, | 84 | static int ipaq_write_bulk(struct usb_serial_port *port, |
@@ -576,7 +575,6 @@ static struct usb_serial_driver ipaq_device = { | |||
576 | .close = ipaq_close, | 575 | .close = ipaq_close, |
577 | .attach = ipaq_startup, | 576 | .attach = ipaq_startup, |
578 | .calc_num_ports = ipaq_calc_num_ports, | 577 | .calc_num_ports = ipaq_calc_num_ports, |
579 | .shutdown = ipaq_shutdown, | ||
580 | .write = ipaq_write, | 578 | .write = ipaq_write, |
581 | .write_room = ipaq_write_room, | 579 | .write_room = ipaq_write_room, |
582 | .chars_in_buffer = ipaq_chars_in_buffer, | 580 | .chars_in_buffer = ipaq_chars_in_buffer, |
@@ -990,11 +988,6 @@ static int ipaq_startup(struct usb_serial *serial) | |||
990 | return usb_reset_configuration(serial->dev); | 988 | return usb_reset_configuration(serial->dev); |
991 | } | 989 | } |
992 | 990 | ||
993 | static void ipaq_shutdown(struct usb_serial *serial) | ||
994 | { | ||
995 | dbg("%s", __func__); | ||
996 | } | ||
997 | |||
998 | static int __init ipaq_init(void) | 991 | static int __init ipaq_init(void) |
999 | { | 992 | { |
1000 | int retval; | 993 | int retval; |
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index 76a3cc327bb9..96873a7a32b0 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
@@ -121,8 +121,8 @@ static int iuu_startup(struct usb_serial *serial) | |||
121 | return 0; | 121 | return 0; |
122 | } | 122 | } |
123 | 123 | ||
124 | /* Shutdown function */ | 124 | /* Release function */ |
125 | static void iuu_shutdown(struct usb_serial *serial) | 125 | static void iuu_release(struct usb_serial *serial) |
126 | { | 126 | { |
127 | struct usb_serial_port *port = serial->port[0]; | 127 | struct usb_serial_port *port = serial->port[0]; |
128 | struct iuu_private *priv = usb_get_serial_port_data(port); | 128 | struct iuu_private *priv = usb_get_serial_port_data(port); |
@@ -1202,7 +1202,7 @@ static struct usb_serial_driver iuu_device = { | |||
1202 | .tiocmset = iuu_tiocmset, | 1202 | .tiocmset = iuu_tiocmset, |
1203 | .set_termios = iuu_set_termios, | 1203 | .set_termios = iuu_set_termios, |
1204 | .attach = iuu_startup, | 1204 | .attach = iuu_startup, |
1205 | .shutdown = iuu_shutdown, | 1205 | .release = iuu_release, |
1206 | }; | 1206 | }; |
1207 | 1207 | ||
1208 | static int __init iuu_init(void) | 1208 | static int __init iuu_init(void) |
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index f1195a98f316..2594b8743d3f 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -2689,7 +2689,7 @@ static int keyspan_startup(struct usb_serial *serial) | |||
2689 | return 0; | 2689 | return 0; |
2690 | } | 2690 | } |
2691 | 2691 | ||
2692 | static void keyspan_shutdown(struct usb_serial *serial) | 2692 | static void keyspan_disconnect(struct usb_serial *serial) |
2693 | { | 2693 | { |
2694 | int i, j; | 2694 | int i, j; |
2695 | struct usb_serial_port *port; | 2695 | struct usb_serial_port *port; |
@@ -2729,6 +2729,17 @@ static void keyspan_shutdown(struct usb_serial *serial) | |||
2729 | usb_free_urb(p_priv->out_urbs[j]); | 2729 | usb_free_urb(p_priv->out_urbs[j]); |
2730 | } | 2730 | } |
2731 | } | 2731 | } |
2732 | } | ||
2733 | |||
2734 | static void keyspan_release(struct usb_serial *serial) | ||
2735 | { | ||
2736 | int i; | ||
2737 | struct usb_serial_port *port; | ||
2738 | struct keyspan_serial_private *s_priv; | ||
2739 | |||
2740 | dbg("%s", __func__); | ||
2741 | |||
2742 | s_priv = usb_get_serial_data(serial); | ||
2732 | 2743 | ||
2733 | /* dbg("Freeing serial->private."); */ | 2744 | /* dbg("Freeing serial->private."); */ |
2734 | kfree(s_priv); | 2745 | kfree(s_priv); |
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h index 0d4569b60768..3107ed15af64 100644 --- a/drivers/usb/serial/keyspan.h +++ b/drivers/usb/serial/keyspan.h | |||
@@ -41,7 +41,8 @@ static int keyspan_open (struct tty_struct *tty, | |||
41 | static void keyspan_close (struct usb_serial_port *port); | 41 | static void keyspan_close (struct usb_serial_port *port); |
42 | static void keyspan_dtr_rts (struct usb_serial_port *port, int on); | 42 | static void keyspan_dtr_rts (struct usb_serial_port *port, int on); |
43 | static int keyspan_startup (struct usb_serial *serial); | 43 | static int keyspan_startup (struct usb_serial *serial); |
44 | static void keyspan_shutdown (struct usb_serial *serial); | 44 | static void keyspan_disconnect (struct usb_serial *serial); |
45 | static void keyspan_release (struct usb_serial *serial); | ||
45 | static int keyspan_write_room (struct tty_struct *tty); | 46 | static int keyspan_write_room (struct tty_struct *tty); |
46 | 47 | ||
47 | static int keyspan_write (struct tty_struct *tty, | 48 | static int keyspan_write (struct tty_struct *tty, |
@@ -569,7 +570,8 @@ static struct usb_serial_driver keyspan_1port_device = { | |||
569 | .tiocmget = keyspan_tiocmget, | 570 | .tiocmget = keyspan_tiocmget, |
570 | .tiocmset = keyspan_tiocmset, | 571 | .tiocmset = keyspan_tiocmset, |
571 | .attach = keyspan_startup, | 572 | .attach = keyspan_startup, |
572 | .shutdown = keyspan_shutdown, | 573 | .disconnect = keyspan_disconnect, |
574 | .release = keyspan_release, | ||
573 | }; | 575 | }; |
574 | 576 | ||
575 | static struct usb_serial_driver keyspan_2port_device = { | 577 | static struct usb_serial_driver keyspan_2port_device = { |
@@ -590,7 +592,8 @@ static struct usb_serial_driver keyspan_2port_device = { | |||
590 | .tiocmget = keyspan_tiocmget, | 592 | .tiocmget = keyspan_tiocmget, |
591 | .tiocmset = keyspan_tiocmset, | 593 | .tiocmset = keyspan_tiocmset, |
592 | .attach = keyspan_startup, | 594 | .attach = keyspan_startup, |
593 | .shutdown = keyspan_shutdown, | 595 | .disconnect = keyspan_disconnect, |
596 | .release = keyspan_release, | ||
594 | }; | 597 | }; |
595 | 598 | ||
596 | static struct usb_serial_driver keyspan_4port_device = { | 599 | static struct usb_serial_driver keyspan_4port_device = { |
@@ -611,7 +614,8 @@ static struct usb_serial_driver keyspan_4port_device = { | |||
611 | .tiocmget = keyspan_tiocmget, | 614 | .tiocmget = keyspan_tiocmget, |
612 | .tiocmset = keyspan_tiocmset, | 615 | .tiocmset = keyspan_tiocmset, |
613 | .attach = keyspan_startup, | 616 | .attach = keyspan_startup, |
614 | .shutdown = keyspan_shutdown, | 617 | .disconnect = keyspan_disconnect, |
618 | .release = keyspan_release, | ||
615 | }; | 619 | }; |
616 | 620 | ||
617 | #endif | 621 | #endif |
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index ab769dbea1b3..d0b12e40c2b1 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -809,7 +809,7 @@ static int keyspan_pda_startup(struct usb_serial *serial) | |||
809 | return 0; | 809 | return 0; |
810 | } | 810 | } |
811 | 811 | ||
812 | static void keyspan_pda_shutdown(struct usb_serial *serial) | 812 | static void keyspan_pda_release(struct usb_serial *serial) |
813 | { | 813 | { |
814 | dbg("%s", __func__); | 814 | dbg("%s", __func__); |
815 | 815 | ||
@@ -869,7 +869,7 @@ static struct usb_serial_driver keyspan_pda_device = { | |||
869 | .tiocmget = keyspan_pda_tiocmget, | 869 | .tiocmget = keyspan_pda_tiocmget, |
870 | .tiocmset = keyspan_pda_tiocmset, | 870 | .tiocmset = keyspan_pda_tiocmset, |
871 | .attach = keyspan_pda_startup, | 871 | .attach = keyspan_pda_startup, |
872 | .shutdown = keyspan_pda_shutdown, | 872 | .release = keyspan_pda_release, |
873 | }; | 873 | }; |
874 | 874 | ||
875 | 875 | ||
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index fa817c66b3e8..0f44bb8e8d4f 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -73,7 +73,8 @@ static int debug; | |||
73 | * Function prototypes | 73 | * Function prototypes |
74 | */ | 74 | */ |
75 | static int klsi_105_startup(struct usb_serial *serial); | 75 | static int klsi_105_startup(struct usb_serial *serial); |
76 | static void klsi_105_shutdown(struct usb_serial *serial); | 76 | static void klsi_105_disconnect(struct usb_serial *serial); |
77 | static void klsi_105_release(struct usb_serial *serial); | ||
77 | static int klsi_105_open(struct tty_struct *tty, | 78 | static int klsi_105_open(struct tty_struct *tty, |
78 | struct usb_serial_port *port, struct file *filp); | 79 | struct usb_serial_port *port, struct file *filp); |
79 | static void klsi_105_close(struct usb_serial_port *port); | 80 | static void klsi_105_close(struct usb_serial_port *port); |
@@ -131,7 +132,8 @@ static struct usb_serial_driver kl5kusb105d_device = { | |||
131 | .tiocmget = klsi_105_tiocmget, | 132 | .tiocmget = klsi_105_tiocmget, |
132 | .tiocmset = klsi_105_tiocmset, | 133 | .tiocmset = klsi_105_tiocmset, |
133 | .attach = klsi_105_startup, | 134 | .attach = klsi_105_startup, |
134 | .shutdown = klsi_105_shutdown, | 135 | .disconnect = klsi_105_disconnect, |
136 | .release = klsi_105_release, | ||
135 | .throttle = klsi_105_throttle, | 137 | .throttle = klsi_105_throttle, |
136 | .unthrottle = klsi_105_unthrottle, | 138 | .unthrottle = klsi_105_unthrottle, |
137 | }; | 139 | }; |
@@ -315,7 +317,7 @@ err_cleanup: | |||
315 | } /* klsi_105_startup */ | 317 | } /* klsi_105_startup */ |
316 | 318 | ||
317 | 319 | ||
318 | static void klsi_105_shutdown(struct usb_serial *serial) | 320 | static void klsi_105_disconnect(struct usb_serial *serial) |
319 | { | 321 | { |
320 | int i; | 322 | int i; |
321 | 323 | ||
@@ -325,33 +327,36 @@ static void klsi_105_shutdown(struct usb_serial *serial) | |||
325 | for (i = 0; i < serial->num_ports; ++i) { | 327 | for (i = 0; i < serial->num_ports; ++i) { |
326 | struct klsi_105_private *priv = | 328 | struct klsi_105_private *priv = |
327 | usb_get_serial_port_data(serial->port[i]); | 329 | usb_get_serial_port_data(serial->port[i]); |
328 | unsigned long flags; | ||
329 | 330 | ||
330 | if (priv) { | 331 | if (priv) { |
331 | /* kill our write urb pool */ | 332 | /* kill our write urb pool */ |
332 | int j; | 333 | int j; |
333 | struct urb **write_urbs = priv->write_urb_pool; | 334 | struct urb **write_urbs = priv->write_urb_pool; |
334 | spin_lock_irqsave(&priv->lock, flags); | ||
335 | 335 | ||
336 | for (j = 0; j < NUM_URBS; j++) { | 336 | for (j = 0; j < NUM_URBS; j++) { |
337 | if (write_urbs[j]) { | 337 | if (write_urbs[j]) { |
338 | /* FIXME - uncomment the following | 338 | usb_kill_urb(write_urbs[j]); |
339 | * usb_kill_urb call when the host | ||
340 | * controllers get fixed to set | ||
341 | * urb->dev = NULL after the urb is | ||
342 | * finished. Otherwise this call | ||
343 | * oopses. */ | ||
344 | /* usb_kill_urb(write_urbs[j]); */ | ||
345 | kfree(write_urbs[j]->transfer_buffer); | ||
346 | usb_free_urb(write_urbs[j]); | 339 | usb_free_urb(write_urbs[j]); |
347 | } | 340 | } |
348 | } | 341 | } |
349 | spin_unlock_irqrestore(&priv->lock, flags); | ||
350 | kfree(priv); | ||
351 | usb_set_serial_port_data(serial->port[i], NULL); | ||
352 | } | 342 | } |
353 | } | 343 | } |
354 | } /* klsi_105_shutdown */ | 344 | } /* klsi_105_disconnect */ |
345 | |||
346 | |||
347 | static void klsi_105_release(struct usb_serial *serial) | ||
348 | { | ||
349 | int i; | ||
350 | |||
351 | dbg("%s", __func__); | ||
352 | |||
353 | for (i = 0; i < serial->num_ports; ++i) { | ||
354 | struct klsi_105_private *priv = | ||
355 | usb_get_serial_port_data(serial->port[i]); | ||
356 | |||
357 | kfree(priv); | ||
358 | } | ||
359 | } /* klsi_105_release */ | ||
355 | 360 | ||
356 | static int klsi_105_open(struct tty_struct *tty, | 361 | static int klsi_105_open(struct tty_struct *tty, |
357 | struct usb_serial_port *port, struct file *filp) | 362 | struct usb_serial_port *port, struct file *filp) |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 6b570498287f..6db0e561f680 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -69,7 +69,7 @@ static int debug; | |||
69 | 69 | ||
70 | /* Function prototypes */ | 70 | /* Function prototypes */ |
71 | static int kobil_startup(struct usb_serial *serial); | 71 | static int kobil_startup(struct usb_serial *serial); |
72 | static void kobil_shutdown(struct usb_serial *serial); | 72 | static void kobil_release(struct usb_serial *serial); |
73 | static int kobil_open(struct tty_struct *tty, | 73 | static int kobil_open(struct tty_struct *tty, |
74 | struct usb_serial_port *port, struct file *filp); | 74 | struct usb_serial_port *port, struct file *filp); |
75 | static void kobil_close(struct usb_serial_port *port); | 75 | static void kobil_close(struct usb_serial_port *port); |
@@ -117,7 +117,7 @@ static struct usb_serial_driver kobil_device = { | |||
117 | .id_table = id_table, | 117 | .id_table = id_table, |
118 | .num_ports = 1, | 118 | .num_ports = 1, |
119 | .attach = kobil_startup, | 119 | .attach = kobil_startup, |
120 | .shutdown = kobil_shutdown, | 120 | .release = kobil_release, |
121 | .ioctl = kobil_ioctl, | 121 | .ioctl = kobil_ioctl, |
122 | .set_termios = kobil_set_termios, | 122 | .set_termios = kobil_set_termios, |
123 | .tiocmget = kobil_tiocmget, | 123 | .tiocmget = kobil_tiocmget, |
@@ -201,17 +201,13 @@ static int kobil_startup(struct usb_serial *serial) | |||
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | static void kobil_shutdown(struct usb_serial *serial) | 204 | static void kobil_release(struct usb_serial *serial) |
205 | { | 205 | { |
206 | int i; | 206 | int i; |
207 | dbg("%s - port %d", __func__, serial->port[0]->number); | 207 | dbg("%s - port %d", __func__, serial->port[0]->number); |
208 | 208 | ||
209 | for (i = 0; i < serial->num_ports; ++i) { | 209 | for (i = 0; i < serial->num_ports; ++i) |
210 | while (serial->port[i]->port.count > 0) | ||
211 | kobil_close(serial->port[i]); | ||
212 | kfree(usb_get_serial_port_data(serial->port[i])); | 210 | kfree(usb_get_serial_port_data(serial->port[i])); |
213 | usb_set_serial_port_data(serial->port[i], NULL); | ||
214 | } | ||
215 | } | 211 | } |
216 | 212 | ||
217 | 213 | ||
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 873795548fc0..d8825e159aa5 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -92,7 +92,7 @@ static int debug; | |||
92 | * Function prototypes | 92 | * Function prototypes |
93 | */ | 93 | */ |
94 | static int mct_u232_startup(struct usb_serial *serial); | 94 | static int mct_u232_startup(struct usb_serial *serial); |
95 | static void mct_u232_shutdown(struct usb_serial *serial); | 95 | static void mct_u232_release(struct usb_serial *serial); |
96 | static int mct_u232_open(struct tty_struct *tty, | 96 | static int mct_u232_open(struct tty_struct *tty, |
97 | struct usb_serial_port *port, struct file *filp); | 97 | struct usb_serial_port *port, struct file *filp); |
98 | static void mct_u232_close(struct usb_serial_port *port); | 98 | static void mct_u232_close(struct usb_serial_port *port); |
@@ -149,7 +149,7 @@ static struct usb_serial_driver mct_u232_device = { | |||
149 | .tiocmget = mct_u232_tiocmget, | 149 | .tiocmget = mct_u232_tiocmget, |
150 | .tiocmset = mct_u232_tiocmset, | 150 | .tiocmset = mct_u232_tiocmset, |
151 | .attach = mct_u232_startup, | 151 | .attach = mct_u232_startup, |
152 | .shutdown = mct_u232_shutdown, | 152 | .release = mct_u232_release, |
153 | }; | 153 | }; |
154 | 154 | ||
155 | 155 | ||
@@ -407,7 +407,7 @@ static int mct_u232_startup(struct usb_serial *serial) | |||
407 | } /* mct_u232_startup */ | 407 | } /* mct_u232_startup */ |
408 | 408 | ||
409 | 409 | ||
410 | static void mct_u232_shutdown(struct usb_serial *serial) | 410 | static void mct_u232_release(struct usb_serial *serial) |
411 | { | 411 | { |
412 | struct mct_u232_private *priv; | 412 | struct mct_u232_private *priv; |
413 | int i; | 413 | int i; |
@@ -417,12 +417,9 @@ static void mct_u232_shutdown(struct usb_serial *serial) | |||
417 | for (i = 0; i < serial->num_ports; ++i) { | 417 | for (i = 0; i < serial->num_ports; ++i) { |
418 | /* My special items, the standard routines free my urbs */ | 418 | /* My special items, the standard routines free my urbs */ |
419 | priv = usb_get_serial_port_data(serial->port[i]); | 419 | priv = usb_get_serial_port_data(serial->port[i]); |
420 | if (priv) { | 420 | kfree(priv); |
421 | usb_set_serial_port_data(serial->port[i], NULL); | ||
422 | kfree(priv); | ||
423 | } | ||
424 | } | 421 | } |
425 | } /* mct_u232_shutdown */ | 422 | } /* mct_u232_release */ |
426 | 423 | ||
427 | static int mct_u232_open(struct tty_struct *tty, | 424 | static int mct_u232_open(struct tty_struct *tty, |
428 | struct usb_serial_port *port, struct file *filp) | 425 | struct usb_serial_port *port, struct file *filp) |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 9e1a013ee7f6..bfc5ce000ef9 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -1521,19 +1521,16 @@ static int mos7720_startup(struct usb_serial *serial) | |||
1521 | return 0; | 1521 | return 0; |
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | static void mos7720_shutdown(struct usb_serial *serial) | 1524 | static void mos7720_release(struct usb_serial *serial) |
1525 | { | 1525 | { |
1526 | int i; | 1526 | int i; |
1527 | 1527 | ||
1528 | /* free private structure allocated for serial port */ | 1528 | /* free private structure allocated for serial port */ |
1529 | for (i = 0; i < serial->num_ports; ++i) { | 1529 | for (i = 0; i < serial->num_ports; ++i) |
1530 | kfree(usb_get_serial_port_data(serial->port[i])); | 1530 | kfree(usb_get_serial_port_data(serial->port[i])); |
1531 | usb_set_serial_port_data(serial->port[i], NULL); | ||
1532 | } | ||
1533 | 1531 | ||
1534 | /* free private structure allocated for serial device */ | 1532 | /* free private structure allocated for serial device */ |
1535 | kfree(usb_get_serial_data(serial)); | 1533 | kfree(usb_get_serial_data(serial)); |
1536 | usb_set_serial_data(serial, NULL); | ||
1537 | } | 1534 | } |
1538 | 1535 | ||
1539 | static struct usb_driver usb_driver = { | 1536 | static struct usb_driver usb_driver = { |
@@ -1558,7 +1555,7 @@ static struct usb_serial_driver moschip7720_2port_driver = { | |||
1558 | .throttle = mos7720_throttle, | 1555 | .throttle = mos7720_throttle, |
1559 | .unthrottle = mos7720_unthrottle, | 1556 | .unthrottle = mos7720_unthrottle, |
1560 | .attach = mos7720_startup, | 1557 | .attach = mos7720_startup, |
1561 | .shutdown = mos7720_shutdown, | 1558 | .release = mos7720_release, |
1562 | .ioctl = mos7720_ioctl, | 1559 | .ioctl = mos7720_ioctl, |
1563 | .set_termios = mos7720_set_termios, | 1560 | .set_termios = mos7720_set_termios, |
1564 | .write = mos7720_write, | 1561 | .write = mos7720_write, |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 10b78a37214f..c40f95c1951c 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -238,7 +238,7 @@ static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg, | |||
238 | { | 238 | { |
239 | struct usb_device *dev = port->serial->dev; | 239 | struct usb_device *dev = port->serial->dev; |
240 | val = val & 0x00ff; | 240 | val = val & 0x00ff; |
241 | dbg("mos7840_set_reg_sync offset is %x, value %x\n", reg, val); | 241 | dbg("mos7840_set_reg_sync offset is %x, value %x", reg, val); |
242 | 242 | ||
243 | return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, | 243 | return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, |
244 | MCS_WR_RTYPE, val, reg, NULL, 0, | 244 | MCS_WR_RTYPE, val, reg, NULL, 0, |
@@ -260,7 +260,7 @@ static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg, | |||
260 | ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, | 260 | ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, |
261 | MCS_RD_RTYPE, 0, reg, val, VENDOR_READ_LENGTH, | 261 | MCS_RD_RTYPE, 0, reg, val, VENDOR_READ_LENGTH, |
262 | MOS_WDR_TIMEOUT); | 262 | MOS_WDR_TIMEOUT); |
263 | dbg("mos7840_get_reg_sync offset is %x, return val %x\n", reg, *val); | 263 | dbg("mos7840_get_reg_sync offset is %x, return val %x", reg, *val); |
264 | *val = (*val) & 0x00ff; | 264 | *val = (*val) & 0x00ff; |
265 | return ret; | 265 | return ret; |
266 | } | 266 | } |
@@ -282,18 +282,18 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg, | |||
282 | if (port->serial->num_ports == 4) { | 282 | if (port->serial->num_ports == 4) { |
283 | val |= (((__u16) port->number - | 283 | val |= (((__u16) port->number - |
284 | (__u16) (port->serial->minor)) + 1) << 8; | 284 | (__u16) (port->serial->minor)) + 1) << 8; |
285 | dbg("mos7840_set_uart_reg application number is %x\n", val); | 285 | dbg("mos7840_set_uart_reg application number is %x", val); |
286 | } else { | 286 | } else { |
287 | if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { | 287 | if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { |
288 | val |= (((__u16) port->number - | 288 | val |= (((__u16) port->number - |
289 | (__u16) (port->serial->minor)) + 1) << 8; | 289 | (__u16) (port->serial->minor)) + 1) << 8; |
290 | dbg("mos7840_set_uart_reg application number is %x\n", | 290 | dbg("mos7840_set_uart_reg application number is %x", |
291 | val); | 291 | val); |
292 | } else { | 292 | } else { |
293 | val |= | 293 | val |= |
294 | (((__u16) port->number - | 294 | (((__u16) port->number - |
295 | (__u16) (port->serial->minor)) + 2) << 8; | 295 | (__u16) (port->serial->minor)) + 2) << 8; |
296 | dbg("mos7840_set_uart_reg application number is %x\n", | 296 | dbg("mos7840_set_uart_reg application number is %x", |
297 | val); | 297 | val); |
298 | } | 298 | } |
299 | } | 299 | } |
@@ -315,24 +315,24 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg, | |||
315 | int ret = 0; | 315 | int ret = 0; |
316 | __u16 Wval; | 316 | __u16 Wval; |
317 | 317 | ||
318 | /* dbg("application number is %4x \n", | 318 | /* dbg("application number is %4x", |
319 | (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */ | 319 | (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */ |
320 | /* Wval is same as application number */ | 320 | /* Wval is same as application number */ |
321 | if (port->serial->num_ports == 4) { | 321 | if (port->serial->num_ports == 4) { |
322 | Wval = | 322 | Wval = |
323 | (((__u16) port->number - (__u16) (port->serial->minor)) + | 323 | (((__u16) port->number - (__u16) (port->serial->minor)) + |
324 | 1) << 8; | 324 | 1) << 8; |
325 | dbg("mos7840_get_uart_reg application number is %x\n", Wval); | 325 | dbg("mos7840_get_uart_reg application number is %x", Wval); |
326 | } else { | 326 | } else { |
327 | if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { | 327 | if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { |
328 | Wval = (((__u16) port->number - | 328 | Wval = (((__u16) port->number - |
329 | (__u16) (port->serial->minor)) + 1) << 8; | 329 | (__u16) (port->serial->minor)) + 1) << 8; |
330 | dbg("mos7840_get_uart_reg application number is %x\n", | 330 | dbg("mos7840_get_uart_reg application number is %x", |
331 | Wval); | 331 | Wval); |
332 | } else { | 332 | } else { |
333 | Wval = (((__u16) port->number - | 333 | Wval = (((__u16) port->number - |
334 | (__u16) (port->serial->minor)) + 2) << 8; | 334 | (__u16) (port->serial->minor)) + 2) << 8; |
335 | dbg("mos7840_get_uart_reg application number is %x\n", | 335 | dbg("mos7840_get_uart_reg application number is %x", |
336 | Wval); | 336 | Wval); |
337 | } | 337 | } |
338 | } | 338 | } |
@@ -346,11 +346,11 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg, | |||
346 | static void mos7840_dump_serial_port(struct moschip_port *mos7840_port) | 346 | static void mos7840_dump_serial_port(struct moschip_port *mos7840_port) |
347 | { | 347 | { |
348 | 348 | ||
349 | dbg("***************************************\n"); | 349 | dbg("***************************************"); |
350 | dbg("SpRegOffset is %2x\n", mos7840_port->SpRegOffset); | 350 | dbg("SpRegOffset is %2x", mos7840_port->SpRegOffset); |
351 | dbg("ControlRegOffset is %2x \n", mos7840_port->ControlRegOffset); | 351 | dbg("ControlRegOffset is %2x", mos7840_port->ControlRegOffset); |
352 | dbg("DCRRegOffset is %2x \n", mos7840_port->DcrRegOffset); | 352 | dbg("DCRRegOffset is %2x", mos7840_port->DcrRegOffset); |
353 | dbg("***************************************\n"); | 353 | dbg("***************************************"); |
354 | 354 | ||
355 | } | 355 | } |
356 | 356 | ||
@@ -474,12 +474,12 @@ static void mos7840_control_callback(struct urb *urb) | |||
474 | goto exit; | 474 | goto exit; |
475 | } | 475 | } |
476 | 476 | ||
477 | dbg("%s urb buffer size is %d\n", __func__, urb->actual_length); | 477 | dbg("%s urb buffer size is %d", __func__, urb->actual_length); |
478 | dbg("%s mos7840_port->MsrLsr is %d port %d\n", __func__, | 478 | dbg("%s mos7840_port->MsrLsr is %d port %d", __func__, |
479 | mos7840_port->MsrLsr, mos7840_port->port_num); | 479 | mos7840_port->MsrLsr, mos7840_port->port_num); |
480 | data = urb->transfer_buffer; | 480 | data = urb->transfer_buffer; |
481 | regval = (__u8) data[0]; | 481 | regval = (__u8) data[0]; |
482 | dbg("%s data is %x\n", __func__, regval); | 482 | dbg("%s data is %x", __func__, regval); |
483 | if (mos7840_port->MsrLsr == 0) | 483 | if (mos7840_port->MsrLsr == 0) |
484 | mos7840_handle_new_msr(mos7840_port, regval); | 484 | mos7840_handle_new_msr(mos7840_port, regval); |
485 | else if (mos7840_port->MsrLsr == 1) | 485 | else if (mos7840_port->MsrLsr == 1) |
@@ -538,7 +538,7 @@ static void mos7840_interrupt_callback(struct urb *urb) | |||
538 | __u16 wval, wreg = 0; | 538 | __u16 wval, wreg = 0; |
539 | int status = urb->status; | 539 | int status = urb->status; |
540 | 540 | ||
541 | dbg("%s", " : Entering\n"); | 541 | dbg("%s", " : Entering"); |
542 | 542 | ||
543 | switch (status) { | 543 | switch (status) { |
544 | case 0: | 544 | case 0: |
@@ -570,7 +570,7 @@ static void mos7840_interrupt_callback(struct urb *urb) | |||
570 | * Byte 5 FIFO status for both */ | 570 | * Byte 5 FIFO status for both */ |
571 | 571 | ||
572 | if (length && length > 5) { | 572 | if (length && length > 5) { |
573 | dbg("%s \n", "Wrong data !!!"); | 573 | dbg("%s", "Wrong data !!!"); |
574 | return; | 574 | return; |
575 | } | 575 | } |
576 | 576 | ||
@@ -587,17 +587,17 @@ static void mos7840_interrupt_callback(struct urb *urb) | |||
587 | (__u16) (serial->minor)) + 1) << 8; | 587 | (__u16) (serial->minor)) + 1) << 8; |
588 | if (mos7840_port->open) { | 588 | if (mos7840_port->open) { |
589 | if (sp[i] & 0x01) { | 589 | if (sp[i] & 0x01) { |
590 | dbg("SP%d No Interrupt !!!\n", i); | 590 | dbg("SP%d No Interrupt !!!", i); |
591 | } else { | 591 | } else { |
592 | switch (sp[i] & 0x0f) { | 592 | switch (sp[i] & 0x0f) { |
593 | case SERIAL_IIR_RLS: | 593 | case SERIAL_IIR_RLS: |
594 | dbg("Serial Port %d: Receiver status error or ", i); | 594 | dbg("Serial Port %d: Receiver status error or ", i); |
595 | dbg("address bit detected in 9-bit mode\n"); | 595 | dbg("address bit detected in 9-bit mode"); |
596 | mos7840_port->MsrLsr = 1; | 596 | mos7840_port->MsrLsr = 1; |
597 | wreg = LINE_STATUS_REGISTER; | 597 | wreg = LINE_STATUS_REGISTER; |
598 | break; | 598 | break; |
599 | case SERIAL_IIR_MS: | 599 | case SERIAL_IIR_MS: |
600 | dbg("Serial Port %d: Modem status change\n", i); | 600 | dbg("Serial Port %d: Modem status change", i); |
601 | mos7840_port->MsrLsr = 0; | 601 | mos7840_port->MsrLsr = 0; |
602 | wreg = MODEM_STATUS_REGISTER; | 602 | wreg = MODEM_STATUS_REGISTER; |
603 | break; | 603 | break; |
@@ -689,7 +689,7 @@ static void mos7840_bulk_in_callback(struct urb *urb) | |||
689 | 689 | ||
690 | mos7840_port = urb->context; | 690 | mos7840_port = urb->context; |
691 | if (!mos7840_port) { | 691 | if (!mos7840_port) { |
692 | dbg("%s", "NULL mos7840_port pointer \n"); | 692 | dbg("%s", "NULL mos7840_port pointer"); |
693 | mos7840_port->read_urb_busy = false; | 693 | mos7840_port->read_urb_busy = false; |
694 | return; | 694 | return; |
695 | } | 695 | } |
@@ -702,41 +702,41 @@ static void mos7840_bulk_in_callback(struct urb *urb) | |||
702 | 702 | ||
703 | port = (struct usb_serial_port *)mos7840_port->port; | 703 | port = (struct usb_serial_port *)mos7840_port->port; |
704 | if (mos7840_port_paranoia_check(port, __func__)) { | 704 | if (mos7840_port_paranoia_check(port, __func__)) { |
705 | dbg("%s", "Port Paranoia failed \n"); | 705 | dbg("%s", "Port Paranoia failed"); |
706 | mos7840_port->read_urb_busy = false; | 706 | mos7840_port->read_urb_busy = false; |
707 | return; | 707 | return; |
708 | } | 708 | } |
709 | 709 | ||
710 | serial = mos7840_get_usb_serial(port, __func__); | 710 | serial = mos7840_get_usb_serial(port, __func__); |
711 | if (!serial) { | 711 | if (!serial) { |
712 | dbg("%s\n", "Bad serial pointer "); | 712 | dbg("%s", "Bad serial pointer"); |
713 | mos7840_port->read_urb_busy = false; | 713 | mos7840_port->read_urb_busy = false; |
714 | return; | 714 | return; |
715 | } | 715 | } |
716 | 716 | ||
717 | dbg("%s\n", "Entering... \n"); | 717 | dbg("%s", "Entering... "); |
718 | 718 | ||
719 | data = urb->transfer_buffer; | 719 | data = urb->transfer_buffer; |
720 | 720 | ||
721 | dbg("%s", "Entering ........... \n"); | 721 | dbg("%s", "Entering ..........."); |
722 | 722 | ||
723 | if (urb->actual_length) { | 723 | if (urb->actual_length) { |
724 | tty = tty_port_tty_get(&mos7840_port->port->port); | 724 | tty = tty_port_tty_get(&mos7840_port->port->port); |
725 | if (tty) { | 725 | if (tty) { |
726 | tty_buffer_request_room(tty, urb->actual_length); | 726 | tty_buffer_request_room(tty, urb->actual_length); |
727 | tty_insert_flip_string(tty, data, urb->actual_length); | 727 | tty_insert_flip_string(tty, data, urb->actual_length); |
728 | dbg(" %s \n", data); | 728 | dbg(" %s ", data); |
729 | tty_flip_buffer_push(tty); | 729 | tty_flip_buffer_push(tty); |
730 | tty_kref_put(tty); | 730 | tty_kref_put(tty); |
731 | } | 731 | } |
732 | mos7840_port->icount.rx += urb->actual_length; | 732 | mos7840_port->icount.rx += urb->actual_length; |
733 | smp_wmb(); | 733 | smp_wmb(); |
734 | dbg("mos7840_port->icount.rx is %d:\n", | 734 | dbg("mos7840_port->icount.rx is %d:", |
735 | mos7840_port->icount.rx); | 735 | mos7840_port->icount.rx); |
736 | } | 736 | } |
737 | 737 | ||
738 | if (!mos7840_port->read_urb) { | 738 | if (!mos7840_port->read_urb) { |
739 | dbg("%s", "URB KILLED !!!\n"); | 739 | dbg("%s", "URB KILLED !!!"); |
740 | mos7840_port->read_urb_busy = false; | 740 | mos7840_port->read_urb_busy = false; |
741 | return; | 741 | return; |
742 | } | 742 | } |
@@ -777,16 +777,16 @@ static void mos7840_bulk_out_data_callback(struct urb *urb) | |||
777 | spin_unlock(&mos7840_port->pool_lock); | 777 | spin_unlock(&mos7840_port->pool_lock); |
778 | 778 | ||
779 | if (status) { | 779 | if (status) { |
780 | dbg("nonzero write bulk status received:%d\n", status); | 780 | dbg("nonzero write bulk status received:%d", status); |
781 | return; | 781 | return; |
782 | } | 782 | } |
783 | 783 | ||
784 | if (mos7840_port_paranoia_check(mos7840_port->port, __func__)) { | 784 | if (mos7840_port_paranoia_check(mos7840_port->port, __func__)) { |
785 | dbg("%s", "Port Paranoia failed \n"); | 785 | dbg("%s", "Port Paranoia failed"); |
786 | return; | 786 | return; |
787 | } | 787 | } |
788 | 788 | ||
789 | dbg("%s \n", "Entering ........."); | 789 | dbg("%s", "Entering ........."); |
790 | 790 | ||
791 | tty = tty_port_tty_get(&mos7840_port->port->port); | 791 | tty = tty_port_tty_get(&mos7840_port->port->port); |
792 | if (tty && mos7840_port->open) | 792 | if (tty && mos7840_port->open) |
@@ -830,15 +830,17 @@ static int mos7840_open(struct tty_struct *tty, | |||
830 | struct moschip_port *mos7840_port; | 830 | struct moschip_port *mos7840_port; |
831 | struct moschip_port *port0; | 831 | struct moschip_port *port0; |
832 | 832 | ||
833 | dbg ("%s enter", __func__); | ||
834 | |||
833 | if (mos7840_port_paranoia_check(port, __func__)) { | 835 | if (mos7840_port_paranoia_check(port, __func__)) { |
834 | dbg("%s", "Port Paranoia failed \n"); | 836 | dbg("%s", "Port Paranoia failed"); |
835 | return -ENODEV; | 837 | return -ENODEV; |
836 | } | 838 | } |
837 | 839 | ||
838 | serial = port->serial; | 840 | serial = port->serial; |
839 | 841 | ||
840 | if (mos7840_serial_paranoia_check(serial, __func__)) { | 842 | if (mos7840_serial_paranoia_check(serial, __func__)) { |
841 | dbg("%s", "Serial Paranoia failed \n"); | 843 | dbg("%s", "Serial Paranoia failed"); |
842 | return -ENODEV; | 844 | return -ENODEV; |
843 | } | 845 | } |
844 | 846 | ||
@@ -891,20 +893,20 @@ static int mos7840_open(struct tty_struct *tty, | |||
891 | Data = 0x0; | 893 | Data = 0x0; |
892 | status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data); | 894 | status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data); |
893 | if (status < 0) { | 895 | if (status < 0) { |
894 | dbg("Reading Spreg failed\n"); | 896 | dbg("Reading Spreg failed"); |
895 | return -1; | 897 | return -1; |
896 | } | 898 | } |
897 | Data |= 0x80; | 899 | Data |= 0x80; |
898 | status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); | 900 | status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); |
899 | if (status < 0) { | 901 | if (status < 0) { |
900 | dbg("writing Spreg failed\n"); | 902 | dbg("writing Spreg failed"); |
901 | return -1; | 903 | return -1; |
902 | } | 904 | } |
903 | 905 | ||
904 | Data &= ~0x80; | 906 | Data &= ~0x80; |
905 | status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); | 907 | status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); |
906 | if (status < 0) { | 908 | if (status < 0) { |
907 | dbg("writing Spreg failed\n"); | 909 | dbg("writing Spreg failed"); |
908 | return -1; | 910 | return -1; |
909 | } | 911 | } |
910 | /* End of block to be checked */ | 912 | /* End of block to be checked */ |
@@ -913,7 +915,7 @@ static int mos7840_open(struct tty_struct *tty, | |||
913 | status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, | 915 | status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, |
914 | &Data); | 916 | &Data); |
915 | if (status < 0) { | 917 | if (status < 0) { |
916 | dbg("Reading Controlreg failed\n"); | 918 | dbg("Reading Controlreg failed"); |
917 | return -1; | 919 | return -1; |
918 | } | 920 | } |
919 | Data |= 0x08; /* Driver done bit */ | 921 | Data |= 0x08; /* Driver done bit */ |
@@ -921,7 +923,7 @@ static int mos7840_open(struct tty_struct *tty, | |||
921 | status = mos7840_set_reg_sync(port, | 923 | status = mos7840_set_reg_sync(port, |
922 | mos7840_port->ControlRegOffset, Data); | 924 | mos7840_port->ControlRegOffset, Data); |
923 | if (status < 0) { | 925 | if (status < 0) { |
924 | dbg("writing Controlreg failed\n"); | 926 | dbg("writing Controlreg failed"); |
925 | return -1; | 927 | return -1; |
926 | } | 928 | } |
927 | /* do register settings here */ | 929 | /* do register settings here */ |
@@ -932,21 +934,21 @@ static int mos7840_open(struct tty_struct *tty, | |||
932 | Data = 0x00; | 934 | Data = 0x00; |
933 | status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); | 935 | status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); |
934 | if (status < 0) { | 936 | if (status < 0) { |
935 | dbg("disableing interrupts failed\n"); | 937 | dbg("disabling interrupts failed"); |
936 | return -1; | 938 | return -1; |
937 | } | 939 | } |
938 | /* Set FIFO_CONTROL_REGISTER to the default value */ | 940 | /* Set FIFO_CONTROL_REGISTER to the default value */ |
939 | Data = 0x00; | 941 | Data = 0x00; |
940 | status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); | 942 | status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); |
941 | if (status < 0) { | 943 | if (status < 0) { |
942 | dbg("Writing FIFO_CONTROL_REGISTER failed\n"); | 944 | dbg("Writing FIFO_CONTROL_REGISTER failed"); |
943 | return -1; | 945 | return -1; |
944 | } | 946 | } |
945 | 947 | ||
946 | Data = 0xcf; | 948 | Data = 0xcf; |
947 | status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); | 949 | status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); |
948 | if (status < 0) { | 950 | if (status < 0) { |
949 | dbg("Writing FIFO_CONTROL_REGISTER failed\n"); | 951 | dbg("Writing FIFO_CONTROL_REGISTER failed"); |
950 | return -1; | 952 | return -1; |
951 | } | 953 | } |
952 | 954 | ||
@@ -1043,12 +1045,12 @@ static int mos7840_open(struct tty_struct *tty, | |||
1043 | * (can't set it up in mos7840_startup as the * | 1045 | * (can't set it up in mos7840_startup as the * |
1044 | * structures were not set up at that time.) */ | 1046 | * structures were not set up at that time.) */ |
1045 | 1047 | ||
1046 | dbg("port number is %d \n", port->number); | 1048 | dbg("port number is %d", port->number); |
1047 | dbg("serial number is %d \n", port->serial->minor); | 1049 | dbg("serial number is %d", port->serial->minor); |
1048 | dbg("Bulkin endpoint is %d \n", port->bulk_in_endpointAddress); | 1050 | dbg("Bulkin endpoint is %d", port->bulk_in_endpointAddress); |
1049 | dbg("BulkOut endpoint is %d \n", port->bulk_out_endpointAddress); | 1051 | dbg("BulkOut endpoint is %d", port->bulk_out_endpointAddress); |
1050 | dbg("Interrupt endpoint is %d \n", port->interrupt_in_endpointAddress); | 1052 | dbg("Interrupt endpoint is %d", port->interrupt_in_endpointAddress); |
1051 | dbg("port's number in the device is %d\n", mos7840_port->port_num); | 1053 | dbg("port's number in the device is %d", mos7840_port->port_num); |
1052 | mos7840_port->read_urb = port->read_urb; | 1054 | mos7840_port->read_urb = port->read_urb; |
1053 | 1055 | ||
1054 | /* set up our bulk in urb */ | 1056 | /* set up our bulk in urb */ |
@@ -1061,7 +1063,7 @@ static int mos7840_open(struct tty_struct *tty, | |||
1061 | mos7840_port->read_urb->transfer_buffer_length, | 1063 | mos7840_port->read_urb->transfer_buffer_length, |
1062 | mos7840_bulk_in_callback, mos7840_port); | 1064 | mos7840_bulk_in_callback, mos7840_port); |
1063 | 1065 | ||
1064 | dbg("mos7840_open: bulkin endpoint is %d\n", | 1066 | dbg("mos7840_open: bulkin endpoint is %d", |
1065 | port->bulk_in_endpointAddress); | 1067 | port->bulk_in_endpointAddress); |
1066 | mos7840_port->read_urb_busy = true; | 1068 | mos7840_port->read_urb_busy = true; |
1067 | response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); | 1069 | response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); |
@@ -1087,9 +1089,11 @@ static int mos7840_open(struct tty_struct *tty, | |||
1087 | mos7840_port->icount.tx = 0; | 1089 | mos7840_port->icount.tx = 0; |
1088 | mos7840_port->icount.rx = 0; | 1090 | mos7840_port->icount.rx = 0; |
1089 | 1091 | ||
1090 | dbg("\n\nusb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p\n\n", | 1092 | dbg("usb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p", |
1091 | serial, mos7840_port, port); | 1093 | serial, mos7840_port, port); |
1092 | 1094 | ||
1095 | dbg ("%s leave", __func__); | ||
1096 | |||
1093 | return 0; | 1097 | return 0; |
1094 | 1098 | ||
1095 | } | 1099 | } |
@@ -1112,16 +1116,16 @@ static int mos7840_chars_in_buffer(struct tty_struct *tty) | |||
1112 | unsigned long flags; | 1116 | unsigned long flags; |
1113 | struct moschip_port *mos7840_port; | 1117 | struct moschip_port *mos7840_port; |
1114 | 1118 | ||
1115 | dbg("%s \n", " mos7840_chars_in_buffer:entering ..........."); | 1119 | dbg("%s", " mos7840_chars_in_buffer:entering ..........."); |
1116 | 1120 | ||
1117 | if (mos7840_port_paranoia_check(port, __func__)) { | 1121 | if (mos7840_port_paranoia_check(port, __func__)) { |
1118 | dbg("%s", "Invalid port \n"); | 1122 | dbg("%s", "Invalid port"); |
1119 | return 0; | 1123 | return 0; |
1120 | } | 1124 | } |
1121 | 1125 | ||
1122 | mos7840_port = mos7840_get_port_private(port); | 1126 | mos7840_port = mos7840_get_port_private(port); |
1123 | if (mos7840_port == NULL) { | 1127 | if (mos7840_port == NULL) { |
1124 | dbg("%s \n", "mos7840_break:leaving ..........."); | 1128 | dbg("%s", "mos7840_break:leaving ..........."); |
1125 | return 0; | 1129 | return 0; |
1126 | } | 1130 | } |
1127 | 1131 | ||
@@ -1148,16 +1152,16 @@ static void mos7840_close(struct usb_serial_port *port) | |||
1148 | int j; | 1152 | int j; |
1149 | __u16 Data; | 1153 | __u16 Data; |
1150 | 1154 | ||
1151 | dbg("%s\n", "mos7840_close:entering..."); | 1155 | dbg("%s", "mos7840_close:entering..."); |
1152 | 1156 | ||
1153 | if (mos7840_port_paranoia_check(port, __func__)) { | 1157 | if (mos7840_port_paranoia_check(port, __func__)) { |
1154 | dbg("%s", "Port Paranoia failed \n"); | 1158 | dbg("%s", "Port Paranoia failed"); |
1155 | return; | 1159 | return; |
1156 | } | 1160 | } |
1157 | 1161 | ||
1158 | serial = mos7840_get_usb_serial(port, __func__); | 1162 | serial = mos7840_get_usb_serial(port, __func__); |
1159 | if (!serial) { | 1163 | if (!serial) { |
1160 | dbg("%s", "Serial Paranoia failed \n"); | 1164 | dbg("%s", "Serial Paranoia failed"); |
1161 | return; | 1165 | return; |
1162 | } | 1166 | } |
1163 | 1167 | ||
@@ -1185,27 +1189,27 @@ static void mos7840_close(struct usb_serial_port *port) | |||
1185 | * and interrupt read if they exists */ | 1189 | * and interrupt read if they exists */ |
1186 | if (serial->dev) { | 1190 | if (serial->dev) { |
1187 | if (mos7840_port->write_urb) { | 1191 | if (mos7840_port->write_urb) { |
1188 | dbg("%s", "Shutdown bulk write\n"); | 1192 | dbg("%s", "Shutdown bulk write"); |
1189 | usb_kill_urb(mos7840_port->write_urb); | 1193 | usb_kill_urb(mos7840_port->write_urb); |
1190 | } | 1194 | } |
1191 | if (mos7840_port->read_urb) { | 1195 | if (mos7840_port->read_urb) { |
1192 | dbg("%s", "Shutdown bulk read\n"); | 1196 | dbg("%s", "Shutdown bulk read"); |
1193 | usb_kill_urb(mos7840_port->read_urb); | 1197 | usb_kill_urb(mos7840_port->read_urb); |
1194 | mos7840_port->read_urb_busy = false; | 1198 | mos7840_port->read_urb_busy = false; |
1195 | } | 1199 | } |
1196 | if ((&mos7840_port->control_urb)) { | 1200 | if ((&mos7840_port->control_urb)) { |
1197 | dbg("%s", "Shutdown control read\n"); | 1201 | dbg("%s", "Shutdown control read"); |
1198 | /*/ usb_kill_urb (mos7840_port->control_urb); */ | 1202 | /*/ usb_kill_urb (mos7840_port->control_urb); */ |
1199 | } | 1203 | } |
1200 | } | 1204 | } |
1201 | /* if(mos7840_port->ctrl_buf != NULL) */ | 1205 | /* if(mos7840_port->ctrl_buf != NULL) */ |
1202 | /* kfree(mos7840_port->ctrl_buf); */ | 1206 | /* kfree(mos7840_port->ctrl_buf); */ |
1203 | port0->open_ports--; | 1207 | port0->open_ports--; |
1204 | dbg("mos7840_num_open_ports in close%d:in port%d\n", | 1208 | dbg("mos7840_num_open_ports in close%d:in port%d", |
1205 | port0->open_ports, port->number); | 1209 | port0->open_ports, port->number); |
1206 | if (port0->open_ports == 0) { | 1210 | if (port0->open_ports == 0) { |
1207 | if (serial->port[0]->interrupt_in_urb) { | 1211 | if (serial->port[0]->interrupt_in_urb) { |
1208 | dbg("%s", "Shutdown interrupt_in_urb\n"); | 1212 | dbg("%s", "Shutdown interrupt_in_urb"); |
1209 | usb_kill_urb(serial->port[0]->interrupt_in_urb); | 1213 | usb_kill_urb(serial->port[0]->interrupt_in_urb); |
1210 | } | 1214 | } |
1211 | } | 1215 | } |
@@ -1225,7 +1229,7 @@ static void mos7840_close(struct usb_serial_port *port) | |||
1225 | 1229 | ||
1226 | mos7840_port->open = 0; | 1230 | mos7840_port->open = 0; |
1227 | 1231 | ||
1228 | dbg("%s \n", "Leaving ............"); | 1232 | dbg("%s", "Leaving ............"); |
1229 | } | 1233 | } |
1230 | 1234 | ||
1231 | /************************************************************************ | 1235 | /************************************************************************ |
@@ -1280,17 +1284,17 @@ static void mos7840_break(struct tty_struct *tty, int break_state) | |||
1280 | struct usb_serial *serial; | 1284 | struct usb_serial *serial; |
1281 | struct moschip_port *mos7840_port; | 1285 | struct moschip_port *mos7840_port; |
1282 | 1286 | ||
1283 | dbg("%s \n", "Entering ..........."); | 1287 | dbg("%s", "Entering ..........."); |
1284 | dbg("mos7840_break: Start\n"); | 1288 | dbg("mos7840_break: Start"); |
1285 | 1289 | ||
1286 | if (mos7840_port_paranoia_check(port, __func__)) { | 1290 | if (mos7840_port_paranoia_check(port, __func__)) { |
1287 | dbg("%s", "Port Paranoia failed \n"); | 1291 | dbg("%s", "Port Paranoia failed"); |
1288 | return; | 1292 | return; |
1289 | } | 1293 | } |
1290 | 1294 | ||
1291 | serial = mos7840_get_usb_serial(port, __func__); | 1295 | serial = mos7840_get_usb_serial(port, __func__); |
1292 | if (!serial) { | 1296 | if (!serial) { |
1293 | dbg("%s", "Serial Paranoia failed \n"); | 1297 | dbg("%s", "Serial Paranoia failed"); |
1294 | return; | 1298 | return; |
1295 | } | 1299 | } |
1296 | 1300 | ||
@@ -1310,7 +1314,7 @@ static void mos7840_break(struct tty_struct *tty, int break_state) | |||
1310 | 1314 | ||
1311 | /* FIXME: no locking on shadowLCR anywhere in driver */ | 1315 | /* FIXME: no locking on shadowLCR anywhere in driver */ |
1312 | mos7840_port->shadowLCR = data; | 1316 | mos7840_port->shadowLCR = data; |
1313 | dbg("mcs7840_break mos7840_port->shadowLCR is %x\n", | 1317 | dbg("mcs7840_break mos7840_port->shadowLCR is %x", |
1314 | mos7840_port->shadowLCR); | 1318 | mos7840_port->shadowLCR); |
1315 | mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, | 1319 | mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, |
1316 | mos7840_port->shadowLCR); | 1320 | mos7840_port->shadowLCR); |
@@ -1334,17 +1338,17 @@ static int mos7840_write_room(struct tty_struct *tty) | |||
1334 | unsigned long flags; | 1338 | unsigned long flags; |
1335 | struct moschip_port *mos7840_port; | 1339 | struct moschip_port *mos7840_port; |
1336 | 1340 | ||
1337 | dbg("%s \n", " mos7840_write_room:entering ..........."); | 1341 | dbg("%s", " mos7840_write_room:entering ..........."); |
1338 | 1342 | ||
1339 | if (mos7840_port_paranoia_check(port, __func__)) { | 1343 | if (mos7840_port_paranoia_check(port, __func__)) { |
1340 | dbg("%s", "Invalid port \n"); | 1344 | dbg("%s", "Invalid port"); |
1341 | dbg("%s \n", " mos7840_write_room:leaving ..........."); | 1345 | dbg("%s", " mos7840_write_room:leaving ..........."); |
1342 | return -1; | 1346 | return -1; |
1343 | } | 1347 | } |
1344 | 1348 | ||
1345 | mos7840_port = mos7840_get_port_private(port); | 1349 | mos7840_port = mos7840_get_port_private(port); |
1346 | if (mos7840_port == NULL) { | 1350 | if (mos7840_port == NULL) { |
1347 | dbg("%s \n", "mos7840_break:leaving ..........."); | 1351 | dbg("%s", "mos7840_break:leaving ..........."); |
1348 | return -1; | 1352 | return -1; |
1349 | } | 1353 | } |
1350 | 1354 | ||
@@ -1384,16 +1388,16 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1384 | /* __u16 Data; */ | 1388 | /* __u16 Data; */ |
1385 | const unsigned char *current_position = data; | 1389 | const unsigned char *current_position = data; |
1386 | unsigned char *data1; | 1390 | unsigned char *data1; |
1387 | dbg("%s \n", "entering ..........."); | 1391 | dbg("%s", "entering ..........."); |
1388 | /* dbg("mos7840_write: mos7840_port->shadowLCR is %x\n", | 1392 | /* dbg("mos7840_write: mos7840_port->shadowLCR is %x", |
1389 | mos7840_port->shadowLCR); */ | 1393 | mos7840_port->shadowLCR); */ |
1390 | 1394 | ||
1391 | #ifdef NOTMOS7840 | 1395 | #ifdef NOTMOS7840 |
1392 | Data = 0x00; | 1396 | Data = 0x00; |
1393 | status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); | 1397 | status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); |
1394 | mos7840_port->shadowLCR = Data; | 1398 | mos7840_port->shadowLCR = Data; |
1395 | dbg("mos7840_write: LINE_CONTROL_REGISTER is %x\n", Data); | 1399 | dbg("mos7840_write: LINE_CONTROL_REGISTER is %x", Data); |
1396 | dbg("mos7840_write: mos7840_port->shadowLCR is %x\n", | 1400 | dbg("mos7840_write: mos7840_port->shadowLCR is %x", |
1397 | mos7840_port->shadowLCR); | 1401 | mos7840_port->shadowLCR); |
1398 | 1402 | ||
1399 | /* Data = 0x03; */ | 1403 | /* Data = 0x03; */ |
@@ -1407,32 +1411,32 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1407 | /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */ | 1411 | /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */ |
1408 | Data = 0x00; | 1412 | Data = 0x00; |
1409 | status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data); | 1413 | status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data); |
1410 | dbg("mos7840_write:DLL value is %x\n", Data); | 1414 | dbg("mos7840_write:DLL value is %x", Data); |
1411 | 1415 | ||
1412 | Data = 0x0; | 1416 | Data = 0x0; |
1413 | status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data); | 1417 | status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data); |
1414 | dbg("mos7840_write:DLM value is %x\n", Data); | 1418 | dbg("mos7840_write:DLM value is %x", Data); |
1415 | 1419 | ||
1416 | Data = Data & ~SERIAL_LCR_DLAB; | 1420 | Data = Data & ~SERIAL_LCR_DLAB; |
1417 | dbg("mos7840_write: mos7840_port->shadowLCR is %x\n", | 1421 | dbg("mos7840_write: mos7840_port->shadowLCR is %x", |
1418 | mos7840_port->shadowLCR); | 1422 | mos7840_port->shadowLCR); |
1419 | status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); | 1423 | status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); |
1420 | #endif | 1424 | #endif |
1421 | 1425 | ||
1422 | if (mos7840_port_paranoia_check(port, __func__)) { | 1426 | if (mos7840_port_paranoia_check(port, __func__)) { |
1423 | dbg("%s", "Port Paranoia failed \n"); | 1427 | dbg("%s", "Port Paranoia failed"); |
1424 | return -1; | 1428 | return -1; |
1425 | } | 1429 | } |
1426 | 1430 | ||
1427 | serial = port->serial; | 1431 | serial = port->serial; |
1428 | if (mos7840_serial_paranoia_check(serial, __func__)) { | 1432 | if (mos7840_serial_paranoia_check(serial, __func__)) { |
1429 | dbg("%s", "Serial Paranoia failed \n"); | 1433 | dbg("%s", "Serial Paranoia failed"); |
1430 | return -1; | 1434 | return -1; |
1431 | } | 1435 | } |
1432 | 1436 | ||
1433 | mos7840_port = mos7840_get_port_private(port); | 1437 | mos7840_port = mos7840_get_port_private(port); |
1434 | if (mos7840_port == NULL) { | 1438 | if (mos7840_port == NULL) { |
1435 | dbg("%s", "mos7840_port is NULL\n"); | 1439 | dbg("%s", "mos7840_port is NULL"); |
1436 | return -1; | 1440 | return -1; |
1437 | } | 1441 | } |
1438 | 1442 | ||
@@ -1444,7 +1448,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1444 | if (!mos7840_port->busy[i]) { | 1448 | if (!mos7840_port->busy[i]) { |
1445 | mos7840_port->busy[i] = 1; | 1449 | mos7840_port->busy[i] = 1; |
1446 | urb = mos7840_port->write_urb_pool[i]; | 1450 | urb = mos7840_port->write_urb_pool[i]; |
1447 | dbg("\nURB:%d", i); | 1451 | dbg("URB:%d", i); |
1448 | break; | 1452 | break; |
1449 | } | 1453 | } |
1450 | } | 1454 | } |
@@ -1479,7 +1483,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1479 | mos7840_bulk_out_data_callback, mos7840_port); | 1483 | mos7840_bulk_out_data_callback, mos7840_port); |
1480 | 1484 | ||
1481 | data1 = urb->transfer_buffer; | 1485 | data1 = urb->transfer_buffer; |
1482 | dbg("\nbulkout endpoint is %d", port->bulk_out_endpointAddress); | 1486 | dbg("bulkout endpoint is %d", port->bulk_out_endpointAddress); |
1483 | 1487 | ||
1484 | /* send it down the pipe */ | 1488 | /* send it down the pipe */ |
1485 | status = usb_submit_urb(urb, GFP_ATOMIC); | 1489 | status = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -1494,7 +1498,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1494 | bytes_sent = transfer_size; | 1498 | bytes_sent = transfer_size; |
1495 | mos7840_port->icount.tx += transfer_size; | 1499 | mos7840_port->icount.tx += transfer_size; |
1496 | smp_wmb(); | 1500 | smp_wmb(); |
1497 | dbg("mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx); | 1501 | dbg("mos7840_port->icount.tx is %d:", mos7840_port->icount.tx); |
1498 | exit: | 1502 | exit: |
1499 | return bytes_sent; | 1503 | return bytes_sent; |
1500 | 1504 | ||
@@ -1513,11 +1517,11 @@ static void mos7840_throttle(struct tty_struct *tty) | |||
1513 | int status; | 1517 | int status; |
1514 | 1518 | ||
1515 | if (mos7840_port_paranoia_check(port, __func__)) { | 1519 | if (mos7840_port_paranoia_check(port, __func__)) { |
1516 | dbg("%s", "Invalid port \n"); | 1520 | dbg("%s", "Invalid port"); |
1517 | return; | 1521 | return; |
1518 | } | 1522 | } |
1519 | 1523 | ||
1520 | dbg("- port %d\n", port->number); | 1524 | dbg("- port %d", port->number); |
1521 | 1525 | ||
1522 | mos7840_port = mos7840_get_port_private(port); | 1526 | mos7840_port = mos7840_get_port_private(port); |
1523 | 1527 | ||
@@ -1525,11 +1529,11 @@ static void mos7840_throttle(struct tty_struct *tty) | |||
1525 | return; | 1529 | return; |
1526 | 1530 | ||
1527 | if (!mos7840_port->open) { | 1531 | if (!mos7840_port->open) { |
1528 | dbg("%s\n", "port not opened"); | 1532 | dbg("%s", "port not opened"); |
1529 | return; | 1533 | return; |
1530 | } | 1534 | } |
1531 | 1535 | ||
1532 | dbg("%s", "Entering .......... \n"); | 1536 | dbg("%s", "Entering .........."); |
1533 | 1537 | ||
1534 | /* if we are implementing XON/XOFF, send the stop character */ | 1538 | /* if we are implementing XON/XOFF, send the stop character */ |
1535 | if (I_IXOFF(tty)) { | 1539 | if (I_IXOFF(tty)) { |
@@ -1563,7 +1567,7 @@ static void mos7840_unthrottle(struct tty_struct *tty) | |||
1563 | struct moschip_port *mos7840_port = mos7840_get_port_private(port); | 1567 | struct moschip_port *mos7840_port = mos7840_get_port_private(port); |
1564 | 1568 | ||
1565 | if (mos7840_port_paranoia_check(port, __func__)) { | 1569 | if (mos7840_port_paranoia_check(port, __func__)) { |
1566 | dbg("%s", "Invalid port \n"); | 1570 | dbg("%s", "Invalid port"); |
1567 | return; | 1571 | return; |
1568 | } | 1572 | } |
1569 | 1573 | ||
@@ -1575,7 +1579,7 @@ static void mos7840_unthrottle(struct tty_struct *tty) | |||
1575 | return; | 1579 | return; |
1576 | } | 1580 | } |
1577 | 1581 | ||
1578 | dbg("%s", "Entering .......... \n"); | 1582 | dbg("%s", "Entering .........."); |
1579 | 1583 | ||
1580 | /* if we are implementing XON/XOFF, send the start character */ | 1584 | /* if we are implementing XON/XOFF, send the start character */ |
1581 | if (I_IXOFF(tty)) { | 1585 | if (I_IXOFF(tty)) { |
@@ -1660,7 +1664,7 @@ static int mos7840_tiocmset(struct tty_struct *tty, struct file *file, | |||
1660 | 1664 | ||
1661 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr); | 1665 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr); |
1662 | if (status < 0) { | 1666 | if (status < 0) { |
1663 | dbg("setting MODEM_CONTROL_REGISTER Failed\n"); | 1667 | dbg("setting MODEM_CONTROL_REGISTER Failed"); |
1664 | return status; | 1668 | return status; |
1665 | } | 1669 | } |
1666 | 1670 | ||
@@ -1729,11 +1733,11 @@ static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor, | |||
1729 | custom++; | 1733 | custom++; |
1730 | *divisor = custom; | 1734 | *divisor = custom; |
1731 | 1735 | ||
1732 | dbg(" Baud %d = %d\n", baudrate, custom); | 1736 | dbg(" Baud %d = %d", baudrate, custom); |
1733 | return 0; | 1737 | return 0; |
1734 | } | 1738 | } |
1735 | 1739 | ||
1736 | dbg("%s\n", " Baud calculation Failed..."); | 1740 | dbg("%s", " Baud calculation Failed..."); |
1737 | return -1; | 1741 | return -1; |
1738 | #endif | 1742 | #endif |
1739 | } | 1743 | } |
@@ -1759,16 +1763,16 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1759 | 1763 | ||
1760 | port = (struct usb_serial_port *)mos7840_port->port; | 1764 | port = (struct usb_serial_port *)mos7840_port->port; |
1761 | if (mos7840_port_paranoia_check(port, __func__)) { | 1765 | if (mos7840_port_paranoia_check(port, __func__)) { |
1762 | dbg("%s", "Invalid port \n"); | 1766 | dbg("%s", "Invalid port"); |
1763 | return -1; | 1767 | return -1; |
1764 | } | 1768 | } |
1765 | 1769 | ||
1766 | if (mos7840_serial_paranoia_check(port->serial, __func__)) { | 1770 | if (mos7840_serial_paranoia_check(port->serial, __func__)) { |
1767 | dbg("%s", "Invalid Serial \n"); | 1771 | dbg("%s", "Invalid Serial"); |
1768 | return -1; | 1772 | return -1; |
1769 | } | 1773 | } |
1770 | 1774 | ||
1771 | dbg("%s", "Entering .......... \n"); | 1775 | dbg("%s", "Entering .........."); |
1772 | 1776 | ||
1773 | number = mos7840_port->port->number - mos7840_port->port->serial->minor; | 1777 | number = mos7840_port->port->number - mos7840_port->port->serial->minor; |
1774 | 1778 | ||
@@ -1784,7 +1788,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1784 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, | 1788 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, |
1785 | Data); | 1789 | Data); |
1786 | if (status < 0) { | 1790 | if (status < 0) { |
1787 | dbg("Writing spreg failed in set_serial_baud\n"); | 1791 | dbg("Writing spreg failed in set_serial_baud"); |
1788 | return -1; | 1792 | return -1; |
1789 | } | 1793 | } |
1790 | #endif | 1794 | #endif |
@@ -1797,7 +1801,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1797 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, | 1801 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, |
1798 | Data); | 1802 | Data); |
1799 | if (status < 0) { | 1803 | if (status < 0) { |
1800 | dbg("Writing spreg failed in set_serial_baud\n"); | 1804 | dbg("Writing spreg failed in set_serial_baud"); |
1801 | return -1; | 1805 | return -1; |
1802 | } | 1806 | } |
1803 | #endif | 1807 | #endif |
@@ -1812,14 +1816,14 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1812 | status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, | 1816 | status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, |
1813 | &Data); | 1817 | &Data); |
1814 | if (status < 0) { | 1818 | if (status < 0) { |
1815 | dbg("reading spreg failed in set_serial_baud\n"); | 1819 | dbg("reading spreg failed in set_serial_baud"); |
1816 | return -1; | 1820 | return -1; |
1817 | } | 1821 | } |
1818 | Data = (Data & 0x8f) | clk_sel_val; | 1822 | Data = (Data & 0x8f) | clk_sel_val; |
1819 | status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, | 1823 | status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, |
1820 | Data); | 1824 | Data); |
1821 | if (status < 0) { | 1825 | if (status < 0) { |
1822 | dbg("Writing spreg failed in set_serial_baud\n"); | 1826 | dbg("Writing spreg failed in set_serial_baud"); |
1823 | return -1; | 1827 | return -1; |
1824 | } | 1828 | } |
1825 | /* Calculate the Divisor */ | 1829 | /* Calculate the Divisor */ |
@@ -1835,11 +1839,11 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1835 | 1839 | ||
1836 | /* Write the divisor */ | 1840 | /* Write the divisor */ |
1837 | Data = (unsigned char)(divisor & 0xff); | 1841 | Data = (unsigned char)(divisor & 0xff); |
1838 | dbg("set_serial_baud Value to write DLL is %x\n", Data); | 1842 | dbg("set_serial_baud Value to write DLL is %x", Data); |
1839 | mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data); | 1843 | mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data); |
1840 | 1844 | ||
1841 | Data = (unsigned char)((divisor & 0xff00) >> 8); | 1845 | Data = (unsigned char)((divisor & 0xff00) >> 8); |
1842 | dbg("set_serial_baud Value to write DLM is %x\n", Data); | 1846 | dbg("set_serial_baud Value to write DLM is %x", Data); |
1843 | mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data); | 1847 | mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data); |
1844 | 1848 | ||
1845 | /* Disable access to divisor latch */ | 1849 | /* Disable access to divisor latch */ |
@@ -1877,12 +1881,12 @@ static void mos7840_change_port_settings(struct tty_struct *tty, | |||
1877 | port = (struct usb_serial_port *)mos7840_port->port; | 1881 | port = (struct usb_serial_port *)mos7840_port->port; |
1878 | 1882 | ||
1879 | if (mos7840_port_paranoia_check(port, __func__)) { | 1883 | if (mos7840_port_paranoia_check(port, __func__)) { |
1880 | dbg("%s", "Invalid port \n"); | 1884 | dbg("%s", "Invalid port"); |
1881 | return; | 1885 | return; |
1882 | } | 1886 | } |
1883 | 1887 | ||
1884 | if (mos7840_serial_paranoia_check(port->serial, __func__)) { | 1888 | if (mos7840_serial_paranoia_check(port->serial, __func__)) { |
1885 | dbg("%s", "Invalid Serial \n"); | 1889 | dbg("%s", "Invalid Serial"); |
1886 | return; | 1890 | return; |
1887 | } | 1891 | } |
1888 | 1892 | ||
@@ -1895,7 +1899,7 @@ static void mos7840_change_port_settings(struct tty_struct *tty, | |||
1895 | return; | 1899 | return; |
1896 | } | 1900 | } |
1897 | 1901 | ||
1898 | dbg("%s", "Entering .......... \n"); | 1902 | dbg("%s", "Entering .........."); |
1899 | 1903 | ||
1900 | lData = LCR_BITS_8; | 1904 | lData = LCR_BITS_8; |
1901 | lStop = LCR_STOP_1; | 1905 | lStop = LCR_STOP_1; |
@@ -1955,7 +1959,7 @@ static void mos7840_change_port_settings(struct tty_struct *tty, | |||
1955 | ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); | 1959 | ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); |
1956 | mos7840_port->shadowLCR |= (lData | lParity | lStop); | 1960 | mos7840_port->shadowLCR |= (lData | lParity | lStop); |
1957 | 1961 | ||
1958 | dbg("mos7840_change_port_settings mos7840_port->shadowLCR is %x\n", | 1962 | dbg("mos7840_change_port_settings mos7840_port->shadowLCR is %x", |
1959 | mos7840_port->shadowLCR); | 1963 | mos7840_port->shadowLCR); |
1960 | /* Disable Interrupts */ | 1964 | /* Disable Interrupts */ |
1961 | Data = 0x00; | 1965 | Data = 0x00; |
@@ -1997,7 +2001,7 @@ static void mos7840_change_port_settings(struct tty_struct *tty, | |||
1997 | 2001 | ||
1998 | if (!baud) { | 2002 | if (!baud) { |
1999 | /* pick a default, any default... */ | 2003 | /* pick a default, any default... */ |
2000 | dbg("%s\n", "Picked default baud..."); | 2004 | dbg("%s", "Picked default baud..."); |
2001 | baud = 9600; | 2005 | baud = 9600; |
2002 | } | 2006 | } |
2003 | 2007 | ||
@@ -2020,7 +2024,7 @@ static void mos7840_change_port_settings(struct tty_struct *tty, | |||
2020 | } | 2024 | } |
2021 | wake_up(&mos7840_port->delta_msr_wait); | 2025 | wake_up(&mos7840_port->delta_msr_wait); |
2022 | mos7840_port->delta_msr_cond = 1; | 2026 | mos7840_port->delta_msr_cond = 1; |
2023 | dbg("mos7840_change_port_settings mos7840_port->shadowLCR is End %x\n", | 2027 | dbg("mos7840_change_port_settings mos7840_port->shadowLCR is End %x", |
2024 | mos7840_port->shadowLCR); | 2028 | mos7840_port->shadowLCR); |
2025 | 2029 | ||
2026 | return; | 2030 | return; |
@@ -2040,16 +2044,16 @@ static void mos7840_set_termios(struct tty_struct *tty, | |||
2040 | unsigned int cflag; | 2044 | unsigned int cflag; |
2041 | struct usb_serial *serial; | 2045 | struct usb_serial *serial; |
2042 | struct moschip_port *mos7840_port; | 2046 | struct moschip_port *mos7840_port; |
2043 | dbg("mos7840_set_termios: START\n"); | 2047 | dbg("mos7840_set_termios: START"); |
2044 | if (mos7840_port_paranoia_check(port, __func__)) { | 2048 | if (mos7840_port_paranoia_check(port, __func__)) { |
2045 | dbg("%s", "Invalid port \n"); | 2049 | dbg("%s", "Invalid port"); |
2046 | return; | 2050 | return; |
2047 | } | 2051 | } |
2048 | 2052 | ||
2049 | serial = port->serial; | 2053 | serial = port->serial; |
2050 | 2054 | ||
2051 | if (mos7840_serial_paranoia_check(serial, __func__)) { | 2055 | if (mos7840_serial_paranoia_check(serial, __func__)) { |
2052 | dbg("%s", "Invalid Serial \n"); | 2056 | dbg("%s", "Invalid Serial"); |
2053 | return; | 2057 | return; |
2054 | } | 2058 | } |
2055 | 2059 | ||
@@ -2063,7 +2067,7 @@ static void mos7840_set_termios(struct tty_struct *tty, | |||
2063 | return; | 2067 | return; |
2064 | } | 2068 | } |
2065 | 2069 | ||
2066 | dbg("%s\n", "setting termios - "); | 2070 | dbg("%s", "setting termios - "); |
2067 | 2071 | ||
2068 | cflag = tty->termios->c_cflag; | 2072 | cflag = tty->termios->c_cflag; |
2069 | 2073 | ||
@@ -2078,7 +2082,7 @@ static void mos7840_set_termios(struct tty_struct *tty, | |||
2078 | mos7840_change_port_settings(tty, mos7840_port, old_termios); | 2082 | mos7840_change_port_settings(tty, mos7840_port, old_termios); |
2079 | 2083 | ||
2080 | if (!mos7840_port->read_urb) { | 2084 | if (!mos7840_port->read_urb) { |
2081 | dbg("%s", "URB KILLED !!!!!\n"); | 2085 | dbg("%s", "URB KILLED !!!!!"); |
2082 | return; | 2086 | return; |
2083 | } | 2087 | } |
2084 | 2088 | ||
@@ -2144,7 +2148,7 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port, | |||
2144 | 2148 | ||
2145 | port = (struct usb_serial_port *)mos7840_port->port; | 2149 | port = (struct usb_serial_port *)mos7840_port->port; |
2146 | if (mos7840_port_paranoia_check(port, __func__)) { | 2150 | if (mos7840_port_paranoia_check(port, __func__)) { |
2147 | dbg("%s", "Invalid port \n"); | 2151 | dbg("%s", "Invalid port"); |
2148 | return -1; | 2152 | return -1; |
2149 | } | 2153 | } |
2150 | 2154 | ||
@@ -2189,7 +2193,7 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port, | |||
2189 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); | 2193 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); |
2190 | unlock_kernel(); | 2194 | unlock_kernel(); |
2191 | if (status < 0) { | 2195 | if (status < 0) { |
2192 | dbg("setting MODEM_CONTROL_REGISTER Failed\n"); | 2196 | dbg("setting MODEM_CONTROL_REGISTER Failed"); |
2193 | return -1; | 2197 | return -1; |
2194 | } | 2198 | } |
2195 | 2199 | ||
@@ -2274,7 +2278,7 @@ static int mos7840_ioctl(struct tty_struct *tty, struct file *file, | |||
2274 | int mosret = 0; | 2278 | int mosret = 0; |
2275 | 2279 | ||
2276 | if (mos7840_port_paranoia_check(port, __func__)) { | 2280 | if (mos7840_port_paranoia_check(port, __func__)) { |
2277 | dbg("%s", "Invalid port \n"); | 2281 | dbg("%s", "Invalid port"); |
2278 | return -1; | 2282 | return -1; |
2279 | } | 2283 | } |
2280 | 2284 | ||
@@ -2374,9 +2378,8 @@ static int mos7840_calc_num_ports(struct usb_serial *serial) | |||
2374 | { | 2378 | { |
2375 | int mos7840_num_ports = 0; | 2379 | int mos7840_num_ports = 0; |
2376 | 2380 | ||
2377 | dbg("numberofendpoints: %d \n", | 2381 | dbg("numberofendpoints: cur %d, alt %d", |
2378 | (int)serial->interface->cur_altsetting->desc.bNumEndpoints); | 2382 | (int)serial->interface->cur_altsetting->desc.bNumEndpoints, |
2379 | dbg("numberofendpoints: %d \n", | ||
2380 | (int)serial->interface->altsetting->desc.bNumEndpoints); | 2383 | (int)serial->interface->altsetting->desc.bNumEndpoints); |
2381 | if (serial->interface->cur_altsetting->desc.bNumEndpoints == 5) { | 2384 | if (serial->interface->cur_altsetting->desc.bNumEndpoints == 5) { |
2382 | mos7840_num_ports = serial->num_ports = 2; | 2385 | mos7840_num_ports = serial->num_ports = 2; |
@@ -2385,7 +2388,7 @@ static int mos7840_calc_num_ports(struct usb_serial *serial) | |||
2385 | serial->num_bulk_out = 4; | 2388 | serial->num_bulk_out = 4; |
2386 | mos7840_num_ports = serial->num_ports = 4; | 2389 | mos7840_num_ports = serial->num_ports = 4; |
2387 | } | 2390 | } |
2388 | 2391 | dbg ("mos7840_num_ports = %d", mos7840_num_ports); | |
2389 | return mos7840_num_ports; | 2392 | return mos7840_num_ports; |
2390 | } | 2393 | } |
2391 | 2394 | ||
@@ -2400,22 +2403,24 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2400 | int i, status; | 2403 | int i, status; |
2401 | 2404 | ||
2402 | __u16 Data; | 2405 | __u16 Data; |
2403 | dbg("%s \n", " mos7840_startup :entering.........."); | 2406 | dbg("%s", "mos7840_startup :Entering.........."); |
2404 | 2407 | ||
2405 | if (!serial) { | 2408 | if (!serial) { |
2406 | dbg("%s\n", "Invalid Handler"); | 2409 | dbg("%s", "Invalid Handler"); |
2407 | return -1; | 2410 | return -1; |
2408 | } | 2411 | } |
2409 | 2412 | ||
2410 | dev = serial->dev; | 2413 | dev = serial->dev; |
2411 | 2414 | ||
2412 | dbg("%s\n", "Entering..."); | 2415 | dbg("%s", "Entering..."); |
2416 | dbg ("mos7840_startup: serial = %p", serial); | ||
2413 | 2417 | ||
2414 | /* we set up the pointers to the endpoints in the mos7840_open * | 2418 | /* we set up the pointers to the endpoints in the mos7840_open * |
2415 | * function, as the structures aren't created yet. */ | 2419 | * function, as the structures aren't created yet. */ |
2416 | 2420 | ||
2417 | /* set up port private structures */ | 2421 | /* set up port private structures */ |
2418 | for (i = 0; i < serial->num_ports; ++i) { | 2422 | for (i = 0; i < serial->num_ports; ++i) { |
2423 | dbg ("mos7840_startup: configuring port %d............", i); | ||
2419 | mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); | 2424 | mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); |
2420 | if (mos7840_port == NULL) { | 2425 | if (mos7840_port == NULL) { |
2421 | dev_err(&dev->dev, "%s - Out of memory\n", __func__); | 2426 | dev_err(&dev->dev, "%s - Out of memory\n", __func__); |
@@ -2473,10 +2478,10 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2473 | status = mos7840_get_reg_sync(serial->port[i], | 2478 | status = mos7840_get_reg_sync(serial->port[i], |
2474 | mos7840_port->ControlRegOffset, &Data); | 2479 | mos7840_port->ControlRegOffset, &Data); |
2475 | if (status < 0) { | 2480 | if (status < 0) { |
2476 | dbg("Reading ControlReg failed status-0x%x\n", status); | 2481 | dbg("Reading ControlReg failed status-0x%x", status); |
2477 | break; | 2482 | break; |
2478 | } else | 2483 | } else |
2479 | dbg("ControlReg Reading success val is %x, status%d\n", | 2484 | dbg("ControlReg Reading success val is %x, status%d", |
2480 | Data, status); | 2485 | Data, status); |
2481 | Data |= 0x08; /* setting driver done bit */ | 2486 | Data |= 0x08; /* setting driver done bit */ |
2482 | Data |= 0x04; /* sp1_bit to have cts change reflect in | 2487 | Data |= 0x04; /* sp1_bit to have cts change reflect in |
@@ -2486,10 +2491,10 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2486 | status = mos7840_set_reg_sync(serial->port[i], | 2491 | status = mos7840_set_reg_sync(serial->port[i], |
2487 | mos7840_port->ControlRegOffset, Data); | 2492 | mos7840_port->ControlRegOffset, Data); |
2488 | if (status < 0) { | 2493 | if (status < 0) { |
2489 | dbg("Writing ControlReg failed(rx_disable) status-0x%x\n", status); | 2494 | dbg("Writing ControlReg failed(rx_disable) status-0x%x", status); |
2490 | break; | 2495 | break; |
2491 | } else | 2496 | } else |
2492 | dbg("ControlReg Writing success(rx_disable) status%d\n", | 2497 | dbg("ControlReg Writing success(rx_disable) status%d", |
2493 | status); | 2498 | status); |
2494 | 2499 | ||
2495 | /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 | 2500 | /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 |
@@ -2498,48 +2503,48 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2498 | status = mos7840_set_reg_sync(serial->port[i], | 2503 | status = mos7840_set_reg_sync(serial->port[i], |
2499 | (__u16) (mos7840_port->DcrRegOffset + 0), Data); | 2504 | (__u16) (mos7840_port->DcrRegOffset + 0), Data); |
2500 | if (status < 0) { | 2505 | if (status < 0) { |
2501 | dbg("Writing DCR0 failed status-0x%x\n", status); | 2506 | dbg("Writing DCR0 failed status-0x%x", status); |
2502 | break; | 2507 | break; |
2503 | } else | 2508 | } else |
2504 | dbg("DCR0 Writing success status%d\n", status); | 2509 | dbg("DCR0 Writing success status%d", status); |
2505 | 2510 | ||
2506 | Data = 0x05; | 2511 | Data = 0x05; |
2507 | status = mos7840_set_reg_sync(serial->port[i], | 2512 | status = mos7840_set_reg_sync(serial->port[i], |
2508 | (__u16) (mos7840_port->DcrRegOffset + 1), Data); | 2513 | (__u16) (mos7840_port->DcrRegOffset + 1), Data); |
2509 | if (status < 0) { | 2514 | if (status < 0) { |
2510 | dbg("Writing DCR1 failed status-0x%x\n", status); | 2515 | dbg("Writing DCR1 failed status-0x%x", status); |
2511 | break; | 2516 | break; |
2512 | } else | 2517 | } else |
2513 | dbg("DCR1 Writing success status%d\n", status); | 2518 | dbg("DCR1 Writing success status%d", status); |
2514 | 2519 | ||
2515 | Data = 0x24; | 2520 | Data = 0x24; |
2516 | status = mos7840_set_reg_sync(serial->port[i], | 2521 | status = mos7840_set_reg_sync(serial->port[i], |
2517 | (__u16) (mos7840_port->DcrRegOffset + 2), Data); | 2522 | (__u16) (mos7840_port->DcrRegOffset + 2), Data); |
2518 | if (status < 0) { | 2523 | if (status < 0) { |
2519 | dbg("Writing DCR2 failed status-0x%x\n", status); | 2524 | dbg("Writing DCR2 failed status-0x%x", status); |
2520 | break; | 2525 | break; |
2521 | } else | 2526 | } else |
2522 | dbg("DCR2 Writing success status%d\n", status); | 2527 | dbg("DCR2 Writing success status%d", status); |
2523 | 2528 | ||
2524 | /* write values in clkstart0x0 and clkmulti 0x20 */ | 2529 | /* write values in clkstart0x0 and clkmulti 0x20 */ |
2525 | Data = 0x0; | 2530 | Data = 0x0; |
2526 | status = mos7840_set_reg_sync(serial->port[i], | 2531 | status = mos7840_set_reg_sync(serial->port[i], |
2527 | CLK_START_VALUE_REGISTER, Data); | 2532 | CLK_START_VALUE_REGISTER, Data); |
2528 | if (status < 0) { | 2533 | if (status < 0) { |
2529 | dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status); | 2534 | dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x", status); |
2530 | break; | 2535 | break; |
2531 | } else | 2536 | } else |
2532 | dbg("CLK_START_VALUE_REGISTER Writing success status%d\n", status); | 2537 | dbg("CLK_START_VALUE_REGISTER Writing success status%d", status); |
2533 | 2538 | ||
2534 | Data = 0x20; | 2539 | Data = 0x20; |
2535 | status = mos7840_set_reg_sync(serial->port[i], | 2540 | status = mos7840_set_reg_sync(serial->port[i], |
2536 | CLK_MULTI_REGISTER, Data); | 2541 | CLK_MULTI_REGISTER, Data); |
2537 | if (status < 0) { | 2542 | if (status < 0) { |
2538 | dbg("Writing CLK_MULTI_REGISTER failed status-0x%x\n", | 2543 | dbg("Writing CLK_MULTI_REGISTER failed status-0x%x", |
2539 | status); | 2544 | status); |
2540 | goto error; | 2545 | goto error; |
2541 | } else | 2546 | } else |
2542 | dbg("CLK_MULTI_REGISTER Writing success status%d\n", | 2547 | dbg("CLK_MULTI_REGISTER Writing success status%d", |
2543 | status); | 2548 | status); |
2544 | 2549 | ||
2545 | /* write value 0x0 to scratchpad register */ | 2550 | /* write value 0x0 to scratchpad register */ |
@@ -2547,11 +2552,11 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2547 | status = mos7840_set_uart_reg(serial->port[i], | 2552 | status = mos7840_set_uart_reg(serial->port[i], |
2548 | SCRATCH_PAD_REGISTER, Data); | 2553 | SCRATCH_PAD_REGISTER, Data); |
2549 | if (status < 0) { | 2554 | if (status < 0) { |
2550 | dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x\n", | 2555 | dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x", |
2551 | status); | 2556 | status); |
2552 | break; | 2557 | break; |
2553 | } else | 2558 | } else |
2554 | dbg("SCRATCH_PAD_REGISTER Writing success status%d\n", | 2559 | dbg("SCRATCH_PAD_REGISTER Writing success status%d", |
2555 | status); | 2560 | status); |
2556 | 2561 | ||
2557 | /* Zero Length flag register */ | 2562 | /* Zero Length flag register */ |
@@ -2562,30 +2567,30 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2562 | status = mos7840_set_reg_sync(serial->port[i], | 2567 | status = mos7840_set_reg_sync(serial->port[i], |
2563 | (__u16) (ZLP_REG1 + | 2568 | (__u16) (ZLP_REG1 + |
2564 | ((__u16)mos7840_port->port_num)), Data); | 2569 | ((__u16)mos7840_port->port_num)), Data); |
2565 | dbg("ZLIP offset%x\n", | 2570 | dbg("ZLIP offset %x", |
2566 | (__u16) (ZLP_REG1 + | 2571 | (__u16) (ZLP_REG1 + |
2567 | ((__u16) mos7840_port->port_num))); | 2572 | ((__u16) mos7840_port->port_num))); |
2568 | if (status < 0) { | 2573 | if (status < 0) { |
2569 | dbg("Writing ZLP_REG%d failed status-0x%x\n", | 2574 | dbg("Writing ZLP_REG%d failed status-0x%x", |
2570 | i + 2, status); | 2575 | i + 2, status); |
2571 | break; | 2576 | break; |
2572 | } else | 2577 | } else |
2573 | dbg("ZLP_REG%d Writing success status%d\n", | 2578 | dbg("ZLP_REG%d Writing success status%d", |
2574 | i + 2, status); | 2579 | i + 2, status); |
2575 | } else { | 2580 | } else { |
2576 | Data = 0xff; | 2581 | Data = 0xff; |
2577 | status = mos7840_set_reg_sync(serial->port[i], | 2582 | status = mos7840_set_reg_sync(serial->port[i], |
2578 | (__u16) (ZLP_REG1 + | 2583 | (__u16) (ZLP_REG1 + |
2579 | ((__u16)mos7840_port->port_num) - 0x1), Data); | 2584 | ((__u16)mos7840_port->port_num) - 0x1), Data); |
2580 | dbg("ZLIP offset%x\n", | 2585 | dbg("ZLIP offset %x", |
2581 | (__u16) (ZLP_REG1 + | 2586 | (__u16) (ZLP_REG1 + |
2582 | ((__u16) mos7840_port->port_num) - 0x1)); | 2587 | ((__u16) mos7840_port->port_num) - 0x1)); |
2583 | if (status < 0) { | 2588 | if (status < 0) { |
2584 | dbg("Writing ZLP_REG%d failed status-0x%x\n", | 2589 | dbg("Writing ZLP_REG%d failed status-0x%x", |
2585 | i + 1, status); | 2590 | i + 1, status); |
2586 | break; | 2591 | break; |
2587 | } else | 2592 | } else |
2588 | dbg("ZLP_REG%d Writing success status%d\n", | 2593 | dbg("ZLP_REG%d Writing success status%d", |
2589 | i + 1, status); | 2594 | i + 1, status); |
2590 | 2595 | ||
2591 | } | 2596 | } |
@@ -2599,15 +2604,16 @@ static int mos7840_startup(struct usb_serial *serial) | |||
2599 | goto error; | 2604 | goto error; |
2600 | } | 2605 | } |
2601 | } | 2606 | } |
2607 | dbg ("mos7840_startup: all ports configured..........."); | ||
2602 | 2608 | ||
2603 | /* Zero Length flag enable */ | 2609 | /* Zero Length flag enable */ |
2604 | Data = 0x0f; | 2610 | Data = 0x0f; |
2605 | status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); | 2611 | status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); |
2606 | if (status < 0) { | 2612 | if (status < 0) { |
2607 | dbg("Writing ZLP_REG5 failed status-0x%x\n", status); | 2613 | dbg("Writing ZLP_REG5 failed status-0x%x", status); |
2608 | goto error; | 2614 | goto error; |
2609 | } else | 2615 | } else |
2610 | dbg("ZLP_REG5 Writing success status%d\n", status); | 2616 | dbg("ZLP_REG5 Writing success status%d", status); |
2611 | 2617 | ||
2612 | /* setting configuration feature to one */ | 2618 | /* setting configuration feature to one */ |
2613 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 2619 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
@@ -2627,19 +2633,19 @@ error: | |||
2627 | } | 2633 | } |
2628 | 2634 | ||
2629 | /**************************************************************************** | 2635 | /**************************************************************************** |
2630 | * mos7840_shutdown | 2636 | * mos7840_disconnect |
2631 | * This function is called whenever the device is removed from the usb bus. | 2637 | * This function is called whenever the device is removed from the usb bus. |
2632 | ****************************************************************************/ | 2638 | ****************************************************************************/ |
2633 | 2639 | ||
2634 | static void mos7840_shutdown(struct usb_serial *serial) | 2640 | static void mos7840_disconnect(struct usb_serial *serial) |
2635 | { | 2641 | { |
2636 | int i; | 2642 | int i; |
2637 | unsigned long flags; | 2643 | unsigned long flags; |
2638 | struct moschip_port *mos7840_port; | 2644 | struct moschip_port *mos7840_port; |
2639 | dbg("%s \n", " shutdown :entering.........."); | 2645 | dbg("%s", " disconnect :entering.........."); |
2640 | 2646 | ||
2641 | if (!serial) { | 2647 | if (!serial) { |
2642 | dbg("%s", "Invalid Handler \n"); | 2648 | dbg("%s", "Invalid Handler"); |
2643 | return; | 2649 | return; |
2644 | } | 2650 | } |
2645 | 2651 | ||
@@ -2656,14 +2662,45 @@ static void mos7840_shutdown(struct usb_serial *serial) | |||
2656 | mos7840_port->zombie = 1; | 2662 | mos7840_port->zombie = 1; |
2657 | spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); | 2663 | spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); |
2658 | usb_kill_urb(mos7840_port->control_urb); | 2664 | usb_kill_urb(mos7840_port->control_urb); |
2665 | } | ||
2666 | } | ||
2667 | |||
2668 | dbg("%s", "Thank u :: "); | ||
2669 | |||
2670 | } | ||
2671 | |||
2672 | /**************************************************************************** | ||
2673 | * mos7840_release | ||
2674 | * This function is called when the usb_serial structure is freed. | ||
2675 | ****************************************************************************/ | ||
2676 | |||
2677 | static void mos7840_release(struct usb_serial *serial) | ||
2678 | { | ||
2679 | int i; | ||
2680 | struct moschip_port *mos7840_port; | ||
2681 | dbg("%s", " release :entering.........."); | ||
2682 | |||
2683 | if (!serial) { | ||
2684 | dbg("%s", "Invalid Handler"); | ||
2685 | return; | ||
2686 | } | ||
2687 | |||
2688 | /* check for the ports to be closed,close the ports and disconnect */ | ||
2689 | |||
2690 | /* free private structure allocated for serial port * | ||
2691 | * stop reads and writes on all ports */ | ||
2692 | |||
2693 | for (i = 0; i < serial->num_ports; ++i) { | ||
2694 | mos7840_port = mos7840_get_port_private(serial->port[i]); | ||
2695 | dbg("mos7840_port %d = %p", i, mos7840_port); | ||
2696 | if (mos7840_port) { | ||
2659 | kfree(mos7840_port->ctrl_buf); | 2697 | kfree(mos7840_port->ctrl_buf); |
2660 | kfree(mos7840_port->dr); | 2698 | kfree(mos7840_port->dr); |
2661 | kfree(mos7840_port); | 2699 | kfree(mos7840_port); |
2662 | } | 2700 | } |
2663 | mos7840_set_port_private(serial->port[i], NULL); | ||
2664 | } | 2701 | } |
2665 | 2702 | ||
2666 | dbg("%s\n", "Thank u :: "); | 2703 | dbg("%s", "Thank u :: "); |
2667 | 2704 | ||
2668 | } | 2705 | } |
2669 | 2706 | ||
@@ -2701,7 +2738,8 @@ static struct usb_serial_driver moschip7840_4port_device = { | |||
2701 | .tiocmget = mos7840_tiocmget, | 2738 | .tiocmget = mos7840_tiocmget, |
2702 | .tiocmset = mos7840_tiocmset, | 2739 | .tiocmset = mos7840_tiocmset, |
2703 | .attach = mos7840_startup, | 2740 | .attach = mos7840_startup, |
2704 | .shutdown = mos7840_shutdown, | 2741 | .disconnect = mos7840_disconnect, |
2742 | .release = mos7840_release, | ||
2705 | .read_bulk_callback = mos7840_bulk_in_callback, | 2743 | .read_bulk_callback = mos7840_bulk_in_callback, |
2706 | .read_int_callback = mos7840_interrupt_callback, | 2744 | .read_int_callback = mos7840_interrupt_callback, |
2707 | }; | 2745 | }; |
@@ -2714,7 +2752,7 @@ static int __init moschip7840_init(void) | |||
2714 | { | 2752 | { |
2715 | int retval; | 2753 | int retval; |
2716 | 2754 | ||
2717 | dbg("%s \n", " mos7840_init :entering.........."); | 2755 | dbg("%s", " mos7840_init :entering.........."); |
2718 | 2756 | ||
2719 | /* Register with the usb serial */ | 2757 | /* Register with the usb serial */ |
2720 | retval = usb_serial_register(&moschip7840_4port_device); | 2758 | retval = usb_serial_register(&moschip7840_4port_device); |
@@ -2722,14 +2760,14 @@ static int __init moschip7840_init(void) | |||
2722 | if (retval) | 2760 | if (retval) |
2723 | goto failed_port_device_register; | 2761 | goto failed_port_device_register; |
2724 | 2762 | ||
2725 | dbg("%s\n", "Entring..."); | 2763 | dbg("%s", "Entering..."); |
2726 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | 2764 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
2727 | DRIVER_DESC "\n"); | 2765 | DRIVER_DESC "\n"); |
2728 | 2766 | ||
2729 | /* Register with the usb */ | 2767 | /* Register with the usb */ |
2730 | retval = usb_register(&io_driver); | 2768 | retval = usb_register(&io_driver); |
2731 | if (retval == 0) { | 2769 | if (retval == 0) { |
2732 | dbg("%s\n", "Leaving..."); | 2770 | dbg("%s", "Leaving..."); |
2733 | return 0; | 2771 | return 0; |
2734 | } | 2772 | } |
2735 | usb_serial_deregister(&moschip7840_4port_device); | 2773 | usb_serial_deregister(&moschip7840_4port_device); |
@@ -2744,13 +2782,13 @@ failed_port_device_register: | |||
2744 | static void __exit moschip7840_exit(void) | 2782 | static void __exit moschip7840_exit(void) |
2745 | { | 2783 | { |
2746 | 2784 | ||
2747 | dbg("%s \n", " mos7840_exit :entering.........."); | 2785 | dbg("%s", " mos7840_exit :entering.........."); |
2748 | 2786 | ||
2749 | usb_deregister(&io_driver); | 2787 | usb_deregister(&io_driver); |
2750 | 2788 | ||
2751 | usb_serial_deregister(&moschip7840_4port_device); | 2789 | usb_serial_deregister(&moschip7840_4port_device); |
2752 | 2790 | ||
2753 | dbg("%s\n", "Entring..."); | 2791 | dbg("%s", "Entering..."); |
2754 | } | 2792 | } |
2755 | 2793 | ||
2756 | module_init(moschip7840_init); | 2794 | module_init(moschip7840_init); |
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 1104617334f5..56857ddbd70b 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -72,7 +72,8 @@ static void omninet_write_bulk_callback(struct urb *urb); | |||
72 | static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | 72 | static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, |
73 | const unsigned char *buf, int count); | 73 | const unsigned char *buf, int count); |
74 | static int omninet_write_room(struct tty_struct *tty); | 74 | static int omninet_write_room(struct tty_struct *tty); |
75 | static void omninet_shutdown(struct usb_serial *serial); | 75 | static void omninet_disconnect(struct usb_serial *serial); |
76 | static void omninet_release(struct usb_serial *serial); | ||
76 | static int omninet_attach(struct usb_serial *serial); | 77 | static int omninet_attach(struct usb_serial *serial); |
77 | 78 | ||
78 | static struct usb_device_id id_table[] = { | 79 | static struct usb_device_id id_table[] = { |
@@ -108,7 +109,8 @@ static struct usb_serial_driver zyxel_omninet_device = { | |||
108 | .write_room = omninet_write_room, | 109 | .write_room = omninet_write_room, |
109 | .read_bulk_callback = omninet_read_bulk_callback, | 110 | .read_bulk_callback = omninet_read_bulk_callback, |
110 | .write_bulk_callback = omninet_write_bulk_callback, | 111 | .write_bulk_callback = omninet_write_bulk_callback, |
111 | .shutdown = omninet_shutdown, | 112 | .disconnect = omninet_disconnect, |
113 | .release = omninet_release, | ||
112 | }; | 114 | }; |
113 | 115 | ||
114 | 116 | ||
@@ -345,13 +347,22 @@ static void omninet_write_bulk_callback(struct urb *urb) | |||
345 | } | 347 | } |
346 | 348 | ||
347 | 349 | ||
348 | static void omninet_shutdown(struct usb_serial *serial) | 350 | static void omninet_disconnect(struct usb_serial *serial) |
349 | { | 351 | { |
350 | struct usb_serial_port *wport = serial->port[1]; | 352 | struct usb_serial_port *wport = serial->port[1]; |
351 | struct usb_serial_port *port = serial->port[0]; | 353 | |
352 | dbg("%s", __func__); | 354 | dbg("%s", __func__); |
353 | 355 | ||
354 | usb_kill_urb(wport->write_urb); | 356 | usb_kill_urb(wport->write_urb); |
357 | } | ||
358 | |||
359 | |||
360 | static void omninet_release(struct usb_serial *serial) | ||
361 | { | ||
362 | struct usb_serial_port *port = serial->port[0]; | ||
363 | |||
364 | dbg("%s", __func__); | ||
365 | |||
355 | kfree(usb_get_serial_port_data(port)); | 366 | kfree(usb_get_serial_port_data(port)); |
356 | } | 367 | } |
357 | 368 | ||
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index c20480aa9755..336bba79ad32 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c | |||
@@ -463,7 +463,7 @@ error: | |||
463 | return retval; | 463 | return retval; |
464 | } | 464 | } |
465 | 465 | ||
466 | static void opticon_shutdown(struct usb_serial *serial) | 466 | static void opticon_disconnect(struct usb_serial *serial) |
467 | { | 467 | { |
468 | struct opticon_private *priv = usb_get_serial_data(serial); | 468 | struct opticon_private *priv = usb_get_serial_data(serial); |
469 | 469 | ||
@@ -471,9 +471,16 @@ static void opticon_shutdown(struct usb_serial *serial) | |||
471 | 471 | ||
472 | usb_kill_urb(priv->bulk_read_urb); | 472 | usb_kill_urb(priv->bulk_read_urb); |
473 | usb_free_urb(priv->bulk_read_urb); | 473 | usb_free_urb(priv->bulk_read_urb); |
474 | } | ||
475 | |||
476 | static void opticon_release(struct usb_serial *serial) | ||
477 | { | ||
478 | struct opticon_private *priv = usb_get_serial_data(serial); | ||
479 | |||
480 | dbg("%s", __func__); | ||
481 | |||
474 | kfree(priv->bulk_in_buffer); | 482 | kfree(priv->bulk_in_buffer); |
475 | kfree(priv); | 483 | kfree(priv); |
476 | usb_set_serial_data(serial, NULL); | ||
477 | } | 484 | } |
478 | 485 | ||
479 | static int opticon_suspend(struct usb_interface *intf, pm_message_t message) | 486 | static int opticon_suspend(struct usb_interface *intf, pm_message_t message) |
@@ -524,7 +531,8 @@ static struct usb_serial_driver opticon_device = { | |||
524 | .close = opticon_close, | 531 | .close = opticon_close, |
525 | .write = opticon_write, | 532 | .write = opticon_write, |
526 | .write_room = opticon_write_room, | 533 | .write_room = opticon_write_room, |
527 | .shutdown = opticon_shutdown, | 534 | .disconnect = opticon_disconnect, |
535 | .release = opticon_release, | ||
528 | .throttle = opticon_throttle, | 536 | .throttle = opticon_throttle, |
529 | .unthrottle = opticon_unthrottle, | 537 | .unthrottle = opticon_unthrottle, |
530 | .ioctl = opticon_ioctl, | 538 | .ioctl = opticon_ioctl, |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index a16d69fadba1..575816e6ba37 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -43,13 +43,16 @@ | |||
43 | #include <linux/usb/serial.h> | 43 | #include <linux/usb/serial.h> |
44 | 44 | ||
45 | /* Function prototypes */ | 45 | /* Function prototypes */ |
46 | static int option_probe(struct usb_serial *serial, | ||
47 | const struct usb_device_id *id); | ||
46 | static int option_open(struct tty_struct *tty, struct usb_serial_port *port, | 48 | static int option_open(struct tty_struct *tty, struct usb_serial_port *port, |
47 | struct file *filp); | 49 | struct file *filp); |
48 | static void option_close(struct usb_serial_port *port); | 50 | static void option_close(struct usb_serial_port *port); |
49 | static void option_dtr_rts(struct usb_serial_port *port, int on); | 51 | static void option_dtr_rts(struct usb_serial_port *port, int on); |
50 | 52 | ||
51 | static int option_startup(struct usb_serial *serial); | 53 | static int option_startup(struct usb_serial *serial); |
52 | static void option_shutdown(struct usb_serial *serial); | 54 | static void option_disconnect(struct usb_serial *serial); |
55 | static void option_release(struct usb_serial *serial); | ||
53 | static int option_write_room(struct tty_struct *tty); | 56 | static int option_write_room(struct tty_struct *tty); |
54 | 57 | ||
55 | static void option_instat_callback(struct urb *urb); | 58 | static void option_instat_callback(struct urb *urb); |
@@ -202,9 +205,9 @@ static int option_resume(struct usb_serial *serial); | |||
202 | #define NOVATELWIRELESS_PRODUCT_MC727 0x4100 | 205 | #define NOVATELWIRELESS_PRODUCT_MC727 0x4100 |
203 | #define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 | 206 | #define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 |
204 | #define NOVATELWIRELESS_PRODUCT_U727 0x5010 | 207 | #define NOVATELWIRELESS_PRODUCT_U727 0x5010 |
208 | #define NOVATELWIRELESS_PRODUCT_MC760 0x6000 | ||
205 | 209 | ||
206 | /* FUTURE NOVATEL PRODUCTS */ | 210 | /* FUTURE NOVATEL PRODUCTS */ |
207 | #define NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED 0X6000 | ||
208 | #define NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED 0X6001 | 211 | #define NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED 0X6001 |
209 | #define NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED 0X7000 | 212 | #define NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED 0X7000 |
210 | #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED 0X7001 | 213 | #define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED 0X7001 |
@@ -305,6 +308,10 @@ static int option_resume(struct usb_serial *serial); | |||
305 | #define DLINK_PRODUCT_DWM_652 0x3e04 | 308 | #define DLINK_PRODUCT_DWM_652 0x3e04 |
306 | 309 | ||
307 | 310 | ||
311 | /* TOSHIBA PRODUCTS */ | ||
312 | #define TOSHIBA_VENDOR_ID 0x0930 | ||
313 | #define TOSHIBA_PRODUCT_HSDPA_MINICARD 0x1302 | ||
314 | |||
308 | static struct usb_device_id option_ids[] = { | 315 | static struct usb_device_id option_ids[] = { |
309 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, | 316 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
310 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, | 317 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, |
@@ -422,7 +429,7 @@ static struct usb_device_id option_ids[] = { | |||
422 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */ | 429 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */ |
423 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ | 430 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ |
424 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U727) }, /* Novatel MC727/U727/USB727 */ | 431 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U727) }, /* Novatel MC727/U727/USB727 */ |
425 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED) }, /* Novatel EVDO product */ | 432 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC760) }, /* Novatel MC760/U760/USB760 */ |
426 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED) }, /* Novatel HSPA product */ | 433 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED) }, /* Novatel HSPA product */ |
427 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) }, /* Novatel EVDO Embedded product */ | 434 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) }, /* Novatel EVDO Embedded product */ |
428 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) }, /* Novatel HSPA Embedded product */ | 435 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) }, /* Novatel HSPA Embedded product */ |
@@ -523,6 +530,7 @@ static struct usb_device_id option_ids[] = { | |||
523 | { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, | 530 | { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, |
524 | { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, | 531 | { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, |
525 | { USB_DEVICE(0x1da5, 0x4515) }, /* BenQ H20 */ | 532 | { USB_DEVICE(0x1da5, 0x4515) }, /* BenQ H20 */ |
533 | { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */ | ||
526 | { } /* Terminating entry */ | 534 | { } /* Terminating entry */ |
527 | }; | 535 | }; |
528 | MODULE_DEVICE_TABLE(usb, option_ids); | 536 | MODULE_DEVICE_TABLE(usb, option_ids); |
@@ -550,6 +558,7 @@ static struct usb_serial_driver option_1port_device = { | |||
550 | .usb_driver = &option_driver, | 558 | .usb_driver = &option_driver, |
551 | .id_table = option_ids, | 559 | .id_table = option_ids, |
552 | .num_ports = 1, | 560 | .num_ports = 1, |
561 | .probe = option_probe, | ||
553 | .open = option_open, | 562 | .open = option_open, |
554 | .close = option_close, | 563 | .close = option_close, |
555 | .dtr_rts = option_dtr_rts, | 564 | .dtr_rts = option_dtr_rts, |
@@ -560,7 +569,8 @@ static struct usb_serial_driver option_1port_device = { | |||
560 | .tiocmget = option_tiocmget, | 569 | .tiocmget = option_tiocmget, |
561 | .tiocmset = option_tiocmset, | 570 | .tiocmset = option_tiocmset, |
562 | .attach = option_startup, | 571 | .attach = option_startup, |
563 | .shutdown = option_shutdown, | 572 | .disconnect = option_disconnect, |
573 | .release = option_release, | ||
564 | .read_int_callback = option_instat_callback, | 574 | .read_int_callback = option_instat_callback, |
565 | .suspend = option_suspend, | 575 | .suspend = option_suspend, |
566 | .resume = option_resume, | 576 | .resume = option_resume, |
@@ -626,6 +636,18 @@ static void __exit option_exit(void) | |||
626 | module_init(option_init); | 636 | module_init(option_init); |
627 | module_exit(option_exit); | 637 | module_exit(option_exit); |
628 | 638 | ||
639 | static int option_probe(struct usb_serial *serial, | ||
640 | const struct usb_device_id *id) | ||
641 | { | ||
642 | /* D-Link DWM 652 still exposes CD-Rom emulation interface in modem mode */ | ||
643 | if (serial->dev->descriptor.idVendor == DLINK_VENDOR_ID && | ||
644 | serial->dev->descriptor.idProduct == DLINK_PRODUCT_DWM_652 && | ||
645 | serial->interface->cur_altsetting->desc.bInterfaceClass == 0x8) | ||
646 | return -ENODEV; | ||
647 | |||
648 | return 0; | ||
649 | } | ||
650 | |||
629 | static void option_set_termios(struct tty_struct *tty, | 651 | static void option_set_termios(struct tty_struct *tty, |
630 | struct usb_serial_port *port, struct ktermios *old_termios) | 652 | struct usb_serial_port *port, struct ktermios *old_termios) |
631 | { | 653 | { |
@@ -1129,7 +1151,14 @@ static void stop_read_write_urbs(struct usb_serial *serial) | |||
1129 | } | 1151 | } |
1130 | } | 1152 | } |
1131 | 1153 | ||
1132 | static void option_shutdown(struct usb_serial *serial) | 1154 | static void option_disconnect(struct usb_serial *serial) |
1155 | { | ||
1156 | dbg("%s", __func__); | ||
1157 | |||
1158 | stop_read_write_urbs(serial); | ||
1159 | } | ||
1160 | |||
1161 | static void option_release(struct usb_serial *serial) | ||
1133 | { | 1162 | { |
1134 | int i, j; | 1163 | int i, j; |
1135 | struct usb_serial_port *port; | 1164 | struct usb_serial_port *port; |
@@ -1137,8 +1166,6 @@ static void option_shutdown(struct usb_serial *serial) | |||
1137 | 1166 | ||
1138 | dbg("%s", __func__); | 1167 | dbg("%s", __func__); |
1139 | 1168 | ||
1140 | stop_read_write_urbs(serial); | ||
1141 | |||
1142 | /* Now free them */ | 1169 | /* Now free them */ |
1143 | for (i = 0; i < serial->num_ports; ++i) { | 1170 | for (i = 0; i < serial->num_ports; ++i) { |
1144 | port = serial->port[i]; | 1171 | port = serial->port[i]; |
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index 7de54781fe61..3cece27325e7 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -159,7 +159,7 @@ static int oti6858_tiocmget(struct tty_struct *tty, struct file *file); | |||
159 | static int oti6858_tiocmset(struct tty_struct *tty, struct file *file, | 159 | static int oti6858_tiocmset(struct tty_struct *tty, struct file *file, |
160 | unsigned int set, unsigned int clear); | 160 | unsigned int set, unsigned int clear); |
161 | static int oti6858_startup(struct usb_serial *serial); | 161 | static int oti6858_startup(struct usb_serial *serial); |
162 | static void oti6858_shutdown(struct usb_serial *serial); | 162 | static void oti6858_release(struct usb_serial *serial); |
163 | 163 | ||
164 | /* functions operating on buffers */ | 164 | /* functions operating on buffers */ |
165 | static struct oti6858_buf *oti6858_buf_alloc(unsigned int size); | 165 | static struct oti6858_buf *oti6858_buf_alloc(unsigned int size); |
@@ -194,7 +194,7 @@ static struct usb_serial_driver oti6858_device = { | |||
194 | .write_room = oti6858_write_room, | 194 | .write_room = oti6858_write_room, |
195 | .chars_in_buffer = oti6858_chars_in_buffer, | 195 | .chars_in_buffer = oti6858_chars_in_buffer, |
196 | .attach = oti6858_startup, | 196 | .attach = oti6858_startup, |
197 | .shutdown = oti6858_shutdown, | 197 | .release = oti6858_release, |
198 | }; | 198 | }; |
199 | 199 | ||
200 | struct oti6858_private { | 200 | struct oti6858_private { |
@@ -782,7 +782,7 @@ static int oti6858_ioctl(struct tty_struct *tty, struct file *file, | |||
782 | } | 782 | } |
783 | 783 | ||
784 | 784 | ||
785 | static void oti6858_shutdown(struct usb_serial *serial) | 785 | static void oti6858_release(struct usb_serial *serial) |
786 | { | 786 | { |
787 | struct oti6858_private *priv; | 787 | struct oti6858_private *priv; |
788 | int i; | 788 | int i; |
@@ -794,7 +794,6 @@ static void oti6858_shutdown(struct usb_serial *serial) | |||
794 | if (priv) { | 794 | if (priv) { |
795 | oti6858_buf_free(priv->buf); | 795 | oti6858_buf_free(priv->buf); |
796 | kfree(priv); | 796 | kfree(priv); |
797 | usb_set_serial_port_data(serial->port[i], NULL); | ||
798 | } | 797 | } |
799 | } | 798 | } |
800 | } | 799 | } |
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index e02dc3d643c7..ec6c132a25b5 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -878,7 +878,7 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state) | |||
878 | dbg("%s - error sending break = %d", __func__, result); | 878 | dbg("%s - error sending break = %d", __func__, result); |
879 | } | 879 | } |
880 | 880 | ||
881 | static void pl2303_shutdown(struct usb_serial *serial) | 881 | static void pl2303_release(struct usb_serial *serial) |
882 | { | 882 | { |
883 | int i; | 883 | int i; |
884 | struct pl2303_private *priv; | 884 | struct pl2303_private *priv; |
@@ -890,7 +890,6 @@ static void pl2303_shutdown(struct usb_serial *serial) | |||
890 | if (priv) { | 890 | if (priv) { |
891 | pl2303_buf_free(priv->buf); | 891 | pl2303_buf_free(priv->buf); |
892 | kfree(priv); | 892 | kfree(priv); |
893 | usb_set_serial_port_data(serial->port[i], NULL); | ||
894 | } | 893 | } |
895 | } | 894 | } |
896 | } | 895 | } |
@@ -927,6 +926,8 @@ static void pl2303_update_line_status(struct usb_serial_port *port, | |||
927 | spin_lock_irqsave(&priv->lock, flags); | 926 | spin_lock_irqsave(&priv->lock, flags); |
928 | priv->line_status = data[status_idx]; | 927 | priv->line_status = data[status_idx]; |
929 | spin_unlock_irqrestore(&priv->lock, flags); | 928 | spin_unlock_irqrestore(&priv->lock, flags); |
929 | if (priv->line_status & UART_BREAK_ERROR) | ||
930 | usb_serial_handle_break(port); | ||
930 | wake_up_interruptible(&priv->delta_msr_wait); | 931 | wake_up_interruptible(&priv->delta_msr_wait); |
931 | } | 932 | } |
932 | 933 | ||
@@ -1037,7 +1038,8 @@ static void pl2303_read_bulk_callback(struct urb *urb) | |||
1037 | if (line_status & UART_OVERRUN_ERROR) | 1038 | if (line_status & UART_OVERRUN_ERROR) |
1038 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); | 1039 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
1039 | for (i = 0; i < urb->actual_length; ++i) | 1040 | for (i = 0; i < urb->actual_length; ++i) |
1040 | tty_insert_flip_char(tty, data[i], tty_flag); | 1041 | if (!usb_serial_handle_sysrq_char(port, data[i])) |
1042 | tty_insert_flip_char(tty, data[i], tty_flag); | ||
1041 | tty_flip_buffer_push(tty); | 1043 | tty_flip_buffer_push(tty); |
1042 | } | 1044 | } |
1043 | tty_kref_put(tty); | 1045 | tty_kref_put(tty); |
@@ -1120,7 +1122,7 @@ static struct usb_serial_driver pl2303_device = { | |||
1120 | .write_room = pl2303_write_room, | 1122 | .write_room = pl2303_write_room, |
1121 | .chars_in_buffer = pl2303_chars_in_buffer, | 1123 | .chars_in_buffer = pl2303_chars_in_buffer, |
1122 | .attach = pl2303_startup, | 1124 | .attach = pl2303_startup, |
1123 | .shutdown = pl2303_shutdown, | 1125 | .release = pl2303_release, |
1124 | }; | 1126 | }; |
1125 | 1127 | ||
1126 | static int __init pl2303_init(void) | 1128 | static int __init pl2303_init(void) |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 17ac34f4d668..032f7aeb40a4 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -1,7 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | USB Driver for Sierra Wireless | 2 | USB Driver for Sierra Wireless |
3 | 3 | ||
4 | Copyright (C) 2006, 2007, 2008 Kevin Lloyd <klloyd@sierrawireless.com> | 4 | Copyright (C) 2006, 2007, 2008 Kevin Lloyd <klloyd@sierrawireless.com>, |
5 | |||
6 | Copyright (C) 2008, 2009 Elina Pasheva, Matthew Safar, Rory Filer | ||
7 | <linux@sierrawireless.com> | ||
5 | 8 | ||
6 | IMPORTANT DISCLAIMER: This driver is not commercially supported by | 9 | IMPORTANT DISCLAIMER: This driver is not commercially supported by |
7 | Sierra Wireless. Use at your own risk. | 10 | Sierra Wireless. Use at your own risk. |
@@ -14,8 +17,8 @@ | |||
14 | Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> | 17 | Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> |
15 | */ | 18 | */ |
16 | 19 | ||
17 | #define DRIVER_VERSION "v.1.3.3" | 20 | #define DRIVER_VERSION "v.1.3.7" |
18 | #define DRIVER_AUTHOR "Kevin Lloyd <klloyd@sierrawireless.com>" | 21 | #define DRIVER_AUTHOR "Kevin Lloyd, Elina Pasheva, Matthew Safar, Rory Filer" |
19 | #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" | 22 | #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" |
20 | 23 | ||
21 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
@@ -30,10 +33,15 @@ | |||
30 | #define SWIMS_USB_REQUEST_SetPower 0x00 | 33 | #define SWIMS_USB_REQUEST_SetPower 0x00 |
31 | #define SWIMS_USB_REQUEST_SetNmea 0x07 | 34 | #define SWIMS_USB_REQUEST_SetNmea 0x07 |
32 | 35 | ||
33 | #define N_IN_URB 4 | 36 | #define N_IN_URB 8 |
34 | #define N_OUT_URB 4 | 37 | #define N_OUT_URB 64 |
35 | #define IN_BUFLEN 4096 | 38 | #define IN_BUFLEN 4096 |
36 | 39 | ||
40 | #define MAX_TRANSFER (PAGE_SIZE - 512) | ||
41 | /* MAX_TRANSFER is chosen so that the VM is not stressed by | ||
42 | allocations > PAGE_SIZE and the number of packets in a page | ||
43 | is an integer 512 is the largest possible packet on EHCI */ | ||
44 | |||
37 | static int debug; | 45 | static int debug; |
38 | static int nmea; | 46 | static int nmea; |
39 | 47 | ||
@@ -46,7 +54,7 @@ struct sierra_iface_info { | |||
46 | static int sierra_set_power_state(struct usb_device *udev, __u16 swiState) | 54 | static int sierra_set_power_state(struct usb_device *udev, __u16 swiState) |
47 | { | 55 | { |
48 | int result; | 56 | int result; |
49 | dev_dbg(&udev->dev, "%s", __func__); | 57 | dev_dbg(&udev->dev, "%s\n", __func__); |
50 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 58 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
51 | SWIMS_USB_REQUEST_SetPower, /* __u8 request */ | 59 | SWIMS_USB_REQUEST_SetPower, /* __u8 request */ |
52 | USB_TYPE_VENDOR, /* __u8 request type */ | 60 | USB_TYPE_VENDOR, /* __u8 request type */ |
@@ -61,7 +69,7 @@ static int sierra_set_power_state(struct usb_device *udev, __u16 swiState) | |||
61 | static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable) | 69 | static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable) |
62 | { | 70 | { |
63 | int result; | 71 | int result; |
64 | dev_dbg(&udev->dev, "%s", __func__); | 72 | dev_dbg(&udev->dev, "%s\n", __func__); |
65 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 73 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
66 | SWIMS_USB_REQUEST_SetNmea, /* __u8 request */ | 74 | SWIMS_USB_REQUEST_SetNmea, /* __u8 request */ |
67 | USB_TYPE_VENDOR, /* __u8 request type */ | 75 | USB_TYPE_VENDOR, /* __u8 request type */ |
@@ -75,18 +83,22 @@ static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable) | |||
75 | 83 | ||
76 | static int sierra_calc_num_ports(struct usb_serial *serial) | 84 | static int sierra_calc_num_ports(struct usb_serial *serial) |
77 | { | 85 | { |
78 | int result; | 86 | int num_ports = 0; |
79 | int *num_ports = usb_get_serial_data(serial); | 87 | u8 ifnum, numendpoints; |
80 | dev_dbg(&serial->dev->dev, "%s", __func__); | ||
81 | 88 | ||
82 | result = *num_ports; | 89 | dev_dbg(&serial->dev->dev, "%s\n", __func__); |
83 | 90 | ||
84 | if (result) { | 91 | ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; |
85 | kfree(num_ports); | 92 | numendpoints = serial->interface->cur_altsetting->desc.bNumEndpoints; |
86 | usb_set_serial_data(serial, NULL); | ||
87 | } | ||
88 | 93 | ||
89 | return result; | 94 | /* Dummy interface present on some SKUs should be ignored */ |
95 | if (ifnum == 0x99) | ||
96 | num_ports = 0; | ||
97 | else if (numendpoints <= 3) | ||
98 | num_ports = 1; | ||
99 | else | ||
100 | num_ports = (numendpoints-1)/2; | ||
101 | return num_ports; | ||
90 | } | 102 | } |
91 | 103 | ||
92 | static int is_blacklisted(const u8 ifnum, | 104 | static int is_blacklisted(const u8 ifnum, |
@@ -111,7 +123,7 @@ static int sierra_calc_interface(struct usb_serial *serial) | |||
111 | int interface; | 123 | int interface; |
112 | struct usb_interface *p_interface; | 124 | struct usb_interface *p_interface; |
113 | struct usb_host_interface *p_host_interface; | 125 | struct usb_host_interface *p_host_interface; |
114 | dev_dbg(&serial->dev->dev, "%s", __func__); | 126 | dev_dbg(&serial->dev->dev, "%s\n", __func__); |
115 | 127 | ||
116 | /* Get the interface structure pointer from the serial struct */ | 128 | /* Get the interface structure pointer from the serial struct */ |
117 | p_interface = serial->interface; | 129 | p_interface = serial->interface; |
@@ -132,23 +144,12 @@ static int sierra_probe(struct usb_serial *serial, | |||
132 | { | 144 | { |
133 | int result = 0; | 145 | int result = 0; |
134 | struct usb_device *udev; | 146 | struct usb_device *udev; |
135 | int *num_ports; | ||
136 | u8 ifnum; | 147 | u8 ifnum; |
137 | u8 numendpoints; | ||
138 | 148 | ||
139 | dev_dbg(&serial->dev->dev, "%s", __func__); | ||
140 | |||
141 | num_ports = kmalloc(sizeof(*num_ports), GFP_KERNEL); | ||
142 | if (!num_ports) | ||
143 | return -ENOMEM; | ||
144 | |||
145 | ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; | ||
146 | numendpoints = serial->interface->cur_altsetting->desc.bNumEndpoints; | ||
147 | udev = serial->dev; | 149 | udev = serial->dev; |
150 | dev_dbg(&udev->dev, "%s\n", __func__); | ||
148 | 151 | ||
149 | /* Figure out the interface number from the serial structure */ | ||
150 | ifnum = sierra_calc_interface(serial); | 152 | ifnum = sierra_calc_interface(serial); |
151 | |||
152 | /* | 153 | /* |
153 | * If this interface supports more than 1 alternate | 154 | * If this interface supports more than 1 alternate |
154 | * select the 2nd one | 155 | * select the 2nd one |
@@ -160,20 +161,6 @@ static int sierra_probe(struct usb_serial *serial, | |||
160 | usb_set_interface(udev, ifnum, 1); | 161 | usb_set_interface(udev, ifnum, 1); |
161 | } | 162 | } |
162 | 163 | ||
163 | /* Dummy interface present on some SKUs should be ignored */ | ||
164 | if (ifnum == 0x99) | ||
165 | *num_ports = 0; | ||
166 | else if (numendpoints <= 3) | ||
167 | *num_ports = 1; | ||
168 | else | ||
169 | *num_ports = (numendpoints-1)/2; | ||
170 | |||
171 | /* | ||
172 | * save off our num_ports info so that we can use it in the | ||
173 | * calc_num_ports callback | ||
174 | */ | ||
175 | usb_set_serial_data(serial, (void *)num_ports); | ||
176 | |||
177 | /* ifnum could have changed - by calling usb_set_interface */ | 164 | /* ifnum could have changed - by calling usb_set_interface */ |
178 | ifnum = sierra_calc_interface(serial); | 165 | ifnum = sierra_calc_interface(serial); |
179 | 166 | ||
@@ -289,7 +276,7 @@ static int sierra_send_setup(struct usb_serial_port *port) | |||
289 | __u16 interface = 0; | 276 | __u16 interface = 0; |
290 | int val = 0; | 277 | int val = 0; |
291 | 278 | ||
292 | dev_dbg(&port->dev, "%s", __func__); | 279 | dev_dbg(&port->dev, "%s\n", __func__); |
293 | 280 | ||
294 | portdata = usb_get_serial_port_data(port); | 281 | portdata = usb_get_serial_port_data(port); |
295 | 282 | ||
@@ -332,7 +319,7 @@ static int sierra_send_setup(struct usb_serial_port *port) | |||
332 | static void sierra_set_termios(struct tty_struct *tty, | 319 | static void sierra_set_termios(struct tty_struct *tty, |
333 | struct usb_serial_port *port, struct ktermios *old_termios) | 320 | struct usb_serial_port *port, struct ktermios *old_termios) |
334 | { | 321 | { |
335 | dev_dbg(&port->dev, "%s", __func__); | 322 | dev_dbg(&port->dev, "%s\n", __func__); |
336 | tty_termios_copy_hw(tty->termios, old_termios); | 323 | tty_termios_copy_hw(tty->termios, old_termios); |
337 | sierra_send_setup(port); | 324 | sierra_send_setup(port); |
338 | } | 325 | } |
@@ -343,7 +330,7 @@ static int sierra_tiocmget(struct tty_struct *tty, struct file *file) | |||
343 | unsigned int value; | 330 | unsigned int value; |
344 | struct sierra_port_private *portdata; | 331 | struct sierra_port_private *portdata; |
345 | 332 | ||
346 | dev_dbg(&port->dev, "%s", __func__); | 333 | dev_dbg(&port->dev, "%s\n", __func__); |
347 | portdata = usb_get_serial_port_data(port); | 334 | portdata = usb_get_serial_port_data(port); |
348 | 335 | ||
349 | value = ((portdata->rts_state) ? TIOCM_RTS : 0) | | 336 | value = ((portdata->rts_state) ? TIOCM_RTS : 0) | |
@@ -394,14 +381,14 @@ static void sierra_outdat_callback(struct urb *urb) | |||
394 | int status = urb->status; | 381 | int status = urb->status; |
395 | unsigned long flags; | 382 | unsigned long flags; |
396 | 383 | ||
397 | dev_dbg(&port->dev, "%s - port %d", __func__, port->number); | 384 | dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number); |
398 | 385 | ||
399 | /* free up the transfer buffer, as usb_free_urb() does not do this */ | 386 | /* free up the transfer buffer, as usb_free_urb() does not do this */ |
400 | kfree(urb->transfer_buffer); | 387 | kfree(urb->transfer_buffer); |
401 | 388 | ||
402 | if (status) | 389 | if (status) |
403 | dev_dbg(&port->dev, "%s - nonzero write bulk status " | 390 | dev_dbg(&port->dev, "%s - nonzero write bulk status " |
404 | "received: %d", __func__, status); | 391 | "received: %d\n", __func__, status); |
405 | 392 | ||
406 | spin_lock_irqsave(&portdata->lock, flags); | 393 | spin_lock_irqsave(&portdata->lock, flags); |
407 | --portdata->outstanding_urbs; | 394 | --portdata->outstanding_urbs; |
@@ -419,50 +406,61 @@ static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
419 | unsigned long flags; | 406 | unsigned long flags; |
420 | unsigned char *buffer; | 407 | unsigned char *buffer; |
421 | struct urb *urb; | 408 | struct urb *urb; |
422 | int status; | 409 | size_t writesize = min((size_t)count, (size_t)MAX_TRANSFER); |
410 | int retval = 0; | ||
411 | |||
412 | /* verify that we actually have some data to write */ | ||
413 | if (count == 0) | ||
414 | return 0; | ||
423 | 415 | ||
424 | portdata = usb_get_serial_port_data(port); | 416 | portdata = usb_get_serial_port_data(port); |
425 | 417 | ||
426 | dev_dbg(&port->dev, "%s: write (%d chars)", __func__, count); | 418 | dev_dbg(&port->dev, "%s: write (%zd bytes)\n", __func__, writesize); |
427 | 419 | ||
428 | spin_lock_irqsave(&portdata->lock, flags); | 420 | spin_lock_irqsave(&portdata->lock, flags); |
421 | dev_dbg(&port->dev, "%s - outstanding_urbs: %d\n", __func__, | ||
422 | portdata->outstanding_urbs); | ||
429 | if (portdata->outstanding_urbs > N_OUT_URB) { | 423 | if (portdata->outstanding_urbs > N_OUT_URB) { |
430 | spin_unlock_irqrestore(&portdata->lock, flags); | 424 | spin_unlock_irqrestore(&portdata->lock, flags); |
431 | dev_dbg(&port->dev, "%s - write limit hit\n", __func__); | 425 | dev_dbg(&port->dev, "%s - write limit hit\n", __func__); |
432 | return 0; | 426 | return 0; |
433 | } | 427 | } |
434 | portdata->outstanding_urbs++; | 428 | portdata->outstanding_urbs++; |
429 | dev_dbg(&port->dev, "%s - 1, outstanding_urbs: %d\n", __func__, | ||
430 | portdata->outstanding_urbs); | ||
435 | spin_unlock_irqrestore(&portdata->lock, flags); | 431 | spin_unlock_irqrestore(&portdata->lock, flags); |
436 | 432 | ||
437 | buffer = kmalloc(count, GFP_ATOMIC); | 433 | buffer = kmalloc(writesize, GFP_ATOMIC); |
438 | if (!buffer) { | 434 | if (!buffer) { |
439 | dev_err(&port->dev, "out of memory\n"); | 435 | dev_err(&port->dev, "out of memory\n"); |
440 | count = -ENOMEM; | 436 | retval = -ENOMEM; |
441 | goto error_no_buffer; | 437 | goto error_no_buffer; |
442 | } | 438 | } |
443 | 439 | ||
444 | urb = usb_alloc_urb(0, GFP_ATOMIC); | 440 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
445 | if (!urb) { | 441 | if (!urb) { |
446 | dev_err(&port->dev, "no more free urbs\n"); | 442 | dev_err(&port->dev, "no more free urbs\n"); |
447 | count = -ENOMEM; | 443 | retval = -ENOMEM; |
448 | goto error_no_urb; | 444 | goto error_no_urb; |
449 | } | 445 | } |
450 | 446 | ||
451 | memcpy(buffer, buf, count); | 447 | memcpy(buffer, buf, writesize); |
452 | 448 | ||
453 | usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); | 449 | usb_serial_debug_data(debug, &port->dev, __func__, writesize, buffer); |
454 | 450 | ||
455 | usb_fill_bulk_urb(urb, serial->dev, | 451 | usb_fill_bulk_urb(urb, serial->dev, |
456 | usb_sndbulkpipe(serial->dev, | 452 | usb_sndbulkpipe(serial->dev, |
457 | port->bulk_out_endpointAddress), | 453 | port->bulk_out_endpointAddress), |
458 | buffer, count, sierra_outdat_callback, port); | 454 | buffer, writesize, sierra_outdat_callback, port); |
455 | |||
456 | /* Handle the need to send a zero length packet */ | ||
457 | urb->transfer_flags |= URB_ZERO_PACKET; | ||
459 | 458 | ||
460 | /* send it down the pipe */ | 459 | /* send it down the pipe */ |
461 | status = usb_submit_urb(urb, GFP_ATOMIC); | 460 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
462 | if (status) { | 461 | if (retval) { |
463 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " | 462 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " |
464 | "with status = %d\n", __func__, status); | 463 | "with status = %d\n", __func__, retval); |
465 | count = status; | ||
466 | goto error; | 464 | goto error; |
467 | } | 465 | } |
468 | 466 | ||
@@ -470,7 +468,7 @@ static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
470 | * really free it when it is finished with it */ | 468 | * really free it when it is finished with it */ |
471 | usb_free_urb(urb); | 469 | usb_free_urb(urb); |
472 | 470 | ||
473 | return count; | 471 | return writesize; |
474 | error: | 472 | error: |
475 | usb_free_urb(urb); | 473 | usb_free_urb(urb); |
476 | error_no_urb: | 474 | error_no_urb: |
@@ -478,8 +476,10 @@ error_no_urb: | |||
478 | error_no_buffer: | 476 | error_no_buffer: |
479 | spin_lock_irqsave(&portdata->lock, flags); | 477 | spin_lock_irqsave(&portdata->lock, flags); |
480 | --portdata->outstanding_urbs; | 478 | --portdata->outstanding_urbs; |
479 | dev_dbg(&port->dev, "%s - 2. outstanding_urbs: %d\n", __func__, | ||
480 | portdata->outstanding_urbs); | ||
481 | spin_unlock_irqrestore(&portdata->lock, flags); | 481 | spin_unlock_irqrestore(&portdata->lock, flags); |
482 | return count; | 482 | return retval; |
483 | } | 483 | } |
484 | 484 | ||
485 | static void sierra_indat_callback(struct urb *urb) | 485 | static void sierra_indat_callback(struct urb *urb) |
@@ -491,33 +491,39 @@ static void sierra_indat_callback(struct urb *urb) | |||
491 | unsigned char *data = urb->transfer_buffer; | 491 | unsigned char *data = urb->transfer_buffer; |
492 | int status = urb->status; | 492 | int status = urb->status; |
493 | 493 | ||
494 | dbg("%s: %p", __func__, urb); | ||
495 | |||
496 | endpoint = usb_pipeendpoint(urb->pipe); | 494 | endpoint = usb_pipeendpoint(urb->pipe); |
497 | port = urb->context; | 495 | port = urb->context; |
496 | |||
497 | dev_dbg(&port->dev, "%s: %p\n", __func__, urb); | ||
498 | 498 | ||
499 | if (status) { | 499 | if (status) { |
500 | dev_dbg(&port->dev, "%s: nonzero status: %d on" | 500 | dev_dbg(&port->dev, "%s: nonzero status: %d on" |
501 | " endpoint %02x.", __func__, status, endpoint); | 501 | " endpoint %02x\n", __func__, status, endpoint); |
502 | } else { | 502 | } else { |
503 | if (urb->actual_length) { | 503 | if (urb->actual_length) { |
504 | tty = tty_port_tty_get(&port->port); | 504 | tty = tty_port_tty_get(&port->port); |
505 | |||
505 | tty_buffer_request_room(tty, urb->actual_length); | 506 | tty_buffer_request_room(tty, urb->actual_length); |
506 | tty_insert_flip_string(tty, data, urb->actual_length); | 507 | tty_insert_flip_string(tty, data, urb->actual_length); |
507 | tty_flip_buffer_push(tty); | 508 | tty_flip_buffer_push(tty); |
509 | |||
508 | tty_kref_put(tty); | 510 | tty_kref_put(tty); |
509 | } else | 511 | usb_serial_debug_data(debug, &port->dev, __func__, |
512 | urb->actual_length, data); | ||
513 | } else { | ||
510 | dev_dbg(&port->dev, "%s: empty read urb" | 514 | dev_dbg(&port->dev, "%s: empty read urb" |
511 | " received", __func__); | 515 | " received\n", __func__); |
512 | |||
513 | /* Resubmit urb so we continue receiving */ | ||
514 | if (port->port.count && status != -ESHUTDOWN && status != -EPERM) { | ||
515 | err = usb_submit_urb(urb, GFP_ATOMIC); | ||
516 | if (err) | ||
517 | dev_err(&port->dev, "resubmit read urb failed." | ||
518 | "(%d)\n", err); | ||
519 | } | 516 | } |
520 | } | 517 | } |
518 | |||
519 | /* Resubmit urb so we continue receiving */ | ||
520 | if (port->port.count && status != -ESHUTDOWN && status != -EPERM) { | ||
521 | err = usb_submit_urb(urb, GFP_ATOMIC); | ||
522 | if (err) | ||
523 | dev_err(&port->dev, "resubmit read urb failed." | ||
524 | "(%d)\n", err); | ||
525 | } | ||
526 | |||
521 | return; | 527 | return; |
522 | } | 528 | } |
523 | 529 | ||
@@ -529,8 +535,7 @@ static void sierra_instat_callback(struct urb *urb) | |||
529 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); | 535 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
530 | struct usb_serial *serial = port->serial; | 536 | struct usb_serial *serial = port->serial; |
531 | 537 | ||
532 | dev_dbg(&port->dev, "%s", __func__); | 538 | dev_dbg(&port->dev, "%s: urb %p port %p has data %p\n", __func__, |
533 | dev_dbg(&port->dev, "%s: urb %p port %p has data %p", __func__, | ||
534 | urb, port, portdata); | 539 | urb, port, portdata); |
535 | 540 | ||
536 | if (status == 0) { | 541 | if (status == 0) { |
@@ -550,7 +555,7 @@ static void sierra_instat_callback(struct urb *urb) | |||
550 | sizeof(struct usb_ctrlrequest)); | 555 | sizeof(struct usb_ctrlrequest)); |
551 | struct tty_struct *tty; | 556 | struct tty_struct *tty; |
552 | 557 | ||
553 | dev_dbg(&port->dev, "%s: signal x%x", __func__, | 558 | dev_dbg(&port->dev, "%s: signal x%x\n", __func__, |
554 | signals); | 559 | signals); |
555 | 560 | ||
556 | old_dcd_state = portdata->dcd_state; | 561 | old_dcd_state = portdata->dcd_state; |
@@ -565,20 +570,20 @@ static void sierra_instat_callback(struct urb *urb) | |||
565 | tty_hangup(tty); | 570 | tty_hangup(tty); |
566 | tty_kref_put(tty); | 571 | tty_kref_put(tty); |
567 | } else { | 572 | } else { |
568 | dev_dbg(&port->dev, "%s: type %x req %x", | 573 | dev_dbg(&port->dev, "%s: type %x req %x\n", |
569 | __func__, req_pkt->bRequestType, | 574 | __func__, req_pkt->bRequestType, |
570 | req_pkt->bRequest); | 575 | req_pkt->bRequest); |
571 | } | 576 | } |
572 | } else | 577 | } else |
573 | dev_dbg(&port->dev, "%s: error %d", __func__, status); | 578 | dev_dbg(&port->dev, "%s: error %d\n", __func__, status); |
574 | 579 | ||
575 | /* Resubmit urb so we continue receiving IRQ data */ | 580 | /* Resubmit urb so we continue receiving IRQ data */ |
576 | if (status != -ESHUTDOWN) { | 581 | if (port->port.count && status != -ESHUTDOWN && status != -ENOENT) { |
577 | urb->dev = serial->dev; | 582 | urb->dev = serial->dev; |
578 | err = usb_submit_urb(urb, GFP_ATOMIC); | 583 | err = usb_submit_urb(urb, GFP_ATOMIC); |
579 | if (err) | 584 | if (err) |
580 | dev_dbg(&port->dev, "%s: resubmit intr urb " | 585 | dev_err(&port->dev, "%s: resubmit intr urb " |
581 | "failed. (%d)", __func__, err); | 586 | "failed. (%d)\n", __func__, err); |
582 | } | 587 | } |
583 | } | 588 | } |
584 | 589 | ||
@@ -588,7 +593,7 @@ static int sierra_write_room(struct tty_struct *tty) | |||
588 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); | 593 | struct sierra_port_private *portdata = usb_get_serial_port_data(port); |
589 | unsigned long flags; | 594 | unsigned long flags; |
590 | 595 | ||
591 | dev_dbg(&port->dev, "%s - port %d", __func__, port->number); | 596 | dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number); |
592 | 597 | ||
593 | /* try to give a good number back based on if we have any free urbs at | 598 | /* try to give a good number back based on if we have any free urbs at |
594 | * this point in time */ | 599 | * this point in time */ |
@@ -729,7 +734,7 @@ static int sierra_open(struct tty_struct *tty, | |||
729 | 734 | ||
730 | portdata = usb_get_serial_port_data(port); | 735 | portdata = usb_get_serial_port_data(port); |
731 | 736 | ||
732 | dev_dbg(&port->dev, "%s", __func__); | 737 | dev_dbg(&port->dev, "%s\n", __func__); |
733 | 738 | ||
734 | /* Set some sane defaults */ | 739 | /* Set some sane defaults */ |
735 | portdata->rts_state = 1; | 740 | portdata->rts_state = 1; |
@@ -782,7 +787,7 @@ static int sierra_startup(struct usb_serial *serial) | |||
782 | struct sierra_port_private *portdata; | 787 | struct sierra_port_private *portdata; |
783 | int i; | 788 | int i; |
784 | 789 | ||
785 | dev_dbg(&serial->dev->dev, "%s", __func__); | 790 | dev_dbg(&serial->dev->dev, "%s\n", __func__); |
786 | 791 | ||
787 | /* Set Device mode to D0 */ | 792 | /* Set Device mode to D0 */ |
788 | sierra_set_power_state(serial->dev, 0x0000); | 793 | sierra_set_power_state(serial->dev, 0x0000); |
@@ -797,7 +802,7 @@ static int sierra_startup(struct usb_serial *serial) | |||
797 | portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); | 802 | portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); |
798 | if (!portdata) { | 803 | if (!portdata) { |
799 | dev_dbg(&port->dev, "%s: kmalloc for " | 804 | dev_dbg(&port->dev, "%s: kmalloc for " |
800 | "sierra_port_private (%d) failed!.", | 805 | "sierra_port_private (%d) failed!.\n", |
801 | __func__, i); | 806 | __func__, i); |
802 | return -ENOMEM; | 807 | return -ENOMEM; |
803 | } | 808 | } |
@@ -809,13 +814,13 @@ static int sierra_startup(struct usb_serial *serial) | |||
809 | return 0; | 814 | return 0; |
810 | } | 815 | } |
811 | 816 | ||
812 | static void sierra_shutdown(struct usb_serial *serial) | 817 | static void sierra_disconnect(struct usb_serial *serial) |
813 | { | 818 | { |
814 | int i; | 819 | int i; |
815 | struct usb_serial_port *port; | 820 | struct usb_serial_port *port; |
816 | struct sierra_port_private *portdata; | 821 | struct sierra_port_private *portdata; |
817 | 822 | ||
818 | dev_dbg(&serial->dev->dev, "%s", __func__); | 823 | dev_dbg(&serial->dev->dev, "%s\n", __func__); |
819 | 824 | ||
820 | for (i = 0; i < serial->num_ports; ++i) { | 825 | for (i = 0; i < serial->num_ports; ++i) { |
821 | port = serial->port[i]; | 826 | port = serial->port[i]; |
@@ -848,7 +853,7 @@ static struct usb_serial_driver sierra_device = { | |||
848 | .tiocmget = sierra_tiocmget, | 853 | .tiocmget = sierra_tiocmget, |
849 | .tiocmset = sierra_tiocmset, | 854 | .tiocmset = sierra_tiocmset, |
850 | .attach = sierra_startup, | 855 | .attach = sierra_startup, |
851 | .shutdown = sierra_shutdown, | 856 | .disconnect = sierra_disconnect, |
852 | .read_int_callback = sierra_instat_callback, | 857 | .read_int_callback = sierra_instat_callback, |
853 | }; | 858 | }; |
854 | 859 | ||
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index 8f7ed8f13996..3c249d8e8b8e 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c | |||
@@ -356,7 +356,7 @@ cleanup: | |||
356 | } | 356 | } |
357 | 357 | ||
358 | /* call when the device plug out. free all the memory alloced by probe */ | 358 | /* call when the device plug out. free all the memory alloced by probe */ |
359 | static void spcp8x5_shutdown(struct usb_serial *serial) | 359 | static void spcp8x5_release(struct usb_serial *serial) |
360 | { | 360 | { |
361 | int i; | 361 | int i; |
362 | struct spcp8x5_private *priv; | 362 | struct spcp8x5_private *priv; |
@@ -366,7 +366,6 @@ static void spcp8x5_shutdown(struct usb_serial *serial) | |||
366 | if (priv) { | 366 | if (priv) { |
367 | free_ringbuf(priv->buf); | 367 | free_ringbuf(priv->buf); |
368 | kfree(priv); | 368 | kfree(priv); |
369 | usb_set_serial_port_data(serial->port[i] , NULL); | ||
370 | } | 369 | } |
371 | } | 370 | } |
372 | } | 371 | } |
@@ -1020,7 +1019,7 @@ static struct usb_serial_driver spcp8x5_device = { | |||
1020 | .write_bulk_callback = spcp8x5_write_bulk_callback, | 1019 | .write_bulk_callback = spcp8x5_write_bulk_callback, |
1021 | .chars_in_buffer = spcp8x5_chars_in_buffer, | 1020 | .chars_in_buffer = spcp8x5_chars_in_buffer, |
1022 | .attach = spcp8x5_startup, | 1021 | .attach = spcp8x5_startup, |
1023 | .shutdown = spcp8x5_shutdown, | 1022 | .release = spcp8x5_release, |
1024 | }; | 1023 | }; |
1025 | 1024 | ||
1026 | static int __init spcp8x5_init(void) | 1025 | static int __init spcp8x5_init(void) |
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c index 8b07ebc6baeb..6157fac9366b 100644 --- a/drivers/usb/serial/symbolserial.c +++ b/drivers/usb/serial/symbolserial.c | |||
@@ -267,7 +267,7 @@ error: | |||
267 | return retval; | 267 | return retval; |
268 | } | 268 | } |
269 | 269 | ||
270 | static void symbol_shutdown(struct usb_serial *serial) | 270 | static void symbol_disconnect(struct usb_serial *serial) |
271 | { | 271 | { |
272 | struct symbol_private *priv = usb_get_serial_data(serial); | 272 | struct symbol_private *priv = usb_get_serial_data(serial); |
273 | 273 | ||
@@ -275,9 +275,16 @@ static void symbol_shutdown(struct usb_serial *serial) | |||
275 | 275 | ||
276 | usb_kill_urb(priv->int_urb); | 276 | usb_kill_urb(priv->int_urb); |
277 | usb_free_urb(priv->int_urb); | 277 | usb_free_urb(priv->int_urb); |
278 | } | ||
279 | |||
280 | static void symbol_release(struct usb_serial *serial) | ||
281 | { | ||
282 | struct symbol_private *priv = usb_get_serial_data(serial); | ||
283 | |||
284 | dbg("%s", __func__); | ||
285 | |||
278 | kfree(priv->int_buffer); | 286 | kfree(priv->int_buffer); |
279 | kfree(priv); | 287 | kfree(priv); |
280 | usb_set_serial_data(serial, NULL); | ||
281 | } | 288 | } |
282 | 289 | ||
283 | static struct usb_driver symbol_driver = { | 290 | static struct usb_driver symbol_driver = { |
@@ -299,7 +306,8 @@ static struct usb_serial_driver symbol_device = { | |||
299 | .attach = symbol_startup, | 306 | .attach = symbol_startup, |
300 | .open = symbol_open, | 307 | .open = symbol_open, |
301 | .close = symbol_close, | 308 | .close = symbol_close, |
302 | .shutdown = symbol_shutdown, | 309 | .disconnect = symbol_disconnect, |
310 | .release = symbol_release, | ||
303 | .throttle = symbol_throttle, | 311 | .throttle = symbol_throttle, |
304 | .unthrottle = symbol_unthrottle, | 312 | .unthrottle = symbol_unthrottle, |
305 | }; | 313 | }; |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 42cb04c403be..991d8232e376 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -97,7 +97,7 @@ struct ti_device { | |||
97 | /* Function Declarations */ | 97 | /* Function Declarations */ |
98 | 98 | ||
99 | static int ti_startup(struct usb_serial *serial); | 99 | static int ti_startup(struct usb_serial *serial); |
100 | static void ti_shutdown(struct usb_serial *serial); | 100 | static void ti_release(struct usb_serial *serial); |
101 | static int ti_open(struct tty_struct *tty, struct usb_serial_port *port, | 101 | static int ti_open(struct tty_struct *tty, struct usb_serial_port *port, |
102 | struct file *file); | 102 | struct file *file); |
103 | static void ti_close(struct usb_serial_port *port); | 103 | static void ti_close(struct usb_serial_port *port); |
@@ -230,7 +230,7 @@ static struct usb_serial_driver ti_1port_device = { | |||
230 | .id_table = ti_id_table_3410, | 230 | .id_table = ti_id_table_3410, |
231 | .num_ports = 1, | 231 | .num_ports = 1, |
232 | .attach = ti_startup, | 232 | .attach = ti_startup, |
233 | .shutdown = ti_shutdown, | 233 | .release = ti_release, |
234 | .open = ti_open, | 234 | .open = ti_open, |
235 | .close = ti_close, | 235 | .close = ti_close, |
236 | .write = ti_write, | 236 | .write = ti_write, |
@@ -258,7 +258,7 @@ static struct usb_serial_driver ti_2port_device = { | |||
258 | .id_table = ti_id_table_5052, | 258 | .id_table = ti_id_table_5052, |
259 | .num_ports = 2, | 259 | .num_ports = 2, |
260 | .attach = ti_startup, | 260 | .attach = ti_startup, |
261 | .shutdown = ti_shutdown, | 261 | .release = ti_release, |
262 | .open = ti_open, | 262 | .open = ti_open, |
263 | .close = ti_close, | 263 | .close = ti_close, |
264 | .write = ti_write, | 264 | .write = ti_write, |
@@ -473,7 +473,7 @@ free_tdev: | |||
473 | } | 473 | } |
474 | 474 | ||
475 | 475 | ||
476 | static void ti_shutdown(struct usb_serial *serial) | 476 | static void ti_release(struct usb_serial *serial) |
477 | { | 477 | { |
478 | int i; | 478 | int i; |
479 | struct ti_device *tdev = usb_get_serial_data(serial); | 479 | struct ti_device *tdev = usb_get_serial_data(serial); |
@@ -486,12 +486,10 @@ static void ti_shutdown(struct usb_serial *serial) | |||
486 | if (tport) { | 486 | if (tport) { |
487 | ti_buf_free(tport->tp_write_buf); | 487 | ti_buf_free(tport->tp_write_buf); |
488 | kfree(tport); | 488 | kfree(tport); |
489 | usb_set_serial_port_data(serial->port[i], NULL); | ||
490 | } | 489 | } |
491 | } | 490 | } |
492 | 491 | ||
493 | kfree(tdev); | 492 | kfree(tdev); |
494 | usb_set_serial_data(serial, NULL); | ||
495 | } | 493 | } |
496 | 494 | ||
497 | 495 | ||
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 1967a7edc10c..d595aa5586a7 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -141,6 +141,14 @@ static void destroy_serial(struct kref *kref) | |||
141 | if (serial->minor != SERIAL_TTY_NO_MINOR) | 141 | if (serial->minor != SERIAL_TTY_NO_MINOR) |
142 | return_serial(serial); | 142 | return_serial(serial); |
143 | 143 | ||
144 | serial->type->release(serial); | ||
145 | |||
146 | for (i = 0; i < serial->num_ports; ++i) { | ||
147 | port = serial->port[i]; | ||
148 | if (port) | ||
149 | put_device(&port->dev); | ||
150 | } | ||
151 | |||
144 | /* If this is a "fake" port, we have to clean it up here, as it will | 152 | /* If this is a "fake" port, we have to clean it up here, as it will |
145 | * not get cleaned up in port_release() as it was never registered with | 153 | * not get cleaned up in port_release() as it was never registered with |
146 | * the driver core */ | 154 | * the driver core */ |
@@ -148,9 +156,8 @@ static void destroy_serial(struct kref *kref) | |||
148 | for (i = serial->num_ports; | 156 | for (i = serial->num_ports; |
149 | i < serial->num_port_pointers; ++i) { | 157 | i < serial->num_port_pointers; ++i) { |
150 | port = serial->port[i]; | 158 | port = serial->port[i]; |
151 | if (!port) | 159 | if (port) |
152 | continue; | 160 | port_free(port); |
153 | port_free(port); | ||
154 | } | 161 | } |
155 | } | 162 | } |
156 | 163 | ||
@@ -1046,10 +1053,15 @@ int usb_serial_probe(struct usb_interface *interface, | |||
1046 | 1053 | ||
1047 | dev_set_name(&port->dev, "ttyUSB%d", port->number); | 1054 | dev_set_name(&port->dev, "ttyUSB%d", port->number); |
1048 | dbg ("%s - registering %s", __func__, dev_name(&port->dev)); | 1055 | dbg ("%s - registering %s", __func__, dev_name(&port->dev)); |
1056 | port->dev_state = PORT_REGISTERING; | ||
1049 | retval = device_register(&port->dev); | 1057 | retval = device_register(&port->dev); |
1050 | if (retval) | 1058 | if (retval) { |
1051 | dev_err(&port->dev, "Error registering port device, " | 1059 | dev_err(&port->dev, "Error registering port device, " |
1052 | "continuing\n"); | 1060 | "continuing\n"); |
1061 | port->dev_state = PORT_UNREGISTERED; | ||
1062 | } else { | ||
1063 | port->dev_state = PORT_REGISTERED; | ||
1064 | } | ||
1053 | } | 1065 | } |
1054 | 1066 | ||
1055 | usb_serial_console_init(debug, minor); | 1067 | usb_serial_console_init(debug, minor); |
@@ -1113,10 +1125,6 @@ void usb_serial_disconnect(struct usb_interface *interface) | |||
1113 | serial->disconnected = 1; | 1125 | serial->disconnected = 1; |
1114 | mutex_unlock(&serial->disc_mutex); | 1126 | mutex_unlock(&serial->disc_mutex); |
1115 | 1127 | ||
1116 | /* Unfortunately, many of the sub-drivers expect the port structures | ||
1117 | * to exist when their shutdown method is called, so we have to go | ||
1118 | * through this awkward two-step unregistration procedure. | ||
1119 | */ | ||
1120 | for (i = 0; i < serial->num_ports; ++i) { | 1128 | for (i = 0; i < serial->num_ports; ++i) { |
1121 | port = serial->port[i]; | 1129 | port = serial->port[i]; |
1122 | if (port) { | 1130 | if (port) { |
@@ -1130,17 +1138,25 @@ void usb_serial_disconnect(struct usb_interface *interface) | |||
1130 | } | 1138 | } |
1131 | kill_traffic(port); | 1139 | kill_traffic(port); |
1132 | cancel_work_sync(&port->work); | 1140 | cancel_work_sync(&port->work); |
1133 | device_del(&port->dev); | 1141 | if (port->dev_state == PORT_REGISTERED) { |
1134 | } | 1142 | |
1135 | } | 1143 | /* Make sure the port is bound so that the |
1136 | serial->type->shutdown(serial); | 1144 | * driver's port_remove method is called. |
1137 | for (i = 0; i < serial->num_ports; ++i) { | 1145 | */ |
1138 | port = serial->port[i]; | 1146 | if (!port->dev.driver) { |
1139 | if (port) { | 1147 | int rc; |
1140 | put_device(&port->dev); | 1148 | |
1141 | serial->port[i] = NULL; | 1149 | port->dev.driver = |
1150 | &serial->type->driver; | ||
1151 | rc = device_bind_driver(&port->dev); | ||
1152 | } | ||
1153 | port->dev_state = PORT_UNREGISTERING; | ||
1154 | device_del(&port->dev); | ||
1155 | port->dev_state = PORT_UNREGISTERED; | ||
1156 | } | ||
1142 | } | 1157 | } |
1143 | } | 1158 | } |
1159 | serial->type->disconnect(serial); | ||
1144 | 1160 | ||
1145 | /* let the last holder of this object | 1161 | /* let the last holder of this object |
1146 | * cause it to be cleaned up */ | 1162 | * cause it to be cleaned up */ |
@@ -1318,7 +1334,8 @@ static void fixup_generic(struct usb_serial_driver *device) | |||
1318 | set_to_generic_if_null(device, chars_in_buffer); | 1334 | set_to_generic_if_null(device, chars_in_buffer); |
1319 | set_to_generic_if_null(device, read_bulk_callback); | 1335 | set_to_generic_if_null(device, read_bulk_callback); |
1320 | set_to_generic_if_null(device, write_bulk_callback); | 1336 | set_to_generic_if_null(device, write_bulk_callback); |
1321 | set_to_generic_if_null(device, shutdown); | 1337 | set_to_generic_if_null(device, disconnect); |
1338 | set_to_generic_if_null(device, release); | ||
1322 | } | 1339 | } |
1323 | 1340 | ||
1324 | int usb_serial_register(struct usb_serial_driver *driver) | 1341 | int usb_serial_register(struct usb_serial_driver *driver) |
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c index 6c9cbb59552a..614800972dc3 100644 --- a/drivers/usb/serial/usb_debug.c +++ b/drivers/usb/serial/usb_debug.c | |||
@@ -15,7 +15,19 @@ | |||
15 | #include <linux/usb.h> | 15 | #include <linux/usb.h> |
16 | #include <linux/usb/serial.h> | 16 | #include <linux/usb/serial.h> |
17 | 17 | ||
18 | #define URB_DEBUG_MAX_IN_FLIGHT_URBS 4000 | ||
18 | #define USB_DEBUG_MAX_PACKET_SIZE 8 | 19 | #define USB_DEBUG_MAX_PACKET_SIZE 8 |
20 | #define USB_DEBUG_BRK_SIZE 8 | ||
21 | static char USB_DEBUG_BRK[USB_DEBUG_BRK_SIZE] = { | ||
22 | 0x00, | ||
23 | 0xff, | ||
24 | 0x01, | ||
25 | 0xfe, | ||
26 | 0x00, | ||
27 | 0xfe, | ||
28 | 0x01, | ||
29 | 0xff, | ||
30 | }; | ||
19 | 31 | ||
20 | static struct usb_device_id id_table [] = { | 32 | static struct usb_device_id id_table [] = { |
21 | { USB_DEVICE(0x0525, 0x127a) }, | 33 | { USB_DEVICE(0x0525, 0x127a) }, |
@@ -38,6 +50,32 @@ static int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port, | |||
38 | return usb_serial_generic_open(tty, port, filp); | 50 | return usb_serial_generic_open(tty, port, filp); |
39 | } | 51 | } |
40 | 52 | ||
53 | /* This HW really does not support a serial break, so one will be | ||
54 | * emulated when ever the break state is set to true. | ||
55 | */ | ||
56 | static void usb_debug_break_ctl(struct tty_struct *tty, int break_state) | ||
57 | { | ||
58 | struct usb_serial_port *port = tty->driver_data; | ||
59 | if (!break_state) | ||
60 | return; | ||
61 | usb_serial_generic_write(tty, port, USB_DEBUG_BRK, USB_DEBUG_BRK_SIZE); | ||
62 | } | ||
63 | |||
64 | static void usb_debug_read_bulk_callback(struct urb *urb) | ||
65 | { | ||
66 | struct usb_serial_port *port = urb->context; | ||
67 | |||
68 | if (urb->actual_length == USB_DEBUG_BRK_SIZE && | ||
69 | memcmp(urb->transfer_buffer, USB_DEBUG_BRK, | ||
70 | USB_DEBUG_BRK_SIZE) == 0) { | ||
71 | usb_serial_handle_break(port); | ||
72 | usb_serial_generic_resubmit_read_urb(port, GFP_ATOMIC); | ||
73 | return; | ||
74 | } | ||
75 | |||
76 | usb_serial_generic_read_bulk_callback(urb); | ||
77 | } | ||
78 | |||
41 | static struct usb_serial_driver debug_device = { | 79 | static struct usb_serial_driver debug_device = { |
42 | .driver = { | 80 | .driver = { |
43 | .owner = THIS_MODULE, | 81 | .owner = THIS_MODULE, |
@@ -46,6 +84,9 @@ static struct usb_serial_driver debug_device = { | |||
46 | .id_table = id_table, | 84 | .id_table = id_table, |
47 | .num_ports = 1, | 85 | .num_ports = 1, |
48 | .open = usb_debug_open, | 86 | .open = usb_debug_open, |
87 | .max_in_flight_urbs = URB_DEBUG_MAX_IN_FLIGHT_URBS, | ||
88 | .break_ctl = usb_debug_break_ctl, | ||
89 | .read_bulk_callback = usb_debug_read_bulk_callback, | ||
49 | }; | 90 | }; |
50 | 91 | ||
51 | static int __init debug_init(void) | 92 | static int __init debug_init(void) |
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index b15f1c0e1d4a..f5d0f64dcc52 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c | |||
@@ -47,7 +47,7 @@ static void visor_unthrottle(struct tty_struct *tty); | |||
47 | static int visor_probe(struct usb_serial *serial, | 47 | static int visor_probe(struct usb_serial *serial, |
48 | const struct usb_device_id *id); | 48 | const struct usb_device_id *id); |
49 | static int visor_calc_num_ports(struct usb_serial *serial); | 49 | static int visor_calc_num_ports(struct usb_serial *serial); |
50 | static void visor_shutdown(struct usb_serial *serial); | 50 | static void visor_release(struct usb_serial *serial); |
51 | static void visor_write_bulk_callback(struct urb *urb); | 51 | static void visor_write_bulk_callback(struct urb *urb); |
52 | static void visor_read_bulk_callback(struct urb *urb); | 52 | static void visor_read_bulk_callback(struct urb *urb); |
53 | static void visor_read_int_callback(struct urb *urb); | 53 | static void visor_read_int_callback(struct urb *urb); |
@@ -202,7 +202,7 @@ static struct usb_serial_driver handspring_device = { | |||
202 | .attach = treo_attach, | 202 | .attach = treo_attach, |
203 | .probe = visor_probe, | 203 | .probe = visor_probe, |
204 | .calc_num_ports = visor_calc_num_ports, | 204 | .calc_num_ports = visor_calc_num_ports, |
205 | .shutdown = visor_shutdown, | 205 | .release = visor_release, |
206 | .write = visor_write, | 206 | .write = visor_write, |
207 | .write_room = visor_write_room, | 207 | .write_room = visor_write_room, |
208 | .write_bulk_callback = visor_write_bulk_callback, | 208 | .write_bulk_callback = visor_write_bulk_callback, |
@@ -227,7 +227,7 @@ static struct usb_serial_driver clie_5_device = { | |||
227 | .attach = clie_5_attach, | 227 | .attach = clie_5_attach, |
228 | .probe = visor_probe, | 228 | .probe = visor_probe, |
229 | .calc_num_ports = visor_calc_num_ports, | 229 | .calc_num_ports = visor_calc_num_ports, |
230 | .shutdown = visor_shutdown, | 230 | .release = visor_release, |
231 | .write = visor_write, | 231 | .write = visor_write, |
232 | .write_room = visor_write_room, | 232 | .write_room = visor_write_room, |
233 | .write_bulk_callback = visor_write_bulk_callback, | 233 | .write_bulk_callback = visor_write_bulk_callback, |
@@ -918,7 +918,7 @@ static int clie_5_attach(struct usb_serial *serial) | |||
918 | return generic_startup(serial); | 918 | return generic_startup(serial); |
919 | } | 919 | } |
920 | 920 | ||
921 | static void visor_shutdown(struct usb_serial *serial) | 921 | static void visor_release(struct usb_serial *serial) |
922 | { | 922 | { |
923 | struct visor_private *priv; | 923 | struct visor_private *priv; |
924 | int i; | 924 | int i; |
@@ -927,10 +927,7 @@ static void visor_shutdown(struct usb_serial *serial) | |||
927 | 927 | ||
928 | for (i = 0; i < serial->num_ports; i++) { | 928 | for (i = 0; i < serial->num_ports; i++) { |
929 | priv = usb_get_serial_port_data(serial->port[i]); | 929 | priv = usb_get_serial_port_data(serial->port[i]); |
930 | if (priv) { | 930 | kfree(priv); |
931 | usb_set_serial_port_data(serial->port[i], NULL); | ||
932 | kfree(priv); | ||
933 | } | ||
934 | } | 931 | } |
935 | } | 932 | } |
936 | 933 | ||
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 7c7295d09f34..8d126dd7a02e 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -144,7 +144,7 @@ static int whiteheat_firmware_attach(struct usb_serial *serial); | |||
144 | 144 | ||
145 | /* function prototypes for the Connect Tech WhiteHEAT serial converter */ | 145 | /* function prototypes for the Connect Tech WhiteHEAT serial converter */ |
146 | static int whiteheat_attach(struct usb_serial *serial); | 146 | static int whiteheat_attach(struct usb_serial *serial); |
147 | static void whiteheat_shutdown(struct usb_serial *serial); | 147 | static void whiteheat_release(struct usb_serial *serial); |
148 | static int whiteheat_open(struct tty_struct *tty, | 148 | static int whiteheat_open(struct tty_struct *tty, |
149 | struct usb_serial_port *port, struct file *filp); | 149 | struct usb_serial_port *port, struct file *filp); |
150 | static void whiteheat_close(struct usb_serial_port *port); | 150 | static void whiteheat_close(struct usb_serial_port *port); |
@@ -189,7 +189,7 @@ static struct usb_serial_driver whiteheat_device = { | |||
189 | .id_table = id_table_std, | 189 | .id_table = id_table_std, |
190 | .num_ports = 4, | 190 | .num_ports = 4, |
191 | .attach = whiteheat_attach, | 191 | .attach = whiteheat_attach, |
192 | .shutdown = whiteheat_shutdown, | 192 | .release = whiteheat_release, |
193 | .open = whiteheat_open, | 193 | .open = whiteheat_open, |
194 | .close = whiteheat_close, | 194 | .close = whiteheat_close, |
195 | .write = whiteheat_write, | 195 | .write = whiteheat_write, |
@@ -617,7 +617,7 @@ no_command_buffer: | |||
617 | } | 617 | } |
618 | 618 | ||
619 | 619 | ||
620 | static void whiteheat_shutdown(struct usb_serial *serial) | 620 | static void whiteheat_release(struct usb_serial *serial) |
621 | { | 621 | { |
622 | struct usb_serial_port *command_port; | 622 | struct usb_serial_port *command_port; |
623 | struct usb_serial_port *port; | 623 | struct usb_serial_port *port; |