Skip to content

Commit

Permalink
USB: option: remove unnecessary and erroneous code
Browse files Browse the repository at this point in the history
This patch (as1264) removes a bunch of unnecessary and erroneous stuff
from the option USB-serial driver.  Clearly there's no need to verify
that the device pointer stored in the URBs is right or to store the
same pointer over again.  After all, the pointer can't change once it
has been set up.

There's also no need to call usb_clear_halt for the IN endpoint
multiple times -- in fact, doing so is an error since every time after
the first there will be active URBs queued for that endpoint.  Since
the Clear-Halts don't appear to be needed at all, the patch simply
removes them.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Jul 12, 2009
1 parent 4d2fae8 commit f092c24
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions drivers/usb/serial/option.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,6 @@ static int option_write(struct tty_struct *tty, struct usb_serial_port *port,
memcpy(this_urb->transfer_buffer, buf, todo);
this_urb->transfer_buffer_length = todo;

this_urb->dev = port->serial->dev;
err = usb_submit_urb(this_urb, GFP_ATOMIC);
if (err) {
dbg("usb_submit_urb %p (write bulk) failed "
Expand Down Expand Up @@ -876,7 +875,6 @@ static void option_instat_callback(struct urb *urb)

/* Resubmit urb so we continue receiving IRQ data */
if (status != -ESHUTDOWN && status != -ENOENT) {
urb->dev = serial->dev;
err = usb_submit_urb(urb, GFP_ATOMIC);
if (err)
dbg("%s: resubmit intr urb failed. (%d)",
Expand Down Expand Up @@ -937,23 +935,11 @@ static int option_open(struct tty_struct *tty,

dbg("%s", __func__);

/* Reset low level data toggle and start reading from endpoints */
/* Start reading from the IN endpoint */
for (i = 0; i < N_IN_URB; i++) {
urb = portdata->in_urbs[i];
if (!urb)
continue;
if (urb->dev != serial->dev) {
dbg("%s: dev %p != %p", __func__,
urb->dev, serial->dev);
continue;
}

/*
* make sure endpoint data toggle is synchronized with the
* device
*/
usb_clear_halt(urb->dev, urb->pipe);

err = usb_submit_urb(urb, GFP_KERNEL);
if (err) {
dbg("%s: submit urb %d failed (%d) %d",
Expand All @@ -962,16 +948,6 @@ static int option_open(struct tty_struct *tty,
}
}

/* Reset low level data toggle on out endpoints */
for (i = 0; i < N_OUT_URB; i++) {
urb = portdata->out_urbs[i];
if (!urb)
continue;
urb->dev = serial->dev;
/* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
usb_pipeout(urb->pipe), 0); */
}

option_send_setup(port);

return 0;
Expand Down Expand Up @@ -1234,7 +1210,6 @@ static int option_resume(struct usb_serial *serial)
dbg("%s: No interrupt URB for port %d\n", __func__, i);
continue;
}
port->interrupt_in_urb->dev = serial->dev;
err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
dbg("Submitted interrupt URB for port %d (result %d)", i, err);
if (err < 0) {
Expand Down

0 comments on commit f092c24

Please sign in to comment.