]> Pileus Git - ~andy/linux/commitdiff
USB: usbtmc: repeat usb_bulk_msg until whole message is transfered
authorAndre Herms <andre.herms@tec-venture.de>
Thu, 19 Nov 2009 17:14:49 +0000 (18:14 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 11 Dec 2009 19:55:25 +0000 (11:55 -0800)
usb_bulk_msg() transfers only bytes up to the maximum packet size.
It must be repeated by the usbtmc driver until all bytes of a TMC message
are transfered.

Without this patch, ETIMEDOUT is reported when writing TMC messages
larger than the maximum USB bulk size and the transfer remains incomplete.
The user will notice that the device hangs and must be reset by either closing
the application or pulling the plug.

Signed-off-by: Andre Herms <andre.herms@tec-venture.de>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/class/usbtmc.c

index 65965587c812b3fb113b686f57673dee25f966e4..619cc9975209ace8b1b84534ecd95dd1810d03a2 100644 (file)
@@ -562,10 +562,16 @@ static ssize_t usbtmc_write(struct file *filp, const char __user *buf,
                n_bytes = roundup(12 + this_part, 4);
                memset(buffer + 12 + this_part, 0, n_bytes - (12 + this_part));
 
-               retval = usb_bulk_msg(data->usb_dev,
-                                     usb_sndbulkpipe(data->usb_dev,
-                                                     data->bulk_out),
-                                     buffer, n_bytes, &actual, USBTMC_TIMEOUT);
+               do {
+                       retval = usb_bulk_msg(data->usb_dev,
+                                             usb_sndbulkpipe(data->usb_dev,
+                                                             data->bulk_out),
+                                             buffer, n_bytes,
+                                             &actual, USBTMC_TIMEOUT);
+                       if (retval != 0)
+                               break;
+                       n_bytes -= actual;
+               } while (n_bytes);
 
                data->bTag_last_write = data->bTag;
                data->bTag++;