diff options
author | Johan Hovold <jhovold@gmail.com> | 2012-11-18 07:23:27 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-21 16:33:55 -0500 |
commit | a0a5fd92a4d62506cb5c6fa64fb25653dda2cf09 (patch) | |
tree | c83aa6e03583e09a3602ca453f89b190db27456e /drivers/usb/serial | |
parent | 37203d6f1d0bef0c0943f3d853efdccb3246e7a6 (diff) |
USB: opticon: simplify bulk-in discovery in attach
Remove custom end-point iteration which has already been taken care of
by usb-serial core.
The first bulk-in endpoint found will be associated with the first port.
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r-- | drivers/usb/serial/opticon.c | 49 |
1 files changed, 16 insertions, 33 deletions
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index a515c5fda8a9..e275abb9a1ec 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c | |||
@@ -471,10 +471,12 @@ static int opticon_ioctl(struct tty_struct *tty, | |||
471 | static int opticon_startup(struct usb_serial *serial) | 471 | static int opticon_startup(struct usb_serial *serial) |
472 | { | 472 | { |
473 | struct opticon_private *priv; | 473 | struct opticon_private *priv; |
474 | struct usb_host_interface *intf; | ||
475 | int i; | ||
476 | int retval = -ENOMEM; | 474 | int retval = -ENOMEM; |
477 | bool bulk_in_found = false; | 475 | |
476 | if (!serial->num_bulk_in) { | ||
477 | dev_err(&serial->dev->dev, "no bulk in endpoint\n"); | ||
478 | return -ENODEV; | ||
479 | } | ||
478 | 480 | ||
479 | /* create our private serial structure */ | 481 | /* create our private serial structure */ |
480 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 482 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
@@ -485,40 +487,21 @@ static int opticon_startup(struct usb_serial *serial) | |||
485 | spin_lock_init(&priv->lock); | 487 | spin_lock_init(&priv->lock); |
486 | priv->port = serial->port[0]; | 488 | priv->port = serial->port[0]; |
487 | 489 | ||
488 | /* find our bulk endpoint */ | 490 | priv->bulk_read_urb = usb_alloc_urb(0, GFP_KERNEL); |
489 | intf = serial->interface->altsetting; | 491 | if (!priv->bulk_read_urb) { |
490 | for (i = 0; i < intf->desc.bNumEndpoints; ++i) { | 492 | dev_err(&serial->dev->dev, "out of memory\n"); |
491 | struct usb_endpoint_descriptor *endpoint; | 493 | goto error; |
492 | 494 | } | |
493 | endpoint = &intf->endpoint[i].desc; | ||
494 | if (!usb_endpoint_is_bulk_in(endpoint)) | ||
495 | continue; | ||
496 | |||
497 | priv->bulk_read_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
498 | if (!priv->bulk_read_urb) { | ||
499 | dev_err(&serial->dev->dev, "out of memory\n"); | ||
500 | goto error; | ||
501 | } | ||
502 | |||
503 | priv->buffer_size = usb_endpoint_maxp(endpoint) * 2; | ||
504 | priv->bulk_in_buffer = kmalloc(priv->buffer_size, GFP_KERNEL); | ||
505 | if (!priv->bulk_in_buffer) { | ||
506 | dev_err(&serial->dev->dev, "out of memory\n"); | ||
507 | goto error; | ||
508 | } | ||
509 | |||
510 | priv->bulk_address = endpoint->bEndpointAddress; | ||
511 | |||
512 | bulk_in_found = true; | ||
513 | break; | ||
514 | } | ||
515 | 495 | ||
516 | if (!bulk_in_found) { | 496 | priv->buffer_size = 2 * priv->port->bulk_in_size; |
517 | dev_err(&serial->dev->dev, | 497 | priv->bulk_in_buffer = kmalloc(priv->buffer_size, GFP_KERNEL); |
518 | "Error - the proper endpoints were not found!\n"); | 498 | if (!priv->bulk_in_buffer) { |
499 | dev_err(&serial->dev->dev, "out of memory\n"); | ||
519 | goto error; | 500 | goto error; |
520 | } | 501 | } |
521 | 502 | ||
503 | priv->bulk_address = priv->port->bulk_in_endpointAddress; | ||
504 | |||
522 | usb_fill_bulk_urb(priv->bulk_read_urb, serial->dev, | 505 | usb_fill_bulk_urb(priv->bulk_read_urb, serial->dev, |
523 | usb_rcvbulkpipe(serial->dev, | 506 | usb_rcvbulkpipe(serial->dev, |
524 | priv->bulk_address), | 507 | priv->bulk_address), |