Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338694
b: refs/heads/master
c: a0a5fd9
h: refs/heads/master
v: v3
  • Loading branch information
Johan Hovold authored and Greg Kroah-Hartman committed Nov 21, 2012
1 parent f73dc78 commit 2d3d639
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 34 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 37203d6f1d0bef0c0943f3d853efdccb3246e7a6
refs/heads/master: a0a5fd92a4d62506cb5c6fa64fb25653dda2cf09
49 changes: 16 additions & 33 deletions trunk/drivers/usb/serial/opticon.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,12 @@ static int opticon_ioctl(struct tty_struct *tty,
static int opticon_startup(struct usb_serial *serial)
{
struct opticon_private *priv;
struct usb_host_interface *intf;
int i;
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 */
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
Expand All @@ -485,40 +487,21 @@ static int opticon_startup(struct usb_serial *serial)
spin_lock_init(&priv->lock);
priv->port = serial->port[0];

/* find our bulk endpoint */
intf = serial->interface->altsetting;
for (i = 0; i < intf->desc.bNumEndpoints; ++i) {
struct usb_endpoint_descriptor *endpoint;

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;
}
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;
}

if (!bulk_in_found) {
dev_err(&serial->dev->dev,
"Error - the proper endpoints were not found!\n");
priv->buffer_size = 2 * priv->port->bulk_in_size;
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 = priv->port->bulk_in_endpointAddress;

usb_fill_bulk_urb(priv->bulk_read_urb, serial->dev,
usb_rcvbulkpipe(serial->dev,
priv->bulk_address),
Expand Down

0 comments on commit 2d3d639

Please sign in to comment.