Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 28347
b: refs/heads/master
c: 9da2150
h: refs/heads/master
i:
  28345: 83b991b
  28343: b1c1db4
v: v3
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Jun 21, 2006
1 parent 57d6182 commit 8ef2374
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0ae4ea8092e1277cfca07cade7eaba5f594076c1
refs/heads/master: 9da2150f59e885d88b9eabe0a677f0fa4962f7b4
36 changes: 29 additions & 7 deletions trunk/drivers/usb/misc/usbtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,9 @@ struct iso_context {
unsigned pending;
spinlock_t lock;
struct completion done;
int submit_error;
unsigned long errors;
unsigned long packet_count;
struct usbtest_dev *dev;
};

Expand All @@ -1348,10 +1350,14 @@ static void iso_callback (struct urb *urb, struct pt_regs *regs)
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)) {
if (urb->status == 0 && ctx->count > (ctx->pending - 1)
&& !ctx->submit_error) {
int status = usb_submit_urb (urb, GFP_ATOMIC);
switch (status) {
case 0:
Expand All @@ -1362,6 +1368,8 @@ static void iso_callback (struct urb *urb, struct pt_regs *regs)
status);
/* FALLTHROUGH */
case -ENODEV: /* disconnected */
case -ESHUTDOWN: /* endpoint disabled */
ctx->submit_error = 1;
break;
}
}
Expand All @@ -1371,8 +1379,8 @@ static void iso_callback (struct urb *urb, struct pt_regs *regs)
if (ctx->pending == 0) {
if (ctx->errors)
dev_dbg (&ctx->dev->intf->dev,
"iso test, %lu errors\n",
ctx->errors);
"iso test, %lu errors out of %lu\n",
ctx->errors, ctx->packet_count);
complete (&ctx->done);
}
done:
Expand Down Expand Up @@ -1433,15 +1441,14 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
struct usb_device *udev;
unsigned i;
unsigned long packets = 0;
int status;
int status = 0;
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);
Expand Down Expand Up @@ -1473,6 +1480,7 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,

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);
Expand All @@ -1483,12 +1491,26 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,

simple_free_urb (urbs [i]);
context.pending--;
context.submit_error = 1;
break;
}
}
spin_unlock_irq (&context.lock);

wait_for_completion (&context.done);
return 0;

/*
* 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;

fail:
for (i = 0; i < param->sglen; i++) {
Expand Down

0 comments on commit 8ef2374

Please sign in to comment.