Commit a0a5fd92 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

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: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 37203d6f
...@@ -471,10 +471,12 @@ static int opticon_ioctl(struct tty_struct *tty, ...@@ -471,10 +471,12 @@ static int opticon_ioctl(struct tty_struct *tty,
static int opticon_startup(struct usb_serial *serial) static int opticon_startup(struct usb_serial *serial)
{ {
struct opticon_private *priv; struct opticon_private *priv;
struct usb_host_interface *intf;
int i;
int retval = -ENOMEM; int retval = -ENOMEM;
bool bulk_in_found = false;
if (!serial->num_bulk_in) {
dev_err(&serial->dev->dev, "no bulk in endpoint\n");
return -ENODEV;
}
/* create our private serial structure */ /* create our private serial structure */
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
...@@ -485,40 +487,21 @@ static int opticon_startup(struct usb_serial *serial) ...@@ -485,40 +487,21 @@ static int opticon_startup(struct usb_serial *serial)
spin_lock_init(&priv->lock); spin_lock_init(&priv->lock);
priv->port = serial->port[0]; priv->port = serial->port[0];
/* find our bulk endpoint */ priv->bulk_read_urb = usb_alloc_urb(0, GFP_KERNEL);
intf = serial->interface->altsetting; if (!priv->bulk_read_urb) {
for (i = 0; i < intf->desc.bNumEndpoints; ++i) { dev_err(&serial->dev->dev, "out of memory\n");
struct usb_endpoint_descriptor *endpoint; goto error;
}
endpoint = &intf->endpoint[i].desc;
if (!usb_endpoint_is_bulk_in(endpoint))
continue;
priv->bulk_read_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!priv->bulk_read_urb) {
dev_err(&serial->dev->dev, "out of memory\n");
goto error;
}
priv->buffer_size = usb_endpoint_maxp(endpoint) * 2;
priv->bulk_in_buffer = kmalloc(priv->buffer_size, GFP_KERNEL);
if (!priv->bulk_in_buffer) {
dev_err(&serial->dev->dev, "out of memory\n");
goto error;
}
priv->bulk_address = endpoint->bEndpointAddress;
bulk_in_found = true;
break;
}
if (!bulk_in_found) { priv->buffer_size = 2 * priv->port->bulk_in_size;
dev_err(&serial->dev->dev, priv->bulk_in_buffer = kmalloc(priv->buffer_size, GFP_KERNEL);
"Error - the proper endpoints were not found!\n"); if (!priv->bulk_in_buffer) {
dev_err(&serial->dev->dev, "out of memory\n");
goto error; goto error;
} }
priv->bulk_address = priv->port->bulk_in_endpointAddress;
usb_fill_bulk_urb(priv->bulk_read_urb, serial->dev, usb_fill_bulk_urb(priv->bulk_read_urb, serial->dev,
usb_rcvbulkpipe(serial->dev, usb_rcvbulkpipe(serial->dev,
priv->bulk_address), priv->bulk_address),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment