aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2012-11-18 07:23:34 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-21 16:33:55 -0500
commit5ad473492ada0ab05bcf15791b7a41c587d831c7 (patch)
tree784d331a54c4133177725a7580ea96a3e47d01a8 /drivers/usb/serial
parent333396fc703860e19eadcdc67def9caa4f3154f4 (diff)
USB: opticon: use usb-serial bulk-in urb
Use the bulk-in urb provided by usb-serial core rather than allocating a private one. 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.c31
1 files changed, 2 insertions, 29 deletions
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 543d8c79b026..36fdab7b016f 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -40,10 +40,7 @@ MODULE_DEVICE_TABLE(usb, id_table);
40 40
41/* This structure holds all of the individual device information */ 41/* This structure holds all of the individual device information */
42struct opticon_private { 42struct opticon_private {
43 unsigned char *bulk_in_buffer;
44 struct urb *bulk_read_urb; 43 struct urb *bulk_read_urb;
45 int buffer_size;
46 u8 bulk_address;
47 spinlock_t lock; /* protects the following flags */ 44 spinlock_t lock; /* protects the following flags */
48 bool throttled; 45 bool throttled;
49 bool actually_throttled; 46 bool actually_throttled;
@@ -478,49 +475,24 @@ static int opticon_startup(struct usb_serial *serial)
478 475
479static int opticon_port_probe(struct usb_serial_port *port) 476static int opticon_port_probe(struct usb_serial_port *port)
480{ 477{
481 struct usb_serial *serial = port->serial;
482 struct opticon_private *priv; 478 struct opticon_private *priv;
483 int retval = -ENOMEM;
484 479
485 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 480 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
486 if (!priv) 481 if (!priv)
487 return -ENOMEM; 482 return -ENOMEM;
488 483
489 spin_lock_init(&priv->lock); 484 spin_lock_init(&priv->lock);
490 485 priv->bulk_read_urb = port->read_urbs[0];
491 priv->bulk_read_urb = usb_alloc_urb(0, GFP_KERNEL);
492 if (!priv->bulk_read_urb)
493 goto error;
494
495 priv->buffer_size = port->bulk_in_size;
496 priv->bulk_in_buffer = kmalloc(priv->buffer_size, GFP_KERNEL);
497 if (!priv->bulk_in_buffer)
498 goto error;
499
500 priv->bulk_address = port->bulk_in_endpointAddress;
501
502 usb_fill_bulk_urb(priv->bulk_read_urb, serial->dev,
503 usb_rcvbulkpipe(serial->dev,
504 priv->bulk_address),
505 priv->bulk_in_buffer, priv->buffer_size,
506 opticon_read_bulk_callback, port);
507 486
508 usb_set_serial_port_data(port, priv); 487 usb_set_serial_port_data(port, priv);
509 488
510 return 0; 489 return 0;
511error:
512 usb_free_urb(priv->bulk_read_urb);
513 kfree(priv->bulk_in_buffer);
514 kfree(priv);
515 return retval;
516} 490}
517 491
518static int opticon_port_remove(struct usb_serial_port *port) 492static int opticon_port_remove(struct usb_serial_port *port)
519{ 493{
520 struct opticon_private *priv = usb_get_serial_port_data(port); 494 struct opticon_private *priv = usb_get_serial_port_data(port);
521 495
522 usb_free_urb(priv->bulk_read_urb);
523 kfree(priv->bulk_in_buffer);
524 kfree(priv); 496 kfree(priv);
525 497
526 return 0; 498 return 0;
@@ -574,6 +546,7 @@ static struct usb_serial_driver opticon_device = {
574 .tiocmset = opticon_tiocmset, 546 .tiocmset = opticon_tiocmset,
575 .suspend = opticon_suspend, 547 .suspend = opticon_suspend,
576 .resume = opticon_resume, 548 .resume = opticon_resume,
549 .read_bulk_callback = opticon_read_bulk_callback,
577}; 550};
578 551
579static struct usb_serial_driver * const serial_drivers[] = { 552static struct usb_serial_driver * const serial_drivers[] = {