diff options
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 3873660d8217..941c2d409f85 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -289,7 +289,7 @@ static void serial_down(struct tty_port *tport) | |||
289 | * The console is magical. Do not hang up the console hardware | 289 | * The console is magical. Do not hang up the console hardware |
290 | * or there will be tears. | 290 | * or there will be tears. |
291 | */ | 291 | */ |
292 | if (port->console) | 292 | if (port->port.console) |
293 | return; | 293 | return; |
294 | if (drv->close) | 294 | if (drv->close) |
295 | drv->close(port); | 295 | drv->close(port); |
@@ -328,7 +328,7 @@ static void serial_cleanup(struct tty_struct *tty) | |||
328 | /* The console is magical. Do not hang up the console hardware | 328 | /* The console is magical. Do not hang up the console hardware |
329 | * or there will be tears. | 329 | * or there will be tears. |
330 | */ | 330 | */ |
331 | if (port->console) | 331 | if (port->port.console) |
332 | return; | 332 | return; |
333 | 333 | ||
334 | dbg("%s - port %d", __func__, port->number); | 334 | dbg("%s - port %d", __func__, port->number); |
@@ -548,8 +548,12 @@ static void usb_serial_port_work(struct work_struct *work) | |||
548 | 548 | ||
549 | static void kill_traffic(struct usb_serial_port *port) | 549 | static void kill_traffic(struct usb_serial_port *port) |
550 | { | 550 | { |
551 | int i; | ||
552 | |||
551 | usb_kill_urb(port->read_urb); | 553 | usb_kill_urb(port->read_urb); |
552 | usb_kill_urb(port->write_urb); | 554 | usb_kill_urb(port->write_urb); |
555 | for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) | ||
556 | usb_kill_urb(port->write_urbs[i]); | ||
553 | /* | 557 | /* |
554 | * This is tricky. | 558 | * This is tricky. |
555 | * Some drivers submit the read_urb in the | 559 | * Some drivers submit the read_urb in the |
@@ -568,6 +572,7 @@ static void kill_traffic(struct usb_serial_port *port) | |||
568 | static void port_release(struct device *dev) | 572 | static void port_release(struct device *dev) |
569 | { | 573 | { |
570 | struct usb_serial_port *port = to_usb_serial_port(dev); | 574 | struct usb_serial_port *port = to_usb_serial_port(dev); |
575 | int i; | ||
571 | 576 | ||
572 | dbg ("%s - %s", __func__, dev_name(dev)); | 577 | dbg ("%s - %s", __func__, dev_name(dev)); |
573 | 578 | ||
@@ -582,6 +587,10 @@ static void port_release(struct device *dev) | |||
582 | usb_free_urb(port->write_urb); | 587 | usb_free_urb(port->write_urb); |
583 | usb_free_urb(port->interrupt_in_urb); | 588 | usb_free_urb(port->interrupt_in_urb); |
584 | usb_free_urb(port->interrupt_out_urb); | 589 | usb_free_urb(port->interrupt_out_urb); |
590 | for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) { | ||
591 | usb_free_urb(port->write_urbs[i]); | ||
592 | kfree(port->bulk_out_buffers[i]); | ||
593 | } | ||
585 | kfifo_free(&port->write_fifo); | 594 | kfifo_free(&port->write_fifo); |
586 | kfree(port->bulk_in_buffer); | 595 | kfree(port->bulk_in_buffer); |
587 | kfree(port->bulk_out_buffer); | 596 | kfree(port->bulk_out_buffer); |
@@ -901,7 +910,9 @@ int usb_serial_probe(struct usb_interface *interface, | |||
901 | dev_err(&interface->dev, "No free urbs available\n"); | 910 | dev_err(&interface->dev, "No free urbs available\n"); |
902 | goto probe_error; | 911 | goto probe_error; |
903 | } | 912 | } |
904 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | 913 | buffer_size = serial->type->bulk_in_size; |
914 | if (!buffer_size) | ||
915 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | ||
905 | port->bulk_in_size = buffer_size; | 916 | port->bulk_in_size = buffer_size; |
906 | port->bulk_in_endpointAddress = endpoint->bEndpointAddress; | 917 | port->bulk_in_endpointAddress = endpoint->bEndpointAddress; |
907 | port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); | 918 | port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); |
@@ -918,6 +929,8 @@ int usb_serial_probe(struct usb_interface *interface, | |||
918 | } | 929 | } |
919 | 930 | ||
920 | for (i = 0; i < num_bulk_out; ++i) { | 931 | for (i = 0; i < num_bulk_out; ++i) { |
932 | int j; | ||
933 | |||
921 | endpoint = bulk_out_endpoint[i]; | 934 | endpoint = bulk_out_endpoint[i]; |
922 | port = serial->port[i]; | 935 | port = serial->port[i]; |
923 | port->write_urb = usb_alloc_urb(0, GFP_KERNEL); | 936 | port->write_urb = usb_alloc_urb(0, GFP_KERNEL); |
@@ -927,7 +940,9 @@ int usb_serial_probe(struct usb_interface *interface, | |||
927 | } | 940 | } |
928 | if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL)) | 941 | if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL)) |
929 | goto probe_error; | 942 | goto probe_error; |
930 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | 943 | buffer_size = serial->type->bulk_out_size; |
944 | if (!buffer_size) | ||
945 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | ||
931 | port->bulk_out_size = buffer_size; | 946 | port->bulk_out_size = buffer_size; |
932 | port->bulk_out_endpointAddress = endpoint->bEndpointAddress; | 947 | port->bulk_out_endpointAddress = endpoint->bEndpointAddress; |
933 | port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL); | 948 | port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL); |
@@ -941,6 +956,28 @@ int usb_serial_probe(struct usb_interface *interface, | |||
941 | endpoint->bEndpointAddress), | 956 | endpoint->bEndpointAddress), |
942 | port->bulk_out_buffer, buffer_size, | 957 | port->bulk_out_buffer, buffer_size, |
943 | serial->type->write_bulk_callback, port); | 958 | serial->type->write_bulk_callback, port); |
959 | for (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j) { | ||
960 | set_bit(j, &port->write_urbs_free); | ||
961 | port->write_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); | ||
962 | if (!port->write_urbs[j]) { | ||
963 | dev_err(&interface->dev, | ||
964 | "No free urbs available\n"); | ||
965 | goto probe_error; | ||
966 | } | ||
967 | port->bulk_out_buffers[j] = kmalloc(buffer_size, | ||
968 | GFP_KERNEL); | ||
969 | if (!port->bulk_out_buffers[j]) { | ||
970 | dev_err(&interface->dev, | ||
971 | "Couldn't allocate bulk_out_buffer\n"); | ||
972 | goto probe_error; | ||
973 | } | ||
974 | usb_fill_bulk_urb(port->write_urbs[j], dev, | ||
975 | usb_sndbulkpipe(dev, | ||
976 | endpoint->bEndpointAddress), | ||
977 | port->bulk_out_buffers[j], buffer_size, | ||
978 | serial->type->write_bulk_callback, | ||
979 | port); | ||
980 | } | ||
944 | } | 981 | } |
945 | 982 | ||
946 | if (serial->type->read_int_callback) { | 983 | if (serial->type->read_int_callback) { |
@@ -1294,6 +1331,8 @@ static void fixup_generic(struct usb_serial_driver *device) | |||
1294 | set_to_generic_if_null(device, write_bulk_callback); | 1331 | set_to_generic_if_null(device, write_bulk_callback); |
1295 | set_to_generic_if_null(device, disconnect); | 1332 | set_to_generic_if_null(device, disconnect); |
1296 | set_to_generic_if_null(device, release); | 1333 | set_to_generic_if_null(device, release); |
1334 | set_to_generic_if_null(device, process_read_urb); | ||
1335 | set_to_generic_if_null(device, prepare_write_buffer); | ||
1297 | } | 1336 | } |
1298 | 1337 | ||
1299 | int usb_serial_register(struct usb_serial_driver *driver) | 1338 | int usb_serial_register(struct usb_serial_driver *driver) |