for (tmp = 0; tmp < intf->num_altsetting; tmp++) {
unsigned ep;
- in = out = 0;
- iso_in = iso_out = 0;
+ in = out = NULL;
+ iso_in = iso_out = NULL;
alt = intf->altsetting + tmp;
/* take the first altsetting with in-bulk + out-bulk;
struct urb *urb;
if (bytes < 0)
- return 0;
+ return NULL;
urb = usb_alloc_urb (0, SLAB_KERNEL);
if (!urb)
return urb;
- usb_fill_bulk_urb (urb, udev, pipe, 0, bytes, simple_callback, 0);
+ usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL);
urb->interval = (udev->speed == USB_SPEED_HIGH)
? (INTERRUPT_RATE << 3)
: INTERRUPT_RATE;
&urb->transfer_dma);
if (!urb->transfer_buffer) {
usb_free_urb (urb);
- urb = 0;
+ urb = NULL;
} else
memset (urb->transfer_buffer, 0, bytes);
return urb;
sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL);
if (!sg)
- return 0;
+ return NULL;
memset (sg, 0, nents * sizeof *sg);
for (i = 0; i < nents; i++) {
buf = kmalloc (size, SLAB_KERNEL);
if (!buf) {
free_sglist (sg, i);
- return 0;
+ return NULL;
}
memset (buf, 0, size);
* or remote wakeup (which needs human interaction).
*/
-static int realworld = 1;
-MODULE_PARM (realworld, "i");
+static unsigned realworld = 1;
+module_param (realworld, uint, 0);
MODULE_PARM_DESC (realworld, "clear to demand stricter ch9 compliance");
static int get_altsetting (struct usbtest_dev *dev)
return 0;
}
- le16_to_cpus (&config->wTotalLength);
- if (config->wTotalLength == len) /* read it all */
+ if (le16_to_cpu(config->wTotalLength) == len) /* read it all */
return 1;
- if (config->wTotalLength >= TBUF_SIZE) /* max partial read */
+ if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */
return 1;
dbg ("bogus config descriptor read size");
return 0;
}
/* and sometimes [9.2.6.6] speed dependent descriptors */
- if (udev->descriptor.bcdUSB == 0x0200) { /* pre-swapped */
- struct usb_qualifier_descriptor *d = 0;
+ if (le16_to_cpu(udev->descriptor.bcdUSB) == 0x0200) {
+ struct usb_qualifier_descriptor *d = NULL;
/* device qualifier [9.6.2] */
retval = usb_get_descriptor (udev,
switch (status) {
case -EINPROGRESS:
case -EBUSY:
+ case -EIDRM:
continue;
default:
dbg ("urb unlink --> %d", status);
if ((status = usb_submit_urb (urb, SLAB_ATOMIC)) != 0) {
dbg ("can't resubmit ctrl %02x.%02x, err %d",
reqp->bRequestType, reqp->bRequest, status);
- urb->dev = 0;
+ urb->dev = NULL;
} else
ctx->pending++;
} else
- urb->dev = 0;
+ urb->dev = NULL;
/* signal completion when nothing's queued */
if (ctx->pending == 0)
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->epmaxpacketin [0];
+ len = 1024 - udev->descriptor.bMaxPacketSize0;
expected = -EREMOTEIO;
break;
case 14: // short read; try to fill the last packet
req.wValue = cpu_to_le16 ((USB_DT_DEVICE << 8) | 0);
// device descriptor size == 18 bytes
- len = udev->epmaxpacketin [0];
+ len = udev->descriptor.bMaxPacketSize0;
switch (len) {
case 8: len = 24; break;
case 16: len = 32; break;
if (!status)
status = usb_submit_urb (urb, SLAB_ATOMIC);
if (status) {
- if (status == -ECONNRESET || status == -ENOENT)
- status = 0;
urb->status = status;
complete ((struct completion *) urb->context);
}
urb = simple_alloc_urb (testdev_to_usbdev (dev), pipe, size);
if (!urb)
return -ENOMEM;
- if (async)
- urb->transfer_flags |= URB_ASYNC_UNLINK;
+ urb->transfer_flags |= URB_ASYNC_UNLINK;
urb->context = &completion;
urb->complete = unlink1_callback;
/* unlinking that should always work. variable delay tests more
* hcd states and code paths, even with little other system load.
*/
- wait_ms (jiffies % (2 * INTERRUPT_RATE));
+ msleep (jiffies % (2 * INTERRUPT_RATE));
+ if (async) {
retry:
- retval = usb_unlink_urb (urb);
- if (retval == -EBUSY) {
- /* we can't unlink urbs while they're completing.
- * "normal" drivers would prevent resubmission, but
- * since we're testing unlink paths, we can't.
- */
- dev_dbg (&dev->intf->dev, "unlink retry\n");
- goto retry;
- }
+ retval = usb_unlink_urb (urb);
+ if (retval == -EBUSY || retval == -EIDRM) {
+ /* we can't unlink urbs while they're completing.
+ * or if they've completed, and we haven't resubmitted.
+ * "normal" drivers would prevent resubmission, but
+ * since we're testing unlink paths, we can't.
+ */
+ dev_dbg (&dev->intf->dev, "unlink retry\n");
+ goto retry;
+ }
+ } else
+ usb_kill_urb (urb);
if (!(retval == 0 || retval == -EINPROGRESS)) {
dev_dbg (&dev->intf->dev, "unlink fail %d\n", retval);
return retval;
simple_free_urb (urb);
if (async)
- return (retval != -ECONNRESET) ? -ECONNRESET : 0;
+ return (retval == -ECONNRESET) ? 0 : retval - 1000;
else
- return (retval != -ENOENT) ? -ENOENT : 0;
+ return (retval == -ENOENT || retval == -EPERM) ?
+ 0 : retval - 2000;
}
static int unlink_simple (struct usbtest_dev *dev, int pipe, int len)
struct urb *urb;
urb = simple_alloc_urb (testdev_to_usbdev (dev), 0, 512);
- if (urb == 0)
+ if (urb == NULL)
return -ENOMEM;
if (dev->in_pipe) {
"iso test, %lu errors\n",
ctx->errors);
complete (&ctx->done);
- } else
+ }
done:
spin_unlock(&ctx->lock);
}
unsigned i, maxp, packets;
if (bytes < 0 || !desc)
- return 0;
- maxp = 0x7ff & desc->wMaxPacketSize;
- maxp *= 1 + (0x3 & (desc->wMaxPacketSize >> 11));
+ return NULL;
+ maxp = 0x7ff & le16_to_cpu(desc->wMaxPacketSize);
+ maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11));
packets = (bytes + maxp - 1) / maxp;
urb = usb_alloc_urb (packets, SLAB_KERNEL);
&urb->transfer_dma);
if (!urb->transfer_buffer) {
usb_free_urb (urb);
- return 0;
+ return NULL;
}
memset (urb->transfer_buffer, 0, bytes);
for (i = 0; i < packets; i++) {
"... iso period %d %sframes, wMaxPacket %04x\n",
1 << (desc->bInterval - 1),
(udev->speed == USB_SPEED_HIGH) ? "micro" : "",
- desc->wMaxPacketSize);
+ le16_to_cpu(desc->wMaxPacketSize));
for (i = 0; i < param->sglen; i++) {
urbs [i] = iso_alloc_urb (udev, pipe, desc,
status = usb_submit_urb (urbs [i], SLAB_ATOMIC);
if (status < 0) {
ERROR (dev, "submit iso[%d], error %d\n", i, status);
- if (i == 0)
+ if (i == 0) {
+ spin_unlock_irq (&context.lock);
goto fail;
+ }
simple_free_urb (urbs [i]);
context.pending--;
/*-------------------------------------------------------------------------*/
-static int force_interrupt = 0;
-MODULE_PARM (force_interrupt, "i");
+static unsigned force_interrupt = 0;
+module_param (force_interrupt, uint, 0);
MODULE_PARM_DESC (force_interrupt, "0 = test default; else interrupt");
#ifdef GENERIC
-static int vendor;
-MODULE_PARM (vendor, "h");
+static unsigned short vendor;
+module_param(vendor, ushort, 0);
MODULE_PARM_DESC (vendor, "vendor code (from usb-if)");
-static int product;
-MODULE_PARM (product, "h");
+static unsigned short product;
+module_param(product, ushort, 0);
MODULE_PARM_DESC (product, "product code (from vendor)");
#endif
/* specify devices by module parameters? */
if (id->match_flags == 0) {
/* vendor match required, product match optional */
- if (!vendor || udev->descriptor.idVendor != (u16)vendor)
+ if (!vendor || le16_to_cpu(udev->descriptor.idVendor) != (u16)vendor)
return -ENODEV;
- if (product && udev->descriptor.idProduct != (u16)product)
+ if (product && le16_to_cpu(udev->descriptor.idProduct) != (u16)product)
return -ENODEV;
dbg ("matched module params, vend=0x%04x prod=0x%04x",
- udev->descriptor.idVendor,
- udev->descriptor.idProduct);
+ le16_to_cpu(udev->descriptor.idVendor),
+ le16_to_cpu(udev->descriptor.idProduct));
}
#endif
dev->intf = intf;
/* cacheline-aligned scratch for i/o */
- if ((dev->buf = kmalloc (TBUF_SIZE, SLAB_KERNEL)) == 0) {
+ if ((dev->buf = kmalloc (TBUF_SIZE, SLAB_KERNEL)) == NULL) {
kfree (dev);
return -ENOMEM;
}