diff options
author | Johan Hovold <jhovold@gmail.com> | 2013-04-16 12:01:27 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-17 13:05:35 -0400 |
commit | 35807187e4b35200b12edad319a36ee7a0167ba7 (patch) | |
tree | d45a22e74ea5382b6d61b7891bc2b0c2f317095a /drivers/usb | |
parent | feb0a36a523b9fd07275b12f76b344901f884253 (diff) |
USB: mct_u232: clean up read implementation
The device uses the second interrupt-in endpoint of the interface for
reading. Stop abusing the port read urb and store a pointer to the
second interrupt-in urb as port-private data instead.
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/mct_u232.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 3353c9ed7721..6a15adf53360 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -43,7 +43,6 @@ | |||
43 | /* | 43 | /* |
44 | * Function prototypes | 44 | * Function prototypes |
45 | */ | 45 | */ |
46 | static int mct_u232_startup(struct usb_serial *serial); | ||
47 | static int mct_u232_port_probe(struct usb_serial_port *port); | 46 | static int mct_u232_port_probe(struct usb_serial_port *port); |
48 | static int mct_u232_port_remove(struct usb_serial_port *remove); | 47 | static int mct_u232_port_remove(struct usb_serial_port *remove); |
49 | static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port); | 48 | static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port); |
@@ -91,7 +90,6 @@ static struct usb_serial_driver mct_u232_device = { | |||
91 | .tiocmget = mct_u232_tiocmget, | 90 | .tiocmget = mct_u232_tiocmget, |
92 | .tiocmset = mct_u232_tiocmset, | 91 | .tiocmset = mct_u232_tiocmset, |
93 | .tiocmiwait = usb_serial_generic_tiocmiwait, | 92 | .tiocmiwait = usb_serial_generic_tiocmiwait, |
94 | .attach = mct_u232_startup, | ||
95 | .port_probe = mct_u232_port_probe, | 93 | .port_probe = mct_u232_port_probe, |
96 | .port_remove = mct_u232_port_remove, | 94 | .port_remove = mct_u232_port_remove, |
97 | .get_icount = usb_serial_generic_get_icount, | 95 | .get_icount = usb_serial_generic_get_icount, |
@@ -102,6 +100,7 @@ static struct usb_serial_driver * const serial_drivers[] = { | |||
102 | }; | 100 | }; |
103 | 101 | ||
104 | struct mct_u232_private { | 102 | struct mct_u232_private { |
103 | struct urb *read_urb; | ||
105 | spinlock_t lock; | 104 | spinlock_t lock; |
106 | unsigned int control_state; /* Modem Line Setting (TIOCM) */ | 105 | unsigned int control_state; /* Modem Line Setting (TIOCM) */ |
107 | unsigned char last_lcr; /* Line Control Register */ | 106 | unsigned char last_lcr; /* Line Control Register */ |
@@ -376,22 +375,6 @@ static void mct_u232_msr_to_state(struct usb_serial_port *port, | |||
376 | * Driver's tty interface functions | 375 | * Driver's tty interface functions |
377 | */ | 376 | */ |
378 | 377 | ||
379 | static int mct_u232_startup(struct usb_serial *serial) | ||
380 | { | ||
381 | struct usb_serial_port *port, *rport; | ||
382 | |||
383 | /* Puh, that's dirty */ | ||
384 | port = serial->port[0]; | ||
385 | rport = serial->port[1]; | ||
386 | /* No unlinking, it wasn't submitted yet. */ | ||
387 | usb_free_urb(port->read_urb); | ||
388 | port->read_urb = rport->interrupt_in_urb; | ||
389 | rport->interrupt_in_urb = NULL; | ||
390 | port->read_urb->context = port; | ||
391 | |||
392 | return 0; | ||
393 | } /* mct_u232_startup */ | ||
394 | |||
395 | static int mct_u232_port_probe(struct usb_serial_port *port) | 378 | static int mct_u232_port_probe(struct usb_serial_port *port) |
396 | { | 379 | { |
397 | struct mct_u232_private *priv; | 380 | struct mct_u232_private *priv; |
@@ -400,6 +383,10 @@ static int mct_u232_port_probe(struct usb_serial_port *port) | |||
400 | if (!priv) | 383 | if (!priv) |
401 | return -ENOMEM; | 384 | return -ENOMEM; |
402 | 385 | ||
386 | /* Use second interrupt-in endpoint for reading. */ | ||
387 | priv->read_urb = port->serial->port[1]->interrupt_in_urb; | ||
388 | priv->read_urb->context = port; | ||
389 | |||
403 | spin_lock_init(&priv->lock); | 390 | spin_lock_init(&priv->lock); |
404 | 391 | ||
405 | usb_set_serial_port_data(port, priv); | 392 | usb_set_serial_port_data(port, priv); |
@@ -463,17 +450,17 @@ static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
463 | mct_u232_msr_to_state(port, &priv->control_state, priv->last_msr); | 450 | mct_u232_msr_to_state(port, &priv->control_state, priv->last_msr); |
464 | spin_unlock_irqrestore(&priv->lock, flags); | 451 | spin_unlock_irqrestore(&priv->lock, flags); |
465 | 452 | ||
466 | retval = usb_submit_urb(port->read_urb, GFP_KERNEL); | 453 | retval = usb_submit_urb(priv->read_urb, GFP_KERNEL); |
467 | if (retval) { | 454 | if (retval) { |
468 | dev_err(&port->dev, | 455 | dev_err(&port->dev, |
469 | "usb_submit_urb(read bulk) failed pipe 0x%x err %d\n", | 456 | "usb_submit_urb(read) failed pipe 0x%x err %d\n", |
470 | port->read_urb->pipe, retval); | 457 | port->read_urb->pipe, retval); |
471 | goto error; | 458 | goto error; |
472 | } | 459 | } |
473 | 460 | ||
474 | retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 461 | retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
475 | if (retval) { | 462 | if (retval) { |
476 | usb_kill_urb(port->read_urb); | 463 | usb_kill_urb(priv->read_urb); |
477 | dev_err(&port->dev, | 464 | dev_err(&port->dev, |
478 | "usb_submit_urb(read int) failed pipe 0x%x err %d", | 465 | "usb_submit_urb(read int) failed pipe 0x%x err %d", |
479 | port->interrupt_in_urb->pipe, retval); | 466 | port->interrupt_in_urb->pipe, retval); |
@@ -503,11 +490,9 @@ static void mct_u232_dtr_rts(struct usb_serial_port *port, int on) | |||
503 | 490 | ||
504 | static void mct_u232_close(struct usb_serial_port *port) | 491 | static void mct_u232_close(struct usb_serial_port *port) |
505 | { | 492 | { |
506 | /* | 493 | struct mct_u232_private *priv = usb_get_serial_port_data(port); |
507 | * Must kill the read urb as it is actually an interrupt urb, which | 494 | |
508 | * generic close thus fails to kill. | 495 | usb_kill_urb(priv->read_urb); |
509 | */ | ||
510 | usb_kill_urb(port->read_urb); | ||
511 | usb_kill_urb(port->interrupt_in_urb); | 496 | usb_kill_urb(port->interrupt_in_urb); |
512 | 497 | ||
513 | usb_serial_generic_close(port); | 498 | usb_serial_generic_close(port); |