aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/visor.c
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-22 06:09:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-22 16:03:22 -0400
commit95da310e66ee8090119596c70ca8432e57f9a97f (patch)
tree7f18c30e9c9ad4d7d53df6453fa338be06f09a85 /drivers/usb/serial/visor.c
parent1aa3692da57c773e5c76de55c5c4a953962d360e (diff)
usb_serial: API all change
USB serial likes to use port->tty back pointers for the real work it does and to do so without any actual locking. Unfortunately when you consider hangup events, hangup/parallel reopen or even worse hangup followed by parallel close events the tty->port and port->tty pointers are not guaranteed to be the same as port->tty is the active tty while tty->port is the port the tty may or may not still be attached to. So rework the entire API to pass the tty struct. For console cases we need to pass both for now. This shows up multiple drivers that immediately crash with USB console some of which have been fixed in the process. Longer term we need a proper tty as console abstraction Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial/visor.c')
-rw-r--r--drivers/usb/serial/visor.c66
1 files changed, 20 insertions, 46 deletions
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 5fc20122145f..373a3c7ea77b 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -35,17 +35,15 @@
35#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver" 35#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver"
36 36
37/* function prototypes for a handspring visor */ 37/* function prototypes for a handspring visor */
38static int visor_open (struct usb_serial_port *port, struct file *filp); 38static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
39static void visor_close (struct usb_serial_port *port, struct file *filp); 39static void visor_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
40static int visor_write (struct usb_serial_port *port, const unsigned char *buf, int count); 40static int visor_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
41static int visor_write_room (struct usb_serial_port *port); 41static int visor_write_room (struct tty_struct *tty);
42static int visor_chars_in_buffer (struct usb_serial_port *port); 42static void visor_throttle (struct tty_struct *tty);
43static void visor_throttle (struct usb_serial_port *port); 43static void visor_unthrottle (struct tty_struct *tty);
44static void visor_unthrottle (struct usb_serial_port *port);
45static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id); 44static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id);
46static int visor_calc_num_ports(struct usb_serial *serial); 45static int visor_calc_num_ports(struct usb_serial *serial);
47static void visor_shutdown (struct usb_serial *serial); 46static void visor_shutdown (struct usb_serial *serial);
48static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
49static void visor_write_bulk_callback (struct urb *urb); 47static void visor_write_bulk_callback (struct urb *urb);
50static void visor_read_bulk_callback (struct urb *urb); 48static void visor_read_bulk_callback (struct urb *urb);
51static void visor_read_int_callback (struct urb *urb); 49static void visor_read_int_callback (struct urb *urb);
@@ -198,10 +196,8 @@ static struct usb_serial_driver handspring_device = {
198 .probe = visor_probe, 196 .probe = visor_probe,
199 .calc_num_ports = visor_calc_num_ports, 197 .calc_num_ports = visor_calc_num_ports,
200 .shutdown = visor_shutdown, 198 .shutdown = visor_shutdown,
201 .ioctl = visor_ioctl,
202 .write = visor_write, 199 .write = visor_write,
203 .write_room = visor_write_room, 200 .write_room = visor_write_room,
204 .chars_in_buffer = visor_chars_in_buffer,
205 .write_bulk_callback = visor_write_bulk_callback, 201 .write_bulk_callback = visor_write_bulk_callback,
206 .read_bulk_callback = visor_read_bulk_callback, 202 .read_bulk_callback = visor_read_bulk_callback,
207 .read_int_callback = visor_read_int_callback, 203 .read_int_callback = visor_read_int_callback,
@@ -225,10 +221,8 @@ static struct usb_serial_driver clie_5_device = {
225 .probe = visor_probe, 221 .probe = visor_probe,
226 .calc_num_ports = visor_calc_num_ports, 222 .calc_num_ports = visor_calc_num_ports,
227 .shutdown = visor_shutdown, 223 .shutdown = visor_shutdown,
228 .ioctl = visor_ioctl,
229 .write = visor_write, 224 .write = visor_write,
230 .write_room = visor_write_room, 225 .write_room = visor_write_room,
231 .chars_in_buffer = visor_chars_in_buffer,
232 .write_bulk_callback = visor_write_bulk_callback, 226 .write_bulk_callback = visor_write_bulk_callback,
233 .read_bulk_callback = visor_read_bulk_callback, 227 .read_bulk_callback = visor_read_bulk_callback,
234 .read_int_callback = visor_read_int_callback, 228 .read_int_callback = visor_read_int_callback,
@@ -249,10 +243,8 @@ static struct usb_serial_driver clie_3_5_device = {
249 .throttle = visor_throttle, 243 .throttle = visor_throttle,
250 .unthrottle = visor_unthrottle, 244 .unthrottle = visor_unthrottle,
251 .attach = clie_3_5_startup, 245 .attach = clie_3_5_startup,
252 .ioctl = visor_ioctl,
253 .write = visor_write, 246 .write = visor_write,
254 .write_room = visor_write_room, 247 .write_room = visor_write_room,
255 .chars_in_buffer = visor_chars_in_buffer,
256 .write_bulk_callback = visor_write_bulk_callback, 248 .write_bulk_callback = visor_write_bulk_callback,
257 .read_bulk_callback = visor_read_bulk_callback, 249 .read_bulk_callback = visor_read_bulk_callback,
258}; 250};
@@ -274,7 +266,7 @@ static int stats;
274/****************************************************************************** 266/******************************************************************************
275 * Handspring Visor specific driver functions 267 * Handspring Visor specific driver functions
276 ******************************************************************************/ 268 ******************************************************************************/
277static int visor_open (struct usb_serial_port *port, struct file *filp) 269static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp)
278{ 270{
279 struct usb_serial *serial = port->serial; 271 struct usb_serial *serial = port->serial;
280 struct visor_private *priv = usb_get_serial_port_data(port); 272 struct visor_private *priv = usb_get_serial_port_data(port);
@@ -300,8 +292,8 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
300 * through, otherwise it is scheduled, and with high data rates (like 292 * through, otherwise it is scheduled, and with high data rates (like
301 * with OHCI) data can get lost. 293 * with OHCI) data can get lost.
302 */ 294 */
303 if (port->tty) 295 if (tty)
304 port->tty->low_latency = 1; 296 tty->low_latency = 1;
305 297
306 /* Start reading from the device */ 298 /* Start reading from the device */
307 usb_fill_bulk_urb (port->read_urb, serial->dev, 299 usb_fill_bulk_urb (port->read_urb, serial->dev,
@@ -329,7 +321,8 @@ exit:
329} 321}
330 322
331 323
332static void visor_close (struct usb_serial_port *port, struct file * filp) 324static void visor_close(struct tty_struct *tty,
325 struct usb_serial_port *port, struct file * filp)
333{ 326{
334 struct visor_private *priv = usb_get_serial_port_data(port); 327 struct visor_private *priv = usb_get_serial_port_data(port);
335 unsigned char *transfer_buffer; 328 unsigned char *transfer_buffer;
@@ -361,7 +354,8 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
361} 354}
362 355
363 356
364static int visor_write (struct usb_serial_port *port, const unsigned char *buf, int count) 357static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
358 const unsigned char *buf, int count)
365{ 359{
366 struct visor_private *priv = usb_get_serial_port_data(port); 360 struct visor_private *priv = usb_get_serial_port_data(port);
367 struct usb_serial *serial = port->serial; 361 struct usb_serial *serial = port->serial;
@@ -435,8 +429,9 @@ error_no_buffer:
435} 429}
436 430
437 431
438static int visor_write_room (struct usb_serial_port *port) 432static int visor_write_room (struct tty_struct *tty)
439{ 433{
434 struct usb_serial_port *port = tty->driver_data;
440 struct visor_private *priv = usb_get_serial_port_data(port); 435 struct visor_private *priv = usb_get_serial_port_data(port);
441 unsigned long flags; 436 unsigned long flags;
442 437
@@ -460,22 +455,6 @@ static int visor_write_room (struct usb_serial_port *port)
460} 455}
461 456
462 457
463static int visor_chars_in_buffer (struct usb_serial_port *port)
464{
465 dbg("%s - port %d", __func__, port->number);
466
467 /*
468 * We can't really account for how much data we
469 * have sent out, but hasn't made it through to the
470 * device, so just tell the tty layer that everything
471 * is flushed.
472 *
473 * FIXME: Should walk outstanding_urbs
474 */
475 return 0;
476}
477
478
479static void visor_write_bulk_callback (struct urb *urb) 458static void visor_write_bulk_callback (struct urb *urb)
480{ 459{
481 struct usb_serial_port *port = urb->context; 460 struct usb_serial_port *port = urb->context;
@@ -520,7 +499,7 @@ static void visor_read_bulk_callback (struct urb *urb)
520 499
521 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); 500 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
522 501
523 tty = port->tty; 502 tty = port->port.tty;
524 if (tty && urb->actual_length) { 503 if (tty && urb->actual_length) {
525 available_room = tty_buffer_request_room(tty, urb->actual_length); 504 available_room = tty_buffer_request_room(tty, urb->actual_length);
526 if (available_room) { 505 if (available_room) {
@@ -591,8 +570,9 @@ exit:
591 __func__, result); 570 __func__, result);
592} 571}
593 572
594static void visor_throttle (struct usb_serial_port *port) 573static void visor_throttle (struct tty_struct *tty)
595{ 574{
575 struct usb_serial_port *port = tty->driver_data;
596 struct visor_private *priv = usb_get_serial_port_data(port); 576 struct visor_private *priv = usb_get_serial_port_data(port);
597 unsigned long flags; 577 unsigned long flags;
598 578
@@ -603,8 +583,9 @@ static void visor_throttle (struct usb_serial_port *port)
603} 583}
604 584
605 585
606static void visor_unthrottle (struct usb_serial_port *port) 586static void visor_unthrottle (struct tty_struct *tty)
607{ 587{
588 struct usb_serial_port *port = tty->driver_data;
608 struct visor_private *priv = usb_get_serial_port_data(port); 589 struct visor_private *priv = usb_get_serial_port_data(port);
609 unsigned long flags; 590 unsigned long flags;
610 int result; 591 int result;
@@ -922,13 +903,6 @@ static void visor_shutdown (struct usb_serial *serial)
922 } 903 }
923} 904}
924 905
925static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
926{
927 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
928
929 return -ENOIOCTLCMD;
930}
931
932static int __init visor_init (void) 906static int __init visor_init (void)
933{ 907{
934 int i, retval; 908 int i, retval;