+#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
for (i = 0; i < nents; i++) {
char *buf;
- unsigned j;
- buf = kzalloc (size, SLAB_KERNEL);
+ buf = kmalloc (size, SLAB_KERNEL);
if (!buf) {
free_sglist (sg, i);
return NULL;
}
+ memset (buf, 0, size);
/* kmalloc pages are always physically contiguous! */
sg_init_one(&sg[i], buf, size);
- switch (pattern) {
- case 0:
- /* already zeroed */
- break;
- case 1:
- for (j = 0; j < size; j++)
- *buf++ = (u8) (j % 63);
- break;
- }
-
if (vary) {
size += vary;
size %= max;
usb_sg_wait (req);
retval = req->status;
- /* FIXME check resulting data pattern */
-
/* FIXME if endpoint halted, clear halt (and log) */
}
if (u == urb || !u->dev)
continue;
- spin_unlock(&ctx->lock);
status = usb_unlink_urb (u);
- spin_lock(&ctx->lock);
switch (status) {
case -EINPROGRESS:
case -EBUSY:
* as with bulk/intr sglists, sglen is the queue depth; it also
* controls which subtests run (more tests than sglen) or rerun.
*/
- urb = kcalloc(param->sglen, sizeof(struct urb *), SLAB_KERNEL);
+ urb = kmalloc (param->sglen * sizeof (struct urb *), SLAB_KERNEL);
if (!urb)
return -ENOMEM;
+ memset (urb, 0, param->sglen * sizeof (struct urb *));
for (i = 0; i < param->sglen; i++) {
int pipe = usb_rcvctrlpipe (udev, 0);
unsigned len;
static int ctrl_out (struct usbtest_dev *dev,
unsigned count, unsigned length, unsigned vary)
{
- unsigned i, j, len;
- int retval;
+ unsigned i, j, len, retval;
u8 *buf;
char *what = "?";
struct usb_device *udev;
-
+
if (length < 1 || length > 0xffff || vary >= length)
return -EINVAL;
unsigned pending;
spinlock_t lock;
struct completion done;
- int submit_error;
unsigned long errors;
- unsigned long packet_count;
struct usbtest_dev *dev;
};
spin_lock(&ctx->lock);
ctx->count--;
- ctx->packet_count += urb->number_of_packets;
if (urb->error_count > 0)
ctx->errors += urb->error_count;
- else if (urb->status != 0)
- ctx->errors += urb->number_of_packets;
- if (urb->status == 0 && ctx->count > (ctx->pending - 1)
- && !ctx->submit_error) {
+ if (urb->status == 0 && ctx->count > (ctx->pending - 1)) {
int status = usb_submit_urb (urb, GFP_ATOMIC);
switch (status) {
case 0:
status);
/* FALLTHROUGH */
case -ENODEV: /* disconnected */
- case -ESHUTDOWN: /* endpoint disabled */
- ctx->submit_error = 1;
break;
}
}
if (ctx->pending == 0) {
if (ctx->errors)
dev_dbg (&ctx->dev->intf->dev,
- "iso test, %lu errors out of %lu\n",
- ctx->errors, ctx->packet_count);
+ "iso test, %lu errors\n",
+ ctx->errors);
complete (&ctx->done);
}
done:
struct usb_device *udev;
unsigned i;
unsigned long packets = 0;
- int status = 0;
+ int status;
struct urb *urbs[10]; /* FIXME no limit */
if (param->sglen > 10)
return -EDOM;
- memset(&context, 0, sizeof context);
context.count = param->iterations * param->sglen;
+ context.pending = param->sglen;
+ context.errors = 0;
context.dev = dev;
init_completion (&context.done);
spin_lock_init (&context.lock);
spin_lock_irq (&context.lock);
for (i = 0; i < param->sglen; i++) {
- ++context.pending;
status = usb_submit_urb (urbs [i], SLAB_ATOMIC);
if (status < 0) {
ERROR (dev, "submit iso[%d], error %d\n", i, status);
simple_free_urb (urbs [i]);
context.pending--;
- context.submit_error = 1;
- break;
}
}
spin_unlock_irq (&context.lock);
wait_for_completion (&context.done);
-
- /*
- * Isochronous transfers are expected to fail sometimes. As an
- * arbitrary limit, we will report an error if any submissions
- * fail or if the transfer failure rate is > 10%.
- */
- if (status != 0)
- ;
- else if (context.submit_error)
- status = -EACCES;
- else if (context.errors > context.packet_count / 10)
- status = -EIO;
- return status;
+ return 0;
fail:
for (i = 0; i < param->sglen; i++) {
}
#endif
- dev = kzalloc(sizeof(*dev), SLAB_KERNEL);
+ dev = kmalloc (sizeof *dev, SLAB_KERNEL);
if (!dev)
return -ENOMEM;
+ memset (dev, 0, sizeof *dev);
info = (struct usbtest_info *) id->driver_info;
dev->info = info;
init_MUTEX (&dev->sem);