USB: serial: visor: fix crash on detecting device without write_urbs
[pandora-kernel.git] / drivers / usb / misc / usbtest.c
index bd6d008..2a38a17 100644 (file)
@@ -1025,7 +1025,10 @@ test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param)
                case 13:        /* short read, resembling case 10 */
                        req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);
                        /* last data packet "should" be DATA1, not DATA0 */
-                       len = 1024 - udev->descriptor.bMaxPacketSize0;
+                       if (udev->speed == USB_SPEED_SUPER)
+                               len = 1024 - 512;
+                       else
+                               len = 1024 - udev->descriptor.bMaxPacketSize0;
                        expected = -EREMOTEIO;
                        break;
                case 14:        /* short read; try to fill the last packet */
@@ -1129,6 +1132,11 @@ static int unlink1(struct usbtest_dev *dev, int pipe, int size, int async)
        urb->context = &completion;
        urb->complete = unlink1_callback;
 
+       if (usb_pipeout(urb->pipe)) {
+               simple_fill_buf(urb);
+               urb->transfer_flags |= URB_ZERO_PACKET;
+       }
+
        /* keep the endpoint busy.  there are lots of hc/hcd-internal
         * states, and testing should get to all of them over time.
         *
@@ -1259,6 +1267,11 @@ static int unlink_queued(struct usbtest_dev *dev, int pipe, unsigned num,
                                unlink_queued_callback, &ctx);
                ctx.urbs[i]->transfer_dma = buf_dma;
                ctx.urbs[i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
+
+               if (usb_pipeout(ctx.urbs[i]->pipe)) {
+                       simple_fill_buf(ctx.urbs[i]);
+                       ctx.urbs[i]->transfer_flags |= URB_ZERO_PACKET;
+               }
        }
 
        /* Submit all the URBs and then unlink URBs num - 4 and num - 2. */
@@ -1384,11 +1397,15 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb)
 
 static int halt_simple(struct usbtest_dev *dev)
 {
-       int             ep;
-       int             retval = 0;
-       struct urb      *urb;
+       int                     ep;
+       int                     retval = 0;
+       struct urb              *urb;
+       struct usb_device       *udev = testdev_to_usbdev(dev);
 
-       urb = simple_alloc_urb(testdev_to_usbdev(dev), 0, 512);
+       if (udev->speed == USB_SPEED_SUPER)
+               urb = simple_alloc_urb(udev, 0, 1024);
+       else
+               urb = simple_alloc_urb(udev, 0, 512);
        if (urb == NULL)
                return -ENOMEM;