aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2011-11-06 13:06:31 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-11-15 13:40:00 -0500
commit1ce7b9349fad3ab47ecf214c76e29cadff5e1a93 (patch)
tree143ca7aec5d5d3a64ac3c0b098e596c64e205ab0 /drivers
parentfd11961a2deaf4220ca90ce734439b4006db2911 (diff)
USB: serial: reuse generic write urb and bulk-out buffer
Reuse first write urb and bulk-out buffer of the generic write implementation for drivers that rely on port->write_urb rather than allocating them separately. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/serial/usb-serial.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index cc274fdf2627..bfbe6e5431d3 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -563,7 +563,6 @@ static void kill_traffic(struct usb_serial_port *port)
563 int i; 563 int i;
564 564
565 usb_kill_urb(port->read_urb); 565 usb_kill_urb(port->read_urb);
566 usb_kill_urb(port->write_urb);
567 for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) 566 for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i)
568 usb_kill_urb(port->write_urbs[i]); 567 usb_kill_urb(port->write_urbs[i]);
569 /* 568 /*
@@ -596,7 +595,6 @@ static void port_release(struct device *dev)
596 cancel_work_sync(&port->work); 595 cancel_work_sync(&port->work);
597 596
598 usb_free_urb(port->read_urb); 597 usb_free_urb(port->read_urb);
599 usb_free_urb(port->write_urb);
600 usb_free_urb(port->interrupt_in_urb); 598 usb_free_urb(port->interrupt_in_urb);
601 usb_free_urb(port->interrupt_out_urb); 599 usb_free_urb(port->interrupt_out_urb);
602 for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) { 600 for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) {
@@ -605,7 +603,6 @@ static void port_release(struct device *dev)
605 } 603 }
606 kfifo_free(&port->write_fifo); 604 kfifo_free(&port->write_fifo);
607 kfree(port->bulk_in_buffer); 605 kfree(port->bulk_in_buffer);
608 kfree(port->bulk_out_buffer);
609 kfree(port->interrupt_in_buffer); 606 kfree(port->interrupt_in_buffer);
610 kfree(port->interrupt_out_buffer); 607 kfree(port->interrupt_out_buffer);
611 kfree(port); 608 kfree(port);
@@ -933,11 +930,6 @@ int usb_serial_probe(struct usb_interface *interface,
933 930
934 endpoint = bulk_out_endpoint[i]; 931 endpoint = bulk_out_endpoint[i];
935 port = serial->port[i]; 932 port = serial->port[i];
936 port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
937 if (!port->write_urb) {
938 dev_err(&interface->dev, "No free urbs available\n");
939 goto probe_error;
940 }
941 if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL)) 933 if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL))
942 goto probe_error; 934 goto probe_error;
943 buffer_size = serial->type->bulk_out_size; 935 buffer_size = serial->type->bulk_out_size;
@@ -945,17 +937,7 @@ int usb_serial_probe(struct usb_interface *interface,
945 buffer_size = usb_endpoint_maxp(endpoint); 937 buffer_size = usb_endpoint_maxp(endpoint);
946 port->bulk_out_size = buffer_size; 938 port->bulk_out_size = buffer_size;
947 port->bulk_out_endpointAddress = endpoint->bEndpointAddress; 939 port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
948 port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL); 940
949 if (!port->bulk_out_buffer) {
950 dev_err(&interface->dev,
951 "Couldn't allocate bulk_out_buffer\n");
952 goto probe_error;
953 }
954 usb_fill_bulk_urb(port->write_urb, dev,
955 usb_sndbulkpipe(dev,
956 endpoint->bEndpointAddress),
957 port->bulk_out_buffer, buffer_size,
958 serial->type->write_bulk_callback, port);
959 for (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j) { 941 for (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j) {
960 set_bit(j, &port->write_urbs_free); 942 set_bit(j, &port->write_urbs_free);
961 port->write_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); 943 port->write_urbs[j] = usb_alloc_urb(0, GFP_KERNEL);
@@ -978,6 +960,9 @@ int usb_serial_probe(struct usb_interface *interface,
978 serial->type->write_bulk_callback, 960 serial->type->write_bulk_callback,
979 port); 961 port);
980 } 962 }
963
964 port->write_urb = port->write_urbs[0];
965 port->bulk_out_buffer = port->bulk_out_buffers[0];
981 } 966 }
982 967
983 if (serial->type->read_int_callback) { 968 if (serial->type->read_int_callback) {