diff options
Diffstat (limited to 'drivers/usb/misc/usbtest.c')
| -rw-r--r-- | drivers/usb/misc/usbtest.c | 667 |
1 files changed, 343 insertions, 324 deletions
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index eef370eb7a54..a35b427c0bac 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
| @@ -13,17 +13,16 @@ | |||
| 13 | 13 | ||
| 14 | /*-------------------------------------------------------------------------*/ | 14 | /*-------------------------------------------------------------------------*/ |
| 15 | 15 | ||
| 16 | // FIXME make these public somewhere; usbdevfs.h? | 16 | /* FIXME make these public somewhere; usbdevfs.h? */ |
| 17 | // | ||
| 18 | struct usbtest_param { | 17 | struct usbtest_param { |
| 19 | // inputs | 18 | /* inputs */ |
| 20 | unsigned test_num; /* 0..(TEST_CASES-1) */ | 19 | unsigned test_num; /* 0..(TEST_CASES-1) */ |
| 21 | unsigned iterations; | 20 | unsigned iterations; |
| 22 | unsigned length; | 21 | unsigned length; |
| 23 | unsigned vary; | 22 | unsigned vary; |
| 24 | unsigned sglen; | 23 | unsigned sglen; |
| 25 | 24 | ||
| 26 | // outputs | 25 | /* outputs */ |
| 27 | struct timeval duration; | 26 | struct timeval duration; |
| 28 | }; | 27 | }; |
| 29 | #define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param) | 28 | #define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param) |
| @@ -45,9 +44,9 @@ struct usbtest_info { | |||
| 45 | const char *name; | 44 | const char *name; |
| 46 | u8 ep_in; /* bulk/intr source */ | 45 | u8 ep_in; /* bulk/intr source */ |
| 47 | u8 ep_out; /* bulk/intr sink */ | 46 | u8 ep_out; /* bulk/intr sink */ |
| 48 | unsigned autoconf : 1; | 47 | unsigned autoconf:1; |
| 49 | unsigned ctrl_out : 1; | 48 | unsigned ctrl_out:1; |
| 50 | unsigned iso : 1; /* try iso in/out */ | 49 | unsigned iso:1; /* try iso in/out */ |
| 51 | int alt; | 50 | int alt; |
| 52 | }; | 51 | }; |
| 53 | 52 | ||
| @@ -71,9 +70,9 @@ struct usbtest_dev { | |||
| 71 | u8 *buf; | 70 | u8 *buf; |
| 72 | }; | 71 | }; |
| 73 | 72 | ||
| 74 | static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test) | 73 | static struct usb_device *testdev_to_usbdev(struct usbtest_dev *test) |
| 75 | { | 74 | { |
| 76 | return interface_to_usbdev (test->intf); | 75 | return interface_to_usbdev(test->intf); |
| 77 | } | 76 | } |
| 78 | 77 | ||
| 79 | /* set up all urbs so they can be used with either bulk or interrupt */ | 78 | /* set up all urbs so they can be used with either bulk or interrupt */ |
| @@ -87,7 +86,7 @@ static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test) | |||
| 87 | /*-------------------------------------------------------------------------*/ | 86 | /*-------------------------------------------------------------------------*/ |
| 88 | 87 | ||
| 89 | static int | 88 | static int |
| 90 | get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf) | 89 | get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf) |
| 91 | { | 90 | { |
| 92 | int tmp; | 91 | int tmp; |
| 93 | struct usb_host_interface *alt; | 92 | struct usb_host_interface *alt; |
| @@ -115,7 +114,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf) | |||
| 115 | case USB_ENDPOINT_XFER_ISOC: | 114 | case USB_ENDPOINT_XFER_ISOC: |
| 116 | if (dev->info->iso) | 115 | if (dev->info->iso) |
| 117 | goto try_iso; | 116 | goto try_iso; |
| 118 | // FALLTHROUGH | 117 | /* FALLTHROUGH */ |
| 119 | default: | 118 | default: |
| 120 | continue; | 119 | continue; |
| 121 | } | 120 | } |
| @@ -142,9 +141,9 @@ try_iso: | |||
| 142 | return -EINVAL; | 141 | return -EINVAL; |
| 143 | 142 | ||
| 144 | found: | 143 | found: |
| 145 | udev = testdev_to_usbdev (dev); | 144 | udev = testdev_to_usbdev(dev); |
| 146 | if (alt->desc.bAlternateSetting != 0) { | 145 | if (alt->desc.bAlternateSetting != 0) { |
| 147 | tmp = usb_set_interface (udev, | 146 | tmp = usb_set_interface(udev, |
| 148 | alt->desc.bInterfaceNumber, | 147 | alt->desc.bInterfaceNumber, |
| 149 | alt->desc.bAlternateSetting); | 148 | alt->desc.bAlternateSetting); |
| 150 | if (tmp < 0) | 149 | if (tmp < 0) |
| @@ -152,21 +151,21 @@ found: | |||
| 152 | } | 151 | } |
| 153 | 152 | ||
| 154 | if (in) { | 153 | if (in) { |
| 155 | dev->in_pipe = usb_rcvbulkpipe (udev, | 154 | dev->in_pipe = usb_rcvbulkpipe(udev, |
| 156 | in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); | 155 | in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); |
| 157 | dev->out_pipe = usb_sndbulkpipe (udev, | 156 | dev->out_pipe = usb_sndbulkpipe(udev, |
| 158 | out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); | 157 | out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); |
| 159 | } | 158 | } |
| 160 | if (iso_in) { | 159 | if (iso_in) { |
| 161 | dev->iso_in = &iso_in->desc; | 160 | dev->iso_in = &iso_in->desc; |
| 162 | dev->in_iso_pipe = usb_rcvisocpipe (udev, | 161 | dev->in_iso_pipe = usb_rcvisocpipe(udev, |
| 163 | iso_in->desc.bEndpointAddress | 162 | iso_in->desc.bEndpointAddress |
| 164 | & USB_ENDPOINT_NUMBER_MASK); | 163 | & USB_ENDPOINT_NUMBER_MASK); |
| 165 | } | 164 | } |
| 166 | 165 | ||
| 167 | if (iso_out) { | 166 | if (iso_out) { |
| 168 | dev->iso_out = &iso_out->desc; | 167 | dev->iso_out = &iso_out->desc; |
| 169 | dev->out_iso_pipe = usb_sndisocpipe (udev, | 168 | dev->out_iso_pipe = usb_sndisocpipe(udev, |
| 170 | iso_out->desc.bEndpointAddress | 169 | iso_out->desc.bEndpointAddress |
| 171 | & USB_ENDPOINT_NUMBER_MASK); | 170 | & USB_ENDPOINT_NUMBER_MASK); |
| 172 | } | 171 | } |
| @@ -182,12 +181,12 @@ found: | |||
| 182 | * them with non-zero test data (or test for it) when appropriate. | 181 | * them with non-zero test data (or test for it) when appropriate. |
| 183 | */ | 182 | */ |
| 184 | 183 | ||
| 185 | static void simple_callback (struct urb *urb) | 184 | static void simple_callback(struct urb *urb) |
| 186 | { | 185 | { |
| 187 | complete(urb->context); | 186 | complete(urb->context); |
| 188 | } | 187 | } |
| 189 | 188 | ||
| 190 | static struct urb *simple_alloc_urb ( | 189 | static struct urb *simple_alloc_urb( |
| 191 | struct usb_device *udev, | 190 | struct usb_device *udev, |
| 192 | int pipe, | 191 | int pipe, |
| 193 | unsigned long bytes | 192 | unsigned long bytes |
| @@ -195,32 +194,32 @@ static struct urb *simple_alloc_urb ( | |||
| 195 | { | 194 | { |
| 196 | struct urb *urb; | 195 | struct urb *urb; |
| 197 | 196 | ||
| 198 | urb = usb_alloc_urb (0, GFP_KERNEL); | 197 | urb = usb_alloc_urb(0, GFP_KERNEL); |
| 199 | if (!urb) | 198 | if (!urb) |
| 200 | return urb; | 199 | return urb; |
| 201 | usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL); | 200 | usb_fill_bulk_urb(urb, udev, pipe, NULL, bytes, simple_callback, NULL); |
| 202 | urb->interval = (udev->speed == USB_SPEED_HIGH) | 201 | urb->interval = (udev->speed == USB_SPEED_HIGH) |
| 203 | ? (INTERRUPT_RATE << 3) | 202 | ? (INTERRUPT_RATE << 3) |
| 204 | : INTERRUPT_RATE; | 203 | : INTERRUPT_RATE; |
| 205 | urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; | 204 | urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; |
| 206 | if (usb_pipein (pipe)) | 205 | if (usb_pipein(pipe)) |
| 207 | urb->transfer_flags |= URB_SHORT_NOT_OK; | 206 | urb->transfer_flags |= URB_SHORT_NOT_OK; |
| 208 | urb->transfer_buffer = usb_alloc_coherent (udev, bytes, GFP_KERNEL, | 207 | urb->transfer_buffer = usb_alloc_coherent(udev, bytes, GFP_KERNEL, |
| 209 | &urb->transfer_dma); | 208 | &urb->transfer_dma); |
| 210 | if (!urb->transfer_buffer) { | 209 | if (!urb->transfer_buffer) { |
| 211 | usb_free_urb (urb); | 210 | usb_free_urb(urb); |
| 212 | urb = NULL; | 211 | urb = NULL; |
| 213 | } else | 212 | } else |
| 214 | memset (urb->transfer_buffer, 0, bytes); | 213 | memset(urb->transfer_buffer, 0, bytes); |
| 215 | return urb; | 214 | return urb; |
| 216 | } | 215 | } |
| 217 | 216 | ||
| 218 | static unsigned pattern = 0; | 217 | static unsigned pattern; |
| 219 | static unsigned mod_pattern; | 218 | static unsigned mod_pattern; |
| 220 | module_param_named(pattern, mod_pattern, uint, S_IRUGO | S_IWUSR); | 219 | module_param_named(pattern, mod_pattern, uint, S_IRUGO | S_IWUSR); |
| 221 | MODULE_PARM_DESC(mod_pattern, "i/o pattern (0 == zeroes)"); | 220 | MODULE_PARM_DESC(mod_pattern, "i/o pattern (0 == zeroes)"); |
| 222 | 221 | ||
| 223 | static inline void simple_fill_buf (struct urb *urb) | 222 | static inline void simple_fill_buf(struct urb *urb) |
| 224 | { | 223 | { |
| 225 | unsigned i; | 224 | unsigned i; |
| 226 | u8 *buf = urb->transfer_buffer; | 225 | u8 *buf = urb->transfer_buffer; |
| @@ -228,9 +227,9 @@ static inline void simple_fill_buf (struct urb *urb) | |||
| 228 | 227 | ||
| 229 | switch (pattern) { | 228 | switch (pattern) { |
| 230 | default: | 229 | default: |
| 231 | // FALLTHROUGH | 230 | /* FALLTHROUGH */ |
| 232 | case 0: | 231 | case 0: |
| 233 | memset (buf, 0, len); | 232 | memset(buf, 0, len); |
| 234 | break; | 233 | break; |
| 235 | case 1: /* mod63 */ | 234 | case 1: /* mod63 */ |
| 236 | for (i = 0; i < len; i++) | 235 | for (i = 0; i < len; i++) |
| @@ -273,14 +272,14 @@ static inline int simple_check_buf(struct usbtest_dev *tdev, struct urb *urb) | |||
| 273 | return 0; | 272 | return 0; |
| 274 | } | 273 | } |
| 275 | 274 | ||
| 276 | static void simple_free_urb (struct urb *urb) | 275 | static void simple_free_urb(struct urb *urb) |
| 277 | { | 276 | { |
| 278 | usb_free_coherent(urb->dev, urb->transfer_buffer_length, | 277 | usb_free_coherent(urb->dev, urb->transfer_buffer_length, |
| 279 | urb->transfer_buffer, urb->transfer_dma); | 278 | urb->transfer_buffer, urb->transfer_dma); |
| 280 | usb_free_urb (urb); | 279 | usb_free_urb(urb); |
| 281 | } | 280 | } |
| 282 | 281 | ||
| 283 | static int simple_io ( | 282 | static int simple_io( |
| 284 | struct usbtest_dev *tdev, | 283 | struct usbtest_dev *tdev, |
| 285 | struct urb *urb, | 284 | struct urb *urb, |
| 286 | int iterations, | 285 | int iterations, |
| @@ -296,17 +295,18 @@ static int simple_io ( | |||
| 296 | 295 | ||
| 297 | urb->context = &completion; | 296 | urb->context = &completion; |
| 298 | while (retval == 0 && iterations-- > 0) { | 297 | while (retval == 0 && iterations-- > 0) { |
| 299 | init_completion (&completion); | 298 | init_completion(&completion); |
| 300 | if (usb_pipeout (urb->pipe)) | 299 | if (usb_pipeout(urb->pipe)) |
| 301 | simple_fill_buf (urb); | 300 | simple_fill_buf(urb); |
| 302 | if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) | 301 | retval = usb_submit_urb(urb, GFP_KERNEL); |
| 302 | if (retval != 0) | ||
| 303 | break; | 303 | break; |
| 304 | 304 | ||
| 305 | /* NOTE: no timeouts; can't be broken out of by interrupt */ | 305 | /* NOTE: no timeouts; can't be broken out of by interrupt */ |
| 306 | wait_for_completion (&completion); | 306 | wait_for_completion(&completion); |
| 307 | retval = urb->status; | 307 | retval = urb->status; |
| 308 | urb->dev = udev; | 308 | urb->dev = udev; |
| 309 | if (retval == 0 && usb_pipein (urb->pipe)) | 309 | if (retval == 0 && usb_pipein(urb->pipe)) |
| 310 | retval = simple_check_buf(tdev, urb); | 310 | retval = simple_check_buf(tdev, urb); |
| 311 | 311 | ||
| 312 | if (vary) { | 312 | if (vary) { |
| @@ -337,7 +337,7 @@ static int simple_io ( | |||
| 337 | * Yes, this also tests the scatterlist primitives. | 337 | * Yes, this also tests the scatterlist primitives. |
| 338 | */ | 338 | */ |
| 339 | 339 | ||
| 340 | static void free_sglist (struct scatterlist *sg, int nents) | 340 | static void free_sglist(struct scatterlist *sg, int nents) |
| 341 | { | 341 | { |
| 342 | unsigned i; | 342 | unsigned i; |
| 343 | 343 | ||
| @@ -346,19 +346,19 @@ static void free_sglist (struct scatterlist *sg, int nents) | |||
| 346 | for (i = 0; i < nents; i++) { | 346 | for (i = 0; i < nents; i++) { |
| 347 | if (!sg_page(&sg[i])) | 347 | if (!sg_page(&sg[i])) |
| 348 | continue; | 348 | continue; |
| 349 | kfree (sg_virt(&sg[i])); | 349 | kfree(sg_virt(&sg[i])); |
| 350 | } | 350 | } |
| 351 | kfree (sg); | 351 | kfree(sg); |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | static struct scatterlist * | 354 | static struct scatterlist * |
| 355 | alloc_sglist (int nents, int max, int vary) | 355 | alloc_sglist(int nents, int max, int vary) |
| 356 | { | 356 | { |
| 357 | struct scatterlist *sg; | 357 | struct scatterlist *sg; |
| 358 | unsigned i; | 358 | unsigned i; |
| 359 | unsigned size = max; | 359 | unsigned size = max; |
| 360 | 360 | ||
| 361 | sg = kmalloc (nents * sizeof *sg, GFP_KERNEL); | 361 | sg = kmalloc(nents * sizeof *sg, GFP_KERNEL); |
| 362 | if (!sg) | 362 | if (!sg) |
| 363 | return NULL; | 363 | return NULL; |
| 364 | sg_init_table(sg, nents); | 364 | sg_init_table(sg, nents); |
| @@ -367,9 +367,9 @@ alloc_sglist (int nents, int max, int vary) | |||
| 367 | char *buf; | 367 | char *buf; |
| 368 | unsigned j; | 368 | unsigned j; |
| 369 | 369 | ||
| 370 | buf = kzalloc (size, GFP_KERNEL); | 370 | buf = kzalloc(size, GFP_KERNEL); |
| 371 | if (!buf) { | 371 | if (!buf) { |
| 372 | free_sglist (sg, i); | 372 | free_sglist(sg, i); |
| 373 | return NULL; | 373 | return NULL; |
| 374 | } | 374 | } |
| 375 | 375 | ||
| @@ -397,7 +397,7 @@ alloc_sglist (int nents, int max, int vary) | |||
| 397 | return sg; | 397 | return sg; |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | static int perform_sglist ( | 400 | static int perform_sglist( |
| 401 | struct usbtest_dev *tdev, | 401 | struct usbtest_dev *tdev, |
| 402 | unsigned iterations, | 402 | unsigned iterations, |
| 403 | int pipe, | 403 | int pipe, |
| @@ -410,7 +410,7 @@ static int perform_sglist ( | |||
| 410 | int retval = 0; | 410 | int retval = 0; |
| 411 | 411 | ||
| 412 | while (retval == 0 && iterations-- > 0) { | 412 | while (retval == 0 && iterations-- > 0) { |
| 413 | retval = usb_sg_init (req, udev, pipe, | 413 | retval = usb_sg_init(req, udev, pipe, |
| 414 | (udev->speed == USB_SPEED_HIGH) | 414 | (udev->speed == USB_SPEED_HIGH) |
| 415 | ? (INTERRUPT_RATE << 3) | 415 | ? (INTERRUPT_RATE << 3) |
| 416 | : INTERRUPT_RATE, | 416 | : INTERRUPT_RATE, |
| @@ -418,7 +418,7 @@ static int perform_sglist ( | |||
| 418 | 418 | ||
| 419 | if (retval) | 419 | if (retval) |
| 420 | break; | 420 | break; |
| 421 | usb_sg_wait (req); | 421 | usb_sg_wait(req); |
| 422 | retval = req->status; | 422 | retval = req->status; |
| 423 | 423 | ||
| 424 | /* FIXME check resulting data pattern */ | 424 | /* FIXME check resulting data pattern */ |
| @@ -426,9 +426,9 @@ static int perform_sglist ( | |||
| 426 | /* FIXME if endpoint halted, clear halt (and log) */ | 426 | /* FIXME if endpoint halted, clear halt (and log) */ |
| 427 | } | 427 | } |
| 428 | 428 | ||
| 429 | // FIXME for unlink or fault handling tests, don't report | 429 | /* FIXME for unlink or fault handling tests, don't report |
| 430 | // failure if retval is as we expected ... | 430 | * failure if retval is as we expected ... |
| 431 | 431 | */ | |
| 432 | if (retval) | 432 | if (retval) |
| 433 | ERROR(tdev, "perform_sglist failed, " | 433 | ERROR(tdev, "perform_sglist failed, " |
| 434 | "iterations left %d, status %d\n", | 434 | "iterations left %d, status %d\n", |
| @@ -452,31 +452,31 @@ static int perform_sglist ( | |||
| 452 | */ | 452 | */ |
| 453 | 453 | ||
| 454 | static unsigned realworld = 1; | 454 | static unsigned realworld = 1; |
| 455 | module_param (realworld, uint, 0); | 455 | module_param(realworld, uint, 0); |
| 456 | MODULE_PARM_DESC (realworld, "clear to demand stricter spec compliance"); | 456 | MODULE_PARM_DESC(realworld, "clear to demand stricter spec compliance"); |
| 457 | 457 | ||
| 458 | static int get_altsetting (struct usbtest_dev *dev) | 458 | static int get_altsetting(struct usbtest_dev *dev) |
| 459 | { | 459 | { |
| 460 | struct usb_interface *iface = dev->intf; | 460 | struct usb_interface *iface = dev->intf; |
| 461 | struct usb_device *udev = interface_to_usbdev (iface); | 461 | struct usb_device *udev = interface_to_usbdev(iface); |
| 462 | int retval; | 462 | int retval; |
| 463 | 463 | ||
| 464 | retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0), | 464 | retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
| 465 | USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE, | 465 | USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE, |
| 466 | 0, iface->altsetting [0].desc.bInterfaceNumber, | 466 | 0, iface->altsetting[0].desc.bInterfaceNumber, |
| 467 | dev->buf, 1, USB_CTRL_GET_TIMEOUT); | 467 | dev->buf, 1, USB_CTRL_GET_TIMEOUT); |
| 468 | switch (retval) { | 468 | switch (retval) { |
| 469 | case 1: | 469 | case 1: |
| 470 | return dev->buf [0]; | 470 | return dev->buf[0]; |
| 471 | case 0: | 471 | case 0: |
| 472 | retval = -ERANGE; | 472 | retval = -ERANGE; |
| 473 | // FALLTHROUGH | 473 | /* FALLTHROUGH */ |
| 474 | default: | 474 | default: |
| 475 | return retval; | 475 | return retval; |
| 476 | } | 476 | } |
| 477 | } | 477 | } |
| 478 | 478 | ||
| 479 | static int set_altsetting (struct usbtest_dev *dev, int alternate) | 479 | static int set_altsetting(struct usbtest_dev *dev, int alternate) |
| 480 | { | 480 | { |
| 481 | struct usb_interface *iface = dev->intf; | 481 | struct usb_interface *iface = dev->intf; |
| 482 | struct usb_device *udev; | 482 | struct usb_device *udev; |
| @@ -484,9 +484,9 @@ static int set_altsetting (struct usbtest_dev *dev, int alternate) | |||
| 484 | if (alternate < 0 || alternate >= 256) | 484 | if (alternate < 0 || alternate >= 256) |
| 485 | return -EINVAL; | 485 | return -EINVAL; |
| 486 | 486 | ||
| 487 | udev = interface_to_usbdev (iface); | 487 | udev = interface_to_usbdev(iface); |
| 488 | return usb_set_interface (udev, | 488 | return usb_set_interface(udev, |
| 489 | iface->altsetting [0].desc.bInterfaceNumber, | 489 | iface->altsetting[0].desc.bInterfaceNumber, |
| 490 | alternate); | 490 | alternate); |
| 491 | } | 491 | } |
| 492 | 492 | ||
| @@ -519,9 +519,9 @@ static int is_good_config(struct usbtest_dev *tdev, int len) | |||
| 519 | return 0; | 519 | return 0; |
| 520 | } | 520 | } |
| 521 | 521 | ||
| 522 | if (le16_to_cpu(config->wTotalLength) == len) /* read it all */ | 522 | if (le16_to_cpu(config->wTotalLength) == len) /* read it all */ |
| 523 | return 1; | 523 | return 1; |
| 524 | if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */ | 524 | if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */ |
| 525 | return 1; | 525 | return 1; |
| 526 | ERROR(tdev, "bogus config descriptor read size\n"); | 526 | ERROR(tdev, "bogus config descriptor read size\n"); |
| 527 | return 0; | 527 | return 0; |
| @@ -542,10 +542,10 @@ static int is_good_config(struct usbtest_dev *tdev, int len) | |||
| 542 | * to see if usbcore, hcd, and device all behave right. such testing would | 542 | * to see if usbcore, hcd, and device all behave right. such testing would |
| 543 | * involve varied read sizes and other operation sequences. | 543 | * involve varied read sizes and other operation sequences. |
| 544 | */ | 544 | */ |
| 545 | static int ch9_postconfig (struct usbtest_dev *dev) | 545 | static int ch9_postconfig(struct usbtest_dev *dev) |
| 546 | { | 546 | { |
| 547 | struct usb_interface *iface = dev->intf; | 547 | struct usb_interface *iface = dev->intf; |
| 548 | struct usb_device *udev = interface_to_usbdev (iface); | 548 | struct usb_device *udev = interface_to_usbdev(iface); |
| 549 | int i, alt, retval; | 549 | int i, alt, retval; |
| 550 | 550 | ||
| 551 | /* [9.2.3] if there's more than one altsetting, we need to be able to | 551 | /* [9.2.3] if there's more than one altsetting, we need to be able to |
| @@ -554,7 +554,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
| 554 | for (i = 0; i < iface->num_altsetting; i++) { | 554 | for (i = 0; i < iface->num_altsetting; i++) { |
| 555 | 555 | ||
| 556 | /* 9.2.3 constrains the range here */ | 556 | /* 9.2.3 constrains the range here */ |
| 557 | alt = iface->altsetting [i].desc.bAlternateSetting; | 557 | alt = iface->altsetting[i].desc.bAlternateSetting; |
| 558 | if (alt < 0 || alt >= iface->num_altsetting) { | 558 | if (alt < 0 || alt >= iface->num_altsetting) { |
| 559 | dev_err(&iface->dev, | 559 | dev_err(&iface->dev, |
| 560 | "invalid alt [%d].bAltSetting = %d\n", | 560 | "invalid alt [%d].bAltSetting = %d\n", |
| @@ -566,7 +566,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
| 566 | continue; | 566 | continue; |
| 567 | 567 | ||
| 568 | /* [9.4.10] set_interface */ | 568 | /* [9.4.10] set_interface */ |
| 569 | retval = set_altsetting (dev, alt); | 569 | retval = set_altsetting(dev, alt); |
| 570 | if (retval) { | 570 | if (retval) { |
| 571 | dev_err(&iface->dev, "can't set_interface = %d, %d\n", | 571 | dev_err(&iface->dev, "can't set_interface = %d, %d\n", |
| 572 | alt, retval); | 572 | alt, retval); |
| @@ -574,7 +574,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
| 574 | } | 574 | } |
| 575 | 575 | ||
| 576 | /* [9.4.4] get_interface always works */ | 576 | /* [9.4.4] get_interface always works */ |
| 577 | retval = get_altsetting (dev); | 577 | retval = get_altsetting(dev); |
| 578 | if (retval != alt) { | 578 | if (retval != alt) { |
| 579 | dev_err(&iface->dev, "get alt should be %d, was %d\n", | 579 | dev_err(&iface->dev, "get alt should be %d, was %d\n", |
| 580 | alt, retval); | 580 | alt, retval); |
| @@ -591,11 +591,11 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
| 591 | * ... although some cheap devices (like one TI Hub I've got) | 591 | * ... although some cheap devices (like one TI Hub I've got) |
| 592 | * won't return config descriptors except before set_config. | 592 | * won't return config descriptors except before set_config. |
| 593 | */ | 593 | */ |
| 594 | retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0), | 594 | retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
| 595 | USB_REQ_GET_CONFIGURATION, | 595 | USB_REQ_GET_CONFIGURATION, |
| 596 | USB_DIR_IN | USB_RECIP_DEVICE, | 596 | USB_DIR_IN | USB_RECIP_DEVICE, |
| 597 | 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT); | 597 | 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT); |
| 598 | if (retval != 1 || dev->buf [0] != expected) { | 598 | if (retval != 1 || dev->buf[0] != expected) { |
| 599 | dev_err(&iface->dev, "get config --> %d %d (1 %d)\n", | 599 | dev_err(&iface->dev, "get config --> %d %d (1 %d)\n", |
| 600 | retval, dev->buf[0], expected); | 600 | retval, dev->buf[0], expected); |
| 601 | return (retval < 0) ? retval : -EDOM; | 601 | return (retval < 0) ? retval : -EDOM; |
| @@ -603,7 +603,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
| 603 | } | 603 | } |
| 604 | 604 | ||
| 605 | /* there's always [9.4.3] a device descriptor [9.6.1] */ | 605 | /* there's always [9.4.3] a device descriptor [9.6.1] */ |
| 606 | retval = usb_get_descriptor (udev, USB_DT_DEVICE, 0, | 606 | retval = usb_get_descriptor(udev, USB_DT_DEVICE, 0, |
| 607 | dev->buf, sizeof udev->descriptor); | 607 | dev->buf, sizeof udev->descriptor); |
| 608 | if (retval != sizeof udev->descriptor) { | 608 | if (retval != sizeof udev->descriptor) { |
| 609 | dev_err(&iface->dev, "dev descriptor --> %d\n", retval); | 609 | dev_err(&iface->dev, "dev descriptor --> %d\n", retval); |
| @@ -612,7 +612,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
| 612 | 612 | ||
| 613 | /* there's always [9.4.3] at least one config descriptor [9.6.3] */ | 613 | /* there's always [9.4.3] at least one config descriptor [9.6.3] */ |
| 614 | for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { | 614 | for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { |
| 615 | retval = usb_get_descriptor (udev, USB_DT_CONFIG, i, | 615 | retval = usb_get_descriptor(udev, USB_DT_CONFIG, i, |
| 616 | dev->buf, TBUF_SIZE); | 616 | dev->buf, TBUF_SIZE); |
| 617 | if (!is_good_config(dev, retval)) { | 617 | if (!is_good_config(dev, retval)) { |
| 618 | dev_err(&iface->dev, | 618 | dev_err(&iface->dev, |
| @@ -621,18 +621,19 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
| 621 | return (retval < 0) ? retval : -EDOM; | 621 | return (retval < 0) ? retval : -EDOM; |
| 622 | } | 622 | } |
| 623 | 623 | ||
| 624 | // FIXME cross-checking udev->config[i] to make sure usbcore | 624 | /* FIXME cross-checking udev->config[i] to make sure usbcore |
| 625 | // parsed it right (etc) would be good testing paranoia | 625 | * parsed it right (etc) would be good testing paranoia |
| 626 | */ | ||
| 626 | } | 627 | } |
| 627 | 628 | ||
| 628 | /* and sometimes [9.2.6.6] speed dependent descriptors */ | 629 | /* and sometimes [9.2.6.6] speed dependent descriptors */ |
| 629 | if (le16_to_cpu(udev->descriptor.bcdUSB) == 0x0200) { | 630 | if (le16_to_cpu(udev->descriptor.bcdUSB) == 0x0200) { |
| 630 | struct usb_qualifier_descriptor *d = NULL; | 631 | struct usb_qualifier_descriptor *d = NULL; |
| 631 | 632 | ||
| 632 | /* device qualifier [9.6.2] */ | 633 | /* device qualifier [9.6.2] */ |
| 633 | retval = usb_get_descriptor (udev, | 634 | retval = usb_get_descriptor(udev, |
| 634 | USB_DT_DEVICE_QUALIFIER, 0, dev->buf, | 635 | USB_DT_DEVICE_QUALIFIER, 0, dev->buf, |
| 635 | sizeof (struct usb_qualifier_descriptor)); | 636 | sizeof(struct usb_qualifier_descriptor)); |
| 636 | if (retval == -EPIPE) { | 637 | if (retval == -EPIPE) { |
| 637 | if (udev->speed == USB_SPEED_HIGH) { | 638 | if (udev->speed == USB_SPEED_HIGH) { |
| 638 | dev_err(&iface->dev, | 639 | dev_err(&iface->dev, |
| @@ -641,7 +642,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
| 641 | return (retval < 0) ? retval : -EDOM; | 642 | return (retval < 0) ? retval : -EDOM; |
| 642 | } | 643 | } |
| 643 | /* usb2.0 but not high-speed capable; fine */ | 644 | /* usb2.0 but not high-speed capable; fine */ |
| 644 | } else if (retval != sizeof (struct usb_qualifier_descriptor)) { | 645 | } else if (retval != sizeof(struct usb_qualifier_descriptor)) { |
| 645 | dev_err(&iface->dev, "dev qualifier --> %d\n", retval); | 646 | dev_err(&iface->dev, "dev qualifier --> %d\n", retval); |
| 646 | return (retval < 0) ? retval : -EDOM; | 647 | return (retval < 0) ? retval : -EDOM; |
| 647 | } else | 648 | } else |
| @@ -651,7 +652,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
| 651 | if (d) { | 652 | if (d) { |
| 652 | unsigned max = d->bNumConfigurations; | 653 | unsigned max = d->bNumConfigurations; |
| 653 | for (i = 0; i < max; i++) { | 654 | for (i = 0; i < max; i++) { |
| 654 | retval = usb_get_descriptor (udev, | 655 | retval = usb_get_descriptor(udev, |
| 655 | USB_DT_OTHER_SPEED_CONFIG, i, | 656 | USB_DT_OTHER_SPEED_CONFIG, i, |
| 656 | dev->buf, TBUF_SIZE); | 657 | dev->buf, TBUF_SIZE); |
| 657 | if (!is_good_config(dev, retval)) { | 658 | if (!is_good_config(dev, retval)) { |
| @@ -663,25 +664,26 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
| 663 | } | 664 | } |
| 664 | } | 665 | } |
| 665 | } | 666 | } |
| 666 | // FIXME fetch strings from at least the device descriptor | 667 | /* FIXME fetch strings from at least the device descriptor */ |
| 667 | 668 | ||
| 668 | /* [9.4.5] get_status always works */ | 669 | /* [9.4.5] get_status always works */ |
| 669 | retval = usb_get_status (udev, USB_RECIP_DEVICE, 0, dev->buf); | 670 | retval = usb_get_status(udev, USB_RECIP_DEVICE, 0, dev->buf); |
| 670 | if (retval != 2) { | 671 | if (retval != 2) { |
| 671 | dev_err(&iface->dev, "get dev status --> %d\n", retval); | 672 | dev_err(&iface->dev, "get dev status --> %d\n", retval); |
| 672 | return (retval < 0) ? retval : -EDOM; | 673 | return (retval < 0) ? retval : -EDOM; |
| 673 | } | 674 | } |
| 674 | 675 | ||
| 675 | // FIXME configuration.bmAttributes says if we could try to set/clear | 676 | /* FIXME configuration.bmAttributes says if we could try to set/clear |
| 676 | // the device's remote wakeup feature ... if we can, test that here | 677 | * the device's remote wakeup feature ... if we can, test that here |
| 678 | */ | ||
| 677 | 679 | ||
| 678 | retval = usb_get_status (udev, USB_RECIP_INTERFACE, | 680 | retval = usb_get_status(udev, USB_RECIP_INTERFACE, |
| 679 | iface->altsetting [0].desc.bInterfaceNumber, dev->buf); | 681 | iface->altsetting[0].desc.bInterfaceNumber, dev->buf); |
| 680 | if (retval != 2) { | 682 | if (retval != 2) { |
| 681 | dev_err(&iface->dev, "get interface status --> %d\n", retval); | 683 | dev_err(&iface->dev, "get interface status --> %d\n", retval); |
| 682 | return (retval < 0) ? retval : -EDOM; | 684 | return (retval < 0) ? retval : -EDOM; |
| 683 | } | 685 | } |
| 684 | // FIXME get status for each endpoint in the interface | 686 | /* FIXME get status for each endpoint in the interface */ |
| 685 | 687 | ||
| 686 | return 0; | 688 | return 0; |
| 687 | } | 689 | } |
| @@ -717,7 +719,7 @@ struct subcase { | |||
| 717 | int expected; | 719 | int expected; |
| 718 | }; | 720 | }; |
| 719 | 721 | ||
| 720 | static void ctrl_complete (struct urb *urb) | 722 | static void ctrl_complete(struct urb *urb) |
| 721 | { | 723 | { |
| 722 | struct ctrl_ctx *ctx = urb->context; | 724 | struct ctrl_ctx *ctx = urb->context; |
| 723 | struct usb_ctrlrequest *reqp; | 725 | struct usb_ctrlrequest *reqp; |
| @@ -725,9 +727,9 @@ static void ctrl_complete (struct urb *urb) | |||
| 725 | int status = urb->status; | 727 | int status = urb->status; |
| 726 | 728 | ||
| 727 | reqp = (struct usb_ctrlrequest *)urb->setup_packet; | 729 | reqp = (struct usb_ctrlrequest *)urb->setup_packet; |
| 728 | subcase = container_of (reqp, struct subcase, setup); | 730 | subcase = container_of(reqp, struct subcase, setup); |
| 729 | 731 | ||
| 730 | spin_lock (&ctx->lock); | 732 | spin_lock(&ctx->lock); |
| 731 | ctx->count--; | 733 | ctx->count--; |
| 732 | ctx->pending--; | 734 | ctx->pending--; |
| 733 | 735 | ||
| @@ -787,14 +789,14 @@ error: | |||
| 787 | 789 | ||
| 788 | /* unlink whatever's still pending */ | 790 | /* unlink whatever's still pending */ |
| 789 | for (i = 1; i < ctx->param->sglen; i++) { | 791 | for (i = 1; i < ctx->param->sglen; i++) { |
| 790 | struct urb *u = ctx->urb [ | 792 | struct urb *u = ctx->urb[ |
| 791 | (i + subcase->number) | 793 | (i + subcase->number) |
| 792 | % ctx->param->sglen]; | 794 | % ctx->param->sglen]; |
| 793 | 795 | ||
| 794 | if (u == urb || !u->dev) | 796 | if (u == urb || !u->dev) |
| 795 | continue; | 797 | continue; |
| 796 | spin_unlock(&ctx->lock); | 798 | spin_unlock(&ctx->lock); |
| 797 | status = usb_unlink_urb (u); | 799 | status = usb_unlink_urb(u); |
| 798 | spin_lock(&ctx->lock); | 800 | spin_lock(&ctx->lock); |
| 799 | switch (status) { | 801 | switch (status) { |
| 800 | case -EINPROGRESS: | 802 | case -EINPROGRESS: |
| @@ -812,7 +814,8 @@ error: | |||
| 812 | 814 | ||
| 813 | /* resubmit if we need to, else mark this as done */ | 815 | /* resubmit if we need to, else mark this as done */ |
| 814 | if ((status == 0) && (ctx->pending < ctx->count)) { | 816 | if ((status == 0) && (ctx->pending < ctx->count)) { |
| 815 | if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) { | 817 | status = usb_submit_urb(urb, GFP_ATOMIC); |
| 818 | if (status != 0) { | ||
| 816 | ERROR(ctx->dev, | 819 | ERROR(ctx->dev, |
| 817 | "can't resubmit ctrl %02x.%02x, err %d\n", | 820 | "can't resubmit ctrl %02x.%02x, err %d\n", |
| 818 | reqp->bRequestType, reqp->bRequest, status); | 821 | reqp->bRequestType, reqp->bRequest, status); |
| @@ -824,21 +827,21 @@ error: | |||
| 824 | 827 | ||
| 825 | /* signal completion when nothing's queued */ | 828 | /* signal completion when nothing's queued */ |
| 826 | if (ctx->pending == 0) | 829 | if (ctx->pending == 0) |
| 827 | complete (&ctx->complete); | 830 | complete(&ctx->complete); |
| 828 | spin_unlock (&ctx->lock); | 831 | spin_unlock(&ctx->lock); |
| 829 | } | 832 | } |
| 830 | 833 | ||
| 831 | static int | 834 | static int |
| 832 | test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | 835 | test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param) |
| 833 | { | 836 | { |
| 834 | struct usb_device *udev = testdev_to_usbdev (dev); | 837 | struct usb_device *udev = testdev_to_usbdev(dev); |
| 835 | struct urb **urb; | 838 | struct urb **urb; |
| 836 | struct ctrl_ctx context; | 839 | struct ctrl_ctx context; |
| 837 | int i; | 840 | int i; |
| 838 | 841 | ||
| 839 | spin_lock_init (&context.lock); | 842 | spin_lock_init(&context.lock); |
| 840 | context.dev = dev; | 843 | context.dev = dev; |
| 841 | init_completion (&context.complete); | 844 | init_completion(&context.complete); |
| 842 | context.count = param->sglen * param->iterations; | 845 | context.count = param->sglen * param->iterations; |
| 843 | context.pending = 0; | 846 | context.pending = 0; |
| 844 | context.status = -ENOMEM; | 847 | context.status = -ENOMEM; |
| @@ -853,7 +856,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
| 853 | if (!urb) | 856 | if (!urb) |
| 854 | return -ENOMEM; | 857 | return -ENOMEM; |
| 855 | for (i = 0; i < param->sglen; i++) { | 858 | for (i = 0; i < param->sglen; i++) { |
| 856 | int pipe = usb_rcvctrlpipe (udev, 0); | 859 | int pipe = usb_rcvctrlpipe(udev, 0); |
| 857 | unsigned len; | 860 | unsigned len; |
| 858 | struct urb *u; | 861 | struct urb *u; |
| 859 | struct usb_ctrlrequest req; | 862 | struct usb_ctrlrequest req; |
| @@ -869,104 +872,108 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
| 869 | * device, but some are chosen to trigger protocol stalls | 872 | * device, but some are chosen to trigger protocol stalls |
| 870 | * or short reads. | 873 | * or short reads. |
| 871 | */ | 874 | */ |
| 872 | memset (&req, 0, sizeof req); | 875 | memset(&req, 0, sizeof req); |
| 873 | req.bRequest = USB_REQ_GET_DESCRIPTOR; | 876 | req.bRequest = USB_REQ_GET_DESCRIPTOR; |
| 874 | req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; | 877 | req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; |
| 875 | 878 | ||
| 876 | switch (i % NUM_SUBCASES) { | 879 | switch (i % NUM_SUBCASES) { |
| 877 | case 0: // get device descriptor | 880 | case 0: /* get device descriptor */ |
| 878 | req.wValue = cpu_to_le16 (USB_DT_DEVICE << 8); | 881 | req.wValue = cpu_to_le16(USB_DT_DEVICE << 8); |
| 879 | len = sizeof (struct usb_device_descriptor); | 882 | len = sizeof(struct usb_device_descriptor); |
| 880 | break; | 883 | break; |
| 881 | case 1: // get first config descriptor (only) | 884 | case 1: /* get first config descriptor (only) */ |
| 882 | req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); | 885 | req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); |
| 883 | len = sizeof (struct usb_config_descriptor); | 886 | len = sizeof(struct usb_config_descriptor); |
| 884 | break; | 887 | break; |
| 885 | case 2: // get altsetting (OFTEN STALLS) | 888 | case 2: /* get altsetting (OFTEN STALLS) */ |
| 886 | req.bRequest = USB_REQ_GET_INTERFACE; | 889 | req.bRequest = USB_REQ_GET_INTERFACE; |
| 887 | req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; | 890 | req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; |
| 888 | // index = 0 means first interface | 891 | /* index = 0 means first interface */ |
| 889 | len = 1; | 892 | len = 1; |
| 890 | expected = EPIPE; | 893 | expected = EPIPE; |
| 891 | break; | 894 | break; |
| 892 | case 3: // get interface status | 895 | case 3: /* get interface status */ |
| 893 | req.bRequest = USB_REQ_GET_STATUS; | 896 | req.bRequest = USB_REQ_GET_STATUS; |
| 894 | req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; | 897 | req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; |
| 895 | // interface 0 | 898 | /* interface 0 */ |
| 896 | len = 2; | 899 | len = 2; |
| 897 | break; | 900 | break; |
| 898 | case 4: // get device status | 901 | case 4: /* get device status */ |
| 899 | req.bRequest = USB_REQ_GET_STATUS; | 902 | req.bRequest = USB_REQ_GET_STATUS; |
| 900 | req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; | 903 | req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; |
| 901 | len = 2; | 904 | len = 2; |
| 902 | break; | 905 | break; |
| 903 | case 5: // get device qualifier (MAY STALL) | 906 | case 5: /* get device qualifier (MAY STALL) */ |
| 904 | req.wValue = cpu_to_le16 (USB_DT_DEVICE_QUALIFIER << 8); | 907 | req.wValue = cpu_to_le16 (USB_DT_DEVICE_QUALIFIER << 8); |
| 905 | len = sizeof (struct usb_qualifier_descriptor); | 908 | len = sizeof(struct usb_qualifier_descriptor); |
| 906 | if (udev->speed != USB_SPEED_HIGH) | 909 | if (udev->speed != USB_SPEED_HIGH) |
| 907 | expected = EPIPE; | 910 | expected = EPIPE; |
| 908 | break; | 911 | break; |
| 909 | case 6: // get first config descriptor, plus interface | 912 | case 6: /* get first config descriptor, plus interface */ |
| 910 | req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); | 913 | req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); |
| 911 | len = sizeof (struct usb_config_descriptor); | 914 | len = sizeof(struct usb_config_descriptor); |
| 912 | len += sizeof (struct usb_interface_descriptor); | 915 | len += sizeof(struct usb_interface_descriptor); |
| 913 | break; | 916 | break; |
| 914 | case 7: // get interface descriptor (ALWAYS STALLS) | 917 | case 7: /* get interface descriptor (ALWAYS STALLS) */ |
| 915 | req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8); | 918 | req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8); |
| 916 | // interface == 0 | 919 | /* interface == 0 */ |
| 917 | len = sizeof (struct usb_interface_descriptor); | 920 | len = sizeof(struct usb_interface_descriptor); |
| 918 | expected = -EPIPE; | 921 | expected = -EPIPE; |
| 919 | break; | 922 | break; |
| 920 | // NOTE: two consecutive stalls in the queue here. | 923 | /* NOTE: two consecutive stalls in the queue here. |
| 921 | // that tests fault recovery a bit more aggressively. | 924 | * that tests fault recovery a bit more aggressively. */ |
| 922 | case 8: // clear endpoint halt (MAY STALL) | 925 | case 8: /* clear endpoint halt (MAY STALL) */ |
| 923 | req.bRequest = USB_REQ_CLEAR_FEATURE; | 926 | req.bRequest = USB_REQ_CLEAR_FEATURE; |
| 924 | req.bRequestType = USB_RECIP_ENDPOINT; | 927 | req.bRequestType = USB_RECIP_ENDPOINT; |
| 925 | // wValue 0 == ep halt | 928 | /* wValue 0 == ep halt */ |
| 926 | // wIndex 0 == ep0 (shouldn't halt!) | 929 | /* wIndex 0 == ep0 (shouldn't halt!) */ |
| 927 | len = 0; | 930 | len = 0; |
| 928 | pipe = usb_sndctrlpipe (udev, 0); | 931 | pipe = usb_sndctrlpipe(udev, 0); |
| 929 | expected = EPIPE; | 932 | expected = EPIPE; |
| 930 | break; | 933 | break; |
| 931 | case 9: // get endpoint status | 934 | case 9: /* get endpoint status */ |
| 932 | req.bRequest = USB_REQ_GET_STATUS; | 935 | req.bRequest = USB_REQ_GET_STATUS; |
| 933 | req.bRequestType = USB_DIR_IN|USB_RECIP_ENDPOINT; | 936 | req.bRequestType = USB_DIR_IN|USB_RECIP_ENDPOINT; |
| 934 | // endpoint 0 | 937 | /* endpoint 0 */ |
| 935 | len = 2; | 938 | len = 2; |
| 936 | break; | 939 | break; |
| 937 | case 10: // trigger short read (EREMOTEIO) | 940 | case 10: /* trigger short read (EREMOTEIO) */ |
| 938 | req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); | 941 | req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); |
| 939 | len = 1024; | 942 | len = 1024; |
| 940 | expected = -EREMOTEIO; | 943 | expected = -EREMOTEIO; |
| 941 | break; | 944 | break; |
| 942 | // NOTE: two consecutive _different_ faults in the queue. | 945 | /* NOTE: two consecutive _different_ faults in the queue. */ |
| 943 | case 11: // get endpoint descriptor (ALWAYS STALLS) | 946 | case 11: /* get endpoint descriptor (ALWAYS STALLS) */ |
| 944 | req.wValue = cpu_to_le16 (USB_DT_ENDPOINT << 8); | 947 | req.wValue = cpu_to_le16(USB_DT_ENDPOINT << 8); |
| 945 | // endpoint == 0 | 948 | /* endpoint == 0 */ |
| 946 | len = sizeof (struct usb_interface_descriptor); | 949 | len = sizeof(struct usb_interface_descriptor); |
| 947 | expected = EPIPE; | 950 | expected = EPIPE; |
| 948 | break; | 951 | break; |
| 949 | // NOTE: sometimes even a third fault in the queue! | 952 | /* NOTE: sometimes even a third fault in the queue! */ |
| 950 | case 12: // get string 0 descriptor (MAY STALL) | 953 | case 12: /* get string 0 descriptor (MAY STALL) */ |
| 951 | req.wValue = cpu_to_le16 (USB_DT_STRING << 8); | 954 | req.wValue = cpu_to_le16(USB_DT_STRING << 8); |
| 952 | // string == 0, for language IDs | 955 | /* string == 0, for language IDs */ |
| 953 | len = sizeof (struct usb_interface_descriptor); | 956 | len = sizeof(struct usb_interface_descriptor); |
| 954 | // may succeed when > 4 languages | 957 | /* may succeed when > 4 languages */ |
| 955 | expected = EREMOTEIO; // or EPIPE, if no strings | 958 | expected = EREMOTEIO; /* or EPIPE, if no strings */ |
| 956 | break; | 959 | break; |
| 957 | case 13: // short read, resembling case 10 | 960 | case 13: /* short read, resembling case 10 */ |
| 958 | req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); | 961 | req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); |
| 959 | // last data packet "should" be DATA1, not DATA0 | 962 | /* last data packet "should" be DATA1, not DATA0 */ |
| 960 | len = 1024 - udev->descriptor.bMaxPacketSize0; | 963 | len = 1024 - udev->descriptor.bMaxPacketSize0; |
| 961 | expected = -EREMOTEIO; | 964 | expected = -EREMOTEIO; |
| 962 | break; | 965 | break; |
| 963 | case 14: // short read; try to fill the last packet | 966 | case 14: /* short read; try to fill the last packet */ |
| 964 | req.wValue = cpu_to_le16 ((USB_DT_DEVICE << 8) | 0); | 967 | req.wValue = cpu_to_le16((USB_DT_DEVICE << 8) | 0); |
| 965 | /* device descriptor size == 18 bytes */ | 968 | /* device descriptor size == 18 bytes */ |
| 966 | len = udev->descriptor.bMaxPacketSize0; | 969 | len = udev->descriptor.bMaxPacketSize0; |
| 967 | switch (len) { | 970 | switch (len) { |
| 968 | case 8: len = 24; break; | 971 | case 8: |
| 969 | case 16: len = 32; break; | 972 | len = 24; |
| 973 | break; | ||
| 974 | case 16: | ||
| 975 | len = 32; | ||
| 976 | break; | ||
| 970 | } | 977 | } |
| 971 | expected = -EREMOTEIO; | 978 | expected = -EREMOTEIO; |
| 972 | break; | 979 | break; |
| @@ -975,8 +982,8 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
| 975 | context.status = -EINVAL; | 982 | context.status = -EINVAL; |
| 976 | goto cleanup; | 983 | goto cleanup; |
| 977 | } | 984 | } |
| 978 | req.wLength = cpu_to_le16 (len); | 985 | req.wLength = cpu_to_le16(len); |
| 979 | urb [i] = u = simple_alloc_urb (udev, pipe, len); | 986 | urb[i] = u = simple_alloc_urb(udev, pipe, len); |
| 980 | if (!u) | 987 | if (!u) |
| 981 | goto cleanup; | 988 | goto cleanup; |
| 982 | 989 | ||
| @@ -994,9 +1001,9 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
| 994 | 1001 | ||
| 995 | /* queue the urbs */ | 1002 | /* queue the urbs */ |
| 996 | context.urb = urb; | 1003 | context.urb = urb; |
| 997 | spin_lock_irq (&context.lock); | 1004 | spin_lock_irq(&context.lock); |
| 998 | for (i = 0; i < param->sglen; i++) { | 1005 | for (i = 0; i < param->sglen; i++) { |
| 999 | context.status = usb_submit_urb (urb [i], GFP_ATOMIC); | 1006 | context.status = usb_submit_urb(urb[i], GFP_ATOMIC); |
| 1000 | if (context.status != 0) { | 1007 | if (context.status != 0) { |
| 1001 | ERROR(dev, "can't submit urb[%d], status %d\n", | 1008 | ERROR(dev, "can't submit urb[%d], status %d\n", |
| 1002 | i, context.status); | 1009 | i, context.status); |
| @@ -1005,23 +1012,23 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
| 1005 | } | 1012 | } |
| 1006 | context.pending++; | 1013 | context.pending++; |
| 1007 | } | 1014 | } |
| 1008 | spin_unlock_irq (&context.lock); | 1015 | spin_unlock_irq(&context.lock); |
| 1009 | 1016 | ||
| 1010 | /* FIXME set timer and time out; provide a disconnect hook */ | 1017 | /* FIXME set timer and time out; provide a disconnect hook */ |
| 1011 | 1018 | ||
| 1012 | /* wait for the last one to complete */ | 1019 | /* wait for the last one to complete */ |
| 1013 | if (context.pending > 0) | 1020 | if (context.pending > 0) |
| 1014 | wait_for_completion (&context.complete); | 1021 | wait_for_completion(&context.complete); |
| 1015 | 1022 | ||
| 1016 | cleanup: | 1023 | cleanup: |
| 1017 | for (i = 0; i < param->sglen; i++) { | 1024 | for (i = 0; i < param->sglen; i++) { |
| 1018 | if (!urb [i]) | 1025 | if (!urb[i]) |
| 1019 | continue; | 1026 | continue; |
| 1020 | urb [i]->dev = udev; | 1027 | urb[i]->dev = udev; |
| 1021 | kfree(urb[i]->setup_packet); | 1028 | kfree(urb[i]->setup_packet); |
| 1022 | simple_free_urb (urb [i]); | 1029 | simple_free_urb(urb[i]); |
| 1023 | } | 1030 | } |
| 1024 | kfree (urb); | 1031 | kfree(urb); |
| 1025 | return context.status; | 1032 | return context.status; |
| 1026 | } | 1033 | } |
| 1027 | #undef NUM_SUBCASES | 1034 | #undef NUM_SUBCASES |
| @@ -1029,27 +1036,27 @@ cleanup: | |||
| 1029 | 1036 | ||
| 1030 | /*-------------------------------------------------------------------------*/ | 1037 | /*-------------------------------------------------------------------------*/ |
| 1031 | 1038 | ||
| 1032 | static void unlink1_callback (struct urb *urb) | 1039 | static void unlink1_callback(struct urb *urb) |
| 1033 | { | 1040 | { |
| 1034 | int status = urb->status; | 1041 | int status = urb->status; |
| 1035 | 1042 | ||
| 1036 | // we "know" -EPIPE (stall) never happens | 1043 | /* we "know" -EPIPE (stall) never happens */ |
| 1037 | if (!status) | 1044 | if (!status) |
| 1038 | status = usb_submit_urb (urb, GFP_ATOMIC); | 1045 | status = usb_submit_urb(urb, GFP_ATOMIC); |
| 1039 | if (status) { | 1046 | if (status) { |
| 1040 | urb->status = status; | 1047 | urb->status = status; |
| 1041 | complete(urb->context); | 1048 | complete(urb->context); |
| 1042 | } | 1049 | } |
| 1043 | } | 1050 | } |
| 1044 | 1051 | ||
| 1045 | static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) | 1052 | static int unlink1(struct usbtest_dev *dev, int pipe, int size, int async) |
| 1046 | { | 1053 | { |
| 1047 | struct urb *urb; | 1054 | struct urb *urb; |
| 1048 | struct completion completion; | 1055 | struct completion completion; |
| 1049 | int retval = 0; | 1056 | int retval = 0; |
| 1050 | 1057 | ||
| 1051 | init_completion (&completion); | 1058 | init_completion(&completion); |
| 1052 | urb = simple_alloc_urb (testdev_to_usbdev (dev), pipe, size); | 1059 | urb = simple_alloc_urb(testdev_to_usbdev(dev), pipe, size); |
| 1053 | if (!urb) | 1060 | if (!urb) |
| 1054 | return -ENOMEM; | 1061 | return -ENOMEM; |
| 1055 | urb->context = &completion; | 1062 | urb->context = &completion; |
| @@ -1061,7 +1068,8 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) | |||
| 1061 | * FIXME want additional tests for when endpoint is STALLing | 1068 | * FIXME want additional tests for when endpoint is STALLing |
| 1062 | * due to errors, or is just NAKing requests. | 1069 | * due to errors, or is just NAKing requests. |
| 1063 | */ | 1070 | */ |
| 1064 | if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) { | 1071 | retval = usb_submit_urb(urb, GFP_KERNEL); |
| 1072 | if (retval != 0) { | ||
| 1065 | dev_err(&dev->intf->dev, "submit fail %d\n", retval); | 1073 | dev_err(&dev->intf->dev, "submit fail %d\n", retval); |
| 1066 | return retval; | 1074 | return retval; |
| 1067 | } | 1075 | } |
| @@ -1069,7 +1077,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) | |||
| 1069 | /* unlinking that should always work. variable delay tests more | 1077 | /* unlinking that should always work. variable delay tests more |
| 1070 | * hcd states and code paths, even with little other system load. | 1078 | * hcd states and code paths, even with little other system load. |
| 1071 | */ | 1079 | */ |
| 1072 | msleep (jiffies % (2 * INTERRUPT_RATE)); | 1080 | msleep(jiffies % (2 * INTERRUPT_RATE)); |
| 1073 | if (async) { | 1081 | if (async) { |
| 1074 | while (!completion_done(&completion)) { | 1082 | while (!completion_done(&completion)) { |
| 1075 | retval = usb_unlink_urb(urb); | 1083 | retval = usb_unlink_urb(urb); |
| @@ -1098,11 +1106,11 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) | |||
| 1098 | break; | 1106 | break; |
| 1099 | } | 1107 | } |
| 1100 | } else | 1108 | } else |
| 1101 | usb_kill_urb (urb); | 1109 | usb_kill_urb(urb); |
| 1102 | 1110 | ||
| 1103 | wait_for_completion (&completion); | 1111 | wait_for_completion(&completion); |
| 1104 | retval = urb->status; | 1112 | retval = urb->status; |
| 1105 | simple_free_urb (urb); | 1113 | simple_free_urb(urb); |
| 1106 | 1114 | ||
| 1107 | if (async) | 1115 | if (async) |
| 1108 | return (retval == -ECONNRESET) ? 0 : retval - 1000; | 1116 | return (retval == -ECONNRESET) ? 0 : retval - 1000; |
| @@ -1111,14 +1119,14 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) | |||
| 1111 | 0 : retval - 2000; | 1119 | 0 : retval - 2000; |
| 1112 | } | 1120 | } |
| 1113 | 1121 | ||
| 1114 | static int unlink_simple (struct usbtest_dev *dev, int pipe, int len) | 1122 | static int unlink_simple(struct usbtest_dev *dev, int pipe, int len) |
| 1115 | { | 1123 | { |
| 1116 | int retval = 0; | 1124 | int retval = 0; |
| 1117 | 1125 | ||
| 1118 | /* test sync and async paths */ | 1126 | /* test sync and async paths */ |
| 1119 | retval = unlink1 (dev, pipe, len, 1); | 1127 | retval = unlink1(dev, pipe, len, 1); |
| 1120 | if (!retval) | 1128 | if (!retval) |
| 1121 | retval = unlink1 (dev, pipe, len, 0); | 1129 | retval = unlink1(dev, pipe, len, 0); |
| 1122 | return retval; | 1130 | return retval; |
| 1123 | } | 1131 | } |
| 1124 | 1132 | ||
| @@ -1130,7 +1138,7 @@ static int verify_not_halted(struct usbtest_dev *tdev, int ep, struct urb *urb) | |||
| 1130 | u16 status; | 1138 | u16 status; |
| 1131 | 1139 | ||
| 1132 | /* shouldn't look or act halted */ | 1140 | /* shouldn't look or act halted */ |
| 1133 | retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status); | 1141 | retval = usb_get_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status); |
| 1134 | if (retval < 0) { | 1142 | if (retval < 0) { |
| 1135 | ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n", | 1143 | ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n", |
| 1136 | ep, retval); | 1144 | ep, retval); |
| @@ -1152,7 +1160,7 @@ static int verify_halted(struct usbtest_dev *tdev, int ep, struct urb *urb) | |||
| 1152 | u16 status; | 1160 | u16 status; |
| 1153 | 1161 | ||
| 1154 | /* should look and act halted */ | 1162 | /* should look and act halted */ |
| 1155 | retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status); | 1163 | retval = usb_get_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status); |
| 1156 | if (retval < 0) { | 1164 | if (retval < 0) { |
| 1157 | ERROR(tdev, "ep %02x couldn't get halt status, %d\n", | 1165 | ERROR(tdev, "ep %02x couldn't get halt status, %d\n", |
| 1158 | ep, retval); | 1166 | ep, retval); |
| @@ -1182,7 +1190,7 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb) | |||
| 1182 | return retval; | 1190 | return retval; |
| 1183 | 1191 | ||
| 1184 | /* set halt (protocol test only), verify it worked */ | 1192 | /* set halt (protocol test only), verify it worked */ |
| 1185 | retval = usb_control_msg (urb->dev, usb_sndctrlpipe (urb->dev, 0), | 1193 | retval = usb_control_msg(urb->dev, usb_sndctrlpipe(urb->dev, 0), |
| 1186 | USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT, | 1194 | USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT, |
| 1187 | USB_ENDPOINT_HALT, ep, | 1195 | USB_ENDPOINT_HALT, ep, |
| 1188 | NULL, 0, USB_CTRL_SET_TIMEOUT); | 1196 | NULL, 0, USB_CTRL_SET_TIMEOUT); |
| @@ -1195,7 +1203,7 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb) | |||
| 1195 | return retval; | 1203 | return retval; |
| 1196 | 1204 | ||
| 1197 | /* clear halt (tests API + protocol), verify it worked */ | 1205 | /* clear halt (tests API + protocol), verify it worked */ |
| 1198 | retval = usb_clear_halt (urb->dev, urb->pipe); | 1206 | retval = usb_clear_halt(urb->dev, urb->pipe); |
| 1199 | if (retval < 0) { | 1207 | if (retval < 0) { |
| 1200 | ERROR(tdev, "ep %02x couldn't clear halt, %d\n", ep, retval); | 1208 | ERROR(tdev, "ep %02x couldn't clear halt, %d\n", ep, retval); |
| 1201 | return retval; | 1209 | return retval; |
| @@ -1209,18 +1217,18 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb) | |||
| 1209 | return 0; | 1217 | return 0; |
| 1210 | } | 1218 | } |
| 1211 | 1219 | ||
| 1212 | static int halt_simple (struct usbtest_dev *dev) | 1220 | static int halt_simple(struct usbtest_dev *dev) |
| 1213 | { | 1221 | { |
| 1214 | int ep; | 1222 | int ep; |
| 1215 | int retval = 0; | 1223 | int retval = 0; |
| 1216 | struct urb *urb; | 1224 | struct urb *urb; |
| 1217 | 1225 | ||
| 1218 | urb = simple_alloc_urb (testdev_to_usbdev (dev), 0, 512); | 1226 | urb = simple_alloc_urb(testdev_to_usbdev(dev), 0, 512); |
| 1219 | if (urb == NULL) | 1227 | if (urb == NULL) |
| 1220 | return -ENOMEM; | 1228 | return -ENOMEM; |
| 1221 | 1229 | ||
| 1222 | if (dev->in_pipe) { | 1230 | if (dev->in_pipe) { |
| 1223 | ep = usb_pipeendpoint (dev->in_pipe) | USB_DIR_IN; | 1231 | ep = usb_pipeendpoint(dev->in_pipe) | USB_DIR_IN; |
| 1224 | urb->pipe = dev->in_pipe; | 1232 | urb->pipe = dev->in_pipe; |
| 1225 | retval = test_halt(dev, ep, urb); | 1233 | retval = test_halt(dev, ep, urb); |
| 1226 | if (retval < 0) | 1234 | if (retval < 0) |
| @@ -1228,12 +1236,12 @@ static int halt_simple (struct usbtest_dev *dev) | |||
| 1228 | } | 1236 | } |
| 1229 | 1237 | ||
| 1230 | if (dev->out_pipe) { | 1238 | if (dev->out_pipe) { |
| 1231 | ep = usb_pipeendpoint (dev->out_pipe); | 1239 | ep = usb_pipeendpoint(dev->out_pipe); |
| 1232 | urb->pipe = dev->out_pipe; | 1240 | urb->pipe = dev->out_pipe; |
| 1233 | retval = test_halt(dev, ep, urb); | 1241 | retval = test_halt(dev, ep, urb); |
| 1234 | } | 1242 | } |
| 1235 | done: | 1243 | done: |
| 1236 | simple_free_urb (urb); | 1244 | simple_free_urb(urb); |
| 1237 | return retval; | 1245 | return retval; |
| 1238 | } | 1246 | } |
| 1239 | 1247 | ||
| @@ -1247,7 +1255,7 @@ done: | |||
| 1247 | * need to be able to handle more than one OUT data packet. We'll | 1255 | * need to be able to handle more than one OUT data packet. We'll |
| 1248 | * try whatever we're told to try. | 1256 | * try whatever we're told to try. |
| 1249 | */ | 1257 | */ |
| 1250 | static int ctrl_out (struct usbtest_dev *dev, | 1258 | static int ctrl_out(struct usbtest_dev *dev, |
| 1251 | unsigned count, unsigned length, unsigned vary) | 1259 | unsigned count, unsigned length, unsigned vary) |
| 1252 | { | 1260 | { |
| 1253 | unsigned i, j, len; | 1261 | unsigned i, j, len; |
| @@ -1263,7 +1271,7 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
| 1263 | if (!buf) | 1271 | if (!buf) |
| 1264 | return -ENOMEM; | 1272 | return -ENOMEM; |
| 1265 | 1273 | ||
| 1266 | udev = testdev_to_usbdev (dev); | 1274 | udev = testdev_to_usbdev(dev); |
| 1267 | len = length; | 1275 | len = length; |
| 1268 | retval = 0; | 1276 | retval = 0; |
| 1269 | 1277 | ||
| @@ -1273,8 +1281,8 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
| 1273 | for (i = 0; i < count; i++) { | 1281 | for (i = 0; i < count; i++) { |
| 1274 | /* write patterned data */ | 1282 | /* write patterned data */ |
| 1275 | for (j = 0; j < len; j++) | 1283 | for (j = 0; j < len; j++) |
| 1276 | buf [j] = i + j; | 1284 | buf[j] = i + j; |
| 1277 | retval = usb_control_msg (udev, usb_sndctrlpipe (udev,0), | 1285 | retval = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
| 1278 | 0x5b, USB_DIR_OUT|USB_TYPE_VENDOR, | 1286 | 0x5b, USB_DIR_OUT|USB_TYPE_VENDOR, |
| 1279 | 0, 0, buf, len, USB_CTRL_SET_TIMEOUT); | 1287 | 0, 0, buf, len, USB_CTRL_SET_TIMEOUT); |
| 1280 | if (retval != len) { | 1288 | if (retval != len) { |
| @@ -1288,7 +1296,7 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
| 1288 | } | 1296 | } |
| 1289 | 1297 | ||
| 1290 | /* read it back -- assuming nothing intervened!! */ | 1298 | /* read it back -- assuming nothing intervened!! */ |
| 1291 | retval = usb_control_msg (udev, usb_rcvctrlpipe (udev,0), | 1299 | retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
| 1292 | 0x5c, USB_DIR_IN|USB_TYPE_VENDOR, | 1300 | 0x5c, USB_DIR_IN|USB_TYPE_VENDOR, |
| 1293 | 0, 0, buf, len, USB_CTRL_GET_TIMEOUT); | 1301 | 0, 0, buf, len, USB_CTRL_GET_TIMEOUT); |
| 1294 | if (retval != len) { | 1302 | if (retval != len) { |
| @@ -1303,9 +1311,9 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
| 1303 | 1311 | ||
| 1304 | /* fail if we can't verify */ | 1312 | /* fail if we can't verify */ |
| 1305 | for (j = 0; j < len; j++) { | 1313 | for (j = 0; j < len; j++) { |
| 1306 | if (buf [j] != (u8) (i + j)) { | 1314 | if (buf[j] != (u8) (i + j)) { |
| 1307 | ERROR(dev, "ctrl_out, byte %d is %d not %d\n", | 1315 | ERROR(dev, "ctrl_out, byte %d is %d not %d\n", |
| 1308 | j, buf [j], (u8) i + j); | 1316 | j, buf[j], (u8) i + j); |
| 1309 | retval = -EBADMSG; | 1317 | retval = -EBADMSG; |
| 1310 | break; | 1318 | break; |
| 1311 | } | 1319 | } |
| @@ -1326,10 +1334,10 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
| 1326 | } | 1334 | } |
| 1327 | 1335 | ||
| 1328 | if (retval < 0) | 1336 | if (retval < 0) |
| 1329 | ERROR (dev, "ctrl_out %s failed, code %d, count %d\n", | 1337 | ERROR(dev, "ctrl_out %s failed, code %d, count %d\n", |
| 1330 | what, retval, i); | 1338 | what, retval, i); |
| 1331 | 1339 | ||
| 1332 | kfree (buf); | 1340 | kfree(buf); |
| 1333 | return retval; | 1341 | return retval; |
| 1334 | } | 1342 | } |
| 1335 | 1343 | ||
| @@ -1351,7 +1359,7 @@ struct iso_context { | |||
| 1351 | struct usbtest_dev *dev; | 1359 | struct usbtest_dev *dev; |
| 1352 | }; | 1360 | }; |
| 1353 | 1361 | ||
| 1354 | static void iso_callback (struct urb *urb) | 1362 | static void iso_callback(struct urb *urb) |
| 1355 | { | 1363 | { |
| 1356 | struct iso_context *ctx = urb->context; | 1364 | struct iso_context *ctx = urb->context; |
| 1357 | 1365 | ||
| @@ -1363,10 +1371,12 @@ static void iso_callback (struct urb *urb) | |||
| 1363 | ctx->errors += urb->error_count; | 1371 | ctx->errors += urb->error_count; |
| 1364 | else if (urb->status != 0) | 1372 | else if (urb->status != 0) |
| 1365 | ctx->errors += urb->number_of_packets; | 1373 | ctx->errors += urb->number_of_packets; |
| 1374 | else if (urb->actual_length != urb->transfer_buffer_length) | ||
| 1375 | ctx->errors++; | ||
| 1366 | 1376 | ||
| 1367 | if (urb->status == 0 && ctx->count > (ctx->pending - 1) | 1377 | if (urb->status == 0 && ctx->count > (ctx->pending - 1) |
| 1368 | && !ctx->submit_error) { | 1378 | && !ctx->submit_error) { |
| 1369 | int status = usb_submit_urb (urb, GFP_ATOMIC); | 1379 | int status = usb_submit_urb(urb, GFP_ATOMIC); |
| 1370 | switch (status) { | 1380 | switch (status) { |
| 1371 | case 0: | 1381 | case 0: |
| 1372 | goto done; | 1382 | goto done; |
| @@ -1388,13 +1398,13 @@ static void iso_callback (struct urb *urb) | |||
| 1388 | dev_err(&ctx->dev->intf->dev, | 1398 | dev_err(&ctx->dev->intf->dev, |
| 1389 | "iso test, %lu errors out of %lu\n", | 1399 | "iso test, %lu errors out of %lu\n", |
| 1390 | ctx->errors, ctx->packet_count); | 1400 | ctx->errors, ctx->packet_count); |
| 1391 | complete (&ctx->done); | 1401 | complete(&ctx->done); |
| 1392 | } | 1402 | } |
| 1393 | done: | 1403 | done: |
| 1394 | spin_unlock(&ctx->lock); | 1404 | spin_unlock(&ctx->lock); |
| 1395 | } | 1405 | } |
| 1396 | 1406 | ||
| 1397 | static struct urb *iso_alloc_urb ( | 1407 | static struct urb *iso_alloc_urb( |
| 1398 | struct usb_device *udev, | 1408 | struct usb_device *udev, |
| 1399 | int pipe, | 1409 | int pipe, |
| 1400 | struct usb_endpoint_descriptor *desc, | 1410 | struct usb_endpoint_descriptor *desc, |
| @@ -1410,7 +1420,7 @@ static struct urb *iso_alloc_urb ( | |||
| 1410 | maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); | 1420 | maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); |
| 1411 | packets = DIV_ROUND_UP(bytes, maxp); | 1421 | packets = DIV_ROUND_UP(bytes, maxp); |
| 1412 | 1422 | ||
| 1413 | urb = usb_alloc_urb (packets, GFP_KERNEL); | 1423 | urb = usb_alloc_urb(packets, GFP_KERNEL); |
| 1414 | if (!urb) | 1424 | if (!urb) |
| 1415 | return urb; | 1425 | return urb; |
| 1416 | urb->dev = udev; | 1426 | urb->dev = udev; |
| @@ -1418,30 +1428,30 @@ static struct urb *iso_alloc_urb ( | |||
| 1418 | 1428 | ||
| 1419 | urb->number_of_packets = packets; | 1429 | urb->number_of_packets = packets; |
| 1420 | urb->transfer_buffer_length = bytes; | 1430 | urb->transfer_buffer_length = bytes; |
| 1421 | urb->transfer_buffer = usb_alloc_coherent (udev, bytes, GFP_KERNEL, | 1431 | urb->transfer_buffer = usb_alloc_coherent(udev, bytes, GFP_KERNEL, |
| 1422 | &urb->transfer_dma); | 1432 | &urb->transfer_dma); |
| 1423 | if (!urb->transfer_buffer) { | 1433 | if (!urb->transfer_buffer) { |
| 1424 | usb_free_urb (urb); | 1434 | usb_free_urb(urb); |
| 1425 | return NULL; | 1435 | return NULL; |
| 1426 | } | 1436 | } |
| 1427 | memset (urb->transfer_buffer, 0, bytes); | 1437 | memset(urb->transfer_buffer, 0, bytes); |
| 1428 | for (i = 0; i < packets; i++) { | 1438 | for (i = 0; i < packets; i++) { |
| 1429 | /* here, only the last packet will be short */ | 1439 | /* here, only the last packet will be short */ |
| 1430 | urb->iso_frame_desc[i].length = min ((unsigned) bytes, maxp); | 1440 | urb->iso_frame_desc[i].length = min((unsigned) bytes, maxp); |
| 1431 | bytes -= urb->iso_frame_desc[i].length; | 1441 | bytes -= urb->iso_frame_desc[i].length; |
| 1432 | 1442 | ||
| 1433 | urb->iso_frame_desc[i].offset = maxp * i; | 1443 | urb->iso_frame_desc[i].offset = maxp * i; |
| 1434 | } | 1444 | } |
| 1435 | 1445 | ||
| 1436 | urb->complete = iso_callback; | 1446 | urb->complete = iso_callback; |
| 1437 | // urb->context = SET BY CALLER | 1447 | /* urb->context = SET BY CALLER */ |
| 1438 | urb->interval = 1 << (desc->bInterval - 1); | 1448 | urb->interval = 1 << (desc->bInterval - 1); |
| 1439 | urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; | 1449 | urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; |
| 1440 | return urb; | 1450 | return urb; |
| 1441 | } | 1451 | } |
| 1442 | 1452 | ||
| 1443 | static int | 1453 | static int |
| 1444 | test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | 1454 | test_iso_queue(struct usbtest_dev *dev, struct usbtest_param *param, |
| 1445 | int pipe, struct usb_endpoint_descriptor *desc) | 1455 | int pipe, struct usb_endpoint_descriptor *desc) |
| 1446 | { | 1456 | { |
| 1447 | struct iso_context context; | 1457 | struct iso_context context; |
| @@ -1457,11 +1467,11 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
| 1457 | memset(&context, 0, sizeof context); | 1467 | memset(&context, 0, sizeof context); |
| 1458 | context.count = param->iterations * param->sglen; | 1468 | context.count = param->iterations * param->sglen; |
| 1459 | context.dev = dev; | 1469 | context.dev = dev; |
| 1460 | init_completion (&context.done); | 1470 | init_completion(&context.done); |
| 1461 | spin_lock_init (&context.lock); | 1471 | spin_lock_init(&context.lock); |
| 1462 | 1472 | ||
| 1463 | memset (urbs, 0, sizeof urbs); | 1473 | memset(urbs, 0, sizeof urbs); |
| 1464 | udev = testdev_to_usbdev (dev); | 1474 | udev = testdev_to_usbdev(dev); |
| 1465 | dev_info(&dev->intf->dev, | 1475 | dev_info(&dev->intf->dev, |
| 1466 | "... iso period %d %sframes, wMaxPacket %04x\n", | 1476 | "... iso period %d %sframes, wMaxPacket %04x\n", |
| 1467 | 1 << (desc->bInterval - 1), | 1477 | 1 << (desc->bInterval - 1), |
| @@ -1469,14 +1479,14 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
| 1469 | le16_to_cpu(desc->wMaxPacketSize)); | 1479 | le16_to_cpu(desc->wMaxPacketSize)); |
| 1470 | 1480 | ||
| 1471 | for (i = 0; i < param->sglen; i++) { | 1481 | for (i = 0; i < param->sglen; i++) { |
| 1472 | urbs [i] = iso_alloc_urb (udev, pipe, desc, | 1482 | urbs[i] = iso_alloc_urb(udev, pipe, desc, |
| 1473 | param->length); | 1483 | param->length); |
| 1474 | if (!urbs [i]) { | 1484 | if (!urbs[i]) { |
| 1475 | status = -ENOMEM; | 1485 | status = -ENOMEM; |
| 1476 | goto fail; | 1486 | goto fail; |
| 1477 | } | 1487 | } |
| 1478 | packets += urbs[i]->number_of_packets; | 1488 | packets += urbs[i]->number_of_packets; |
| 1479 | urbs [i]->context = &context; | 1489 | urbs[i]->context = &context; |
| 1480 | } | 1490 | } |
| 1481 | packets *= param->iterations; | 1491 | packets *= param->iterations; |
| 1482 | dev_info(&dev->intf->dev, | 1492 | dev_info(&dev->intf->dev, |
| @@ -1485,27 +1495,27 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
| 1485 | / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1), | 1495 | / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1), |
| 1486 | packets); | 1496 | packets); |
| 1487 | 1497 | ||
| 1488 | spin_lock_irq (&context.lock); | 1498 | spin_lock_irq(&context.lock); |
| 1489 | for (i = 0; i < param->sglen; i++) { | 1499 | for (i = 0; i < param->sglen; i++) { |
| 1490 | ++context.pending; | 1500 | ++context.pending; |
| 1491 | status = usb_submit_urb (urbs [i], GFP_ATOMIC); | 1501 | status = usb_submit_urb(urbs[i], GFP_ATOMIC); |
| 1492 | if (status < 0) { | 1502 | if (status < 0) { |
| 1493 | ERROR (dev, "submit iso[%d], error %d\n", i, status); | 1503 | ERROR(dev, "submit iso[%d], error %d\n", i, status); |
| 1494 | if (i == 0) { | 1504 | if (i == 0) { |
| 1495 | spin_unlock_irq (&context.lock); | 1505 | spin_unlock_irq(&context.lock); |
| 1496 | goto fail; | 1506 | goto fail; |
| 1497 | } | 1507 | } |
| 1498 | 1508 | ||
| 1499 | simple_free_urb (urbs [i]); | 1509 | simple_free_urb(urbs[i]); |
| 1500 | urbs[i] = NULL; | 1510 | urbs[i] = NULL; |
| 1501 | context.pending--; | 1511 | context.pending--; |
| 1502 | context.submit_error = 1; | 1512 | context.submit_error = 1; |
| 1503 | break; | 1513 | break; |
| 1504 | } | 1514 | } |
| 1505 | } | 1515 | } |
| 1506 | spin_unlock_irq (&context.lock); | 1516 | spin_unlock_irq(&context.lock); |
| 1507 | 1517 | ||
| 1508 | wait_for_completion (&context.done); | 1518 | wait_for_completion(&context.done); |
| 1509 | 1519 | ||
| 1510 | for (i = 0; i < param->sglen; i++) { | 1520 | for (i = 0; i < param->sglen; i++) { |
| 1511 | if (urbs[i]) | 1521 | if (urbs[i]) |
| @@ -1526,8 +1536,8 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
| 1526 | 1536 | ||
| 1527 | fail: | 1537 | fail: |
| 1528 | for (i = 0; i < param->sglen; i++) { | 1538 | for (i = 0; i < param->sglen; i++) { |
| 1529 | if (urbs [i]) | 1539 | if (urbs[i]) |
| 1530 | simple_free_urb (urbs [i]); | 1540 | simple_free_urb(urbs[i]); |
| 1531 | } | 1541 | } |
| 1532 | return status; | 1542 | return status; |
| 1533 | } | 1543 | } |
| @@ -1557,10 +1567,10 @@ fail: | |||
| 1557 | 1567 | ||
| 1558 | /* No BKL needed */ | 1568 | /* No BKL needed */ |
| 1559 | static int | 1569 | static int |
| 1560 | usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | 1570 | usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf) |
| 1561 | { | 1571 | { |
| 1562 | struct usbtest_dev *dev = usb_get_intfdata (intf); | 1572 | struct usbtest_dev *dev = usb_get_intfdata(intf); |
| 1563 | struct usb_device *udev = testdev_to_usbdev (dev); | 1573 | struct usb_device *udev = testdev_to_usbdev(dev); |
| 1564 | struct usbtest_param *param = buf; | 1574 | struct usbtest_param *param = buf; |
| 1565 | int retval = -EOPNOTSUPP; | 1575 | int retval = -EOPNOTSUPP; |
| 1566 | struct urb *urb; | 1576 | struct urb *urb; |
| @@ -1569,7 +1579,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1569 | struct timeval start; | 1579 | struct timeval start; |
| 1570 | unsigned i; | 1580 | unsigned i; |
| 1571 | 1581 | ||
| 1572 | // FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. | 1582 | /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */ |
| 1573 | 1583 | ||
| 1574 | pattern = mod_pattern; | 1584 | pattern = mod_pattern; |
| 1575 | 1585 | ||
| @@ -1595,9 +1605,9 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1595 | mutex_unlock(&dev->lock); | 1605 | mutex_unlock(&dev->lock); |
| 1596 | return -ENODEV; | 1606 | return -ENODEV; |
| 1597 | } | 1607 | } |
| 1598 | res = set_altsetting (dev, dev->info->alt); | 1608 | res = set_altsetting(dev, dev->info->alt); |
| 1599 | if (res) { | 1609 | if (res) { |
| 1600 | dev_err (&intf->dev, | 1610 | dev_err(&intf->dev, |
| 1601 | "set altsetting to %d failed, %d\n", | 1611 | "set altsetting to %d failed, %d\n", |
| 1602 | dev->info->alt, res); | 1612 | dev->info->alt, res); |
| 1603 | mutex_unlock(&dev->lock); | 1613 | mutex_unlock(&dev->lock); |
| @@ -1614,7 +1624,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1614 | * FIXME add more tests! cancel requests, verify the data, control | 1624 | * FIXME add more tests! cancel requests, verify the data, control |
| 1615 | * queueing, concurrent read+write threads, and so on. | 1625 | * queueing, concurrent read+write threads, and so on. |
| 1616 | */ | 1626 | */ |
| 1617 | do_gettimeofday (&start); | 1627 | do_gettimeofday(&start); |
| 1618 | switch (param->test_num) { | 1628 | switch (param->test_num) { |
| 1619 | 1629 | ||
| 1620 | case 0: | 1630 | case 0: |
| @@ -1629,14 +1639,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1629 | dev_info(&intf->dev, | 1639 | dev_info(&intf->dev, |
| 1630 | "TEST 1: write %d bytes %u times\n", | 1640 | "TEST 1: write %d bytes %u times\n", |
| 1631 | param->length, param->iterations); | 1641 | param->length, param->iterations); |
| 1632 | urb = simple_alloc_urb (udev, dev->out_pipe, param->length); | 1642 | urb = simple_alloc_urb(udev, dev->out_pipe, param->length); |
| 1633 | if (!urb) { | 1643 | if (!urb) { |
| 1634 | retval = -ENOMEM; | 1644 | retval = -ENOMEM; |
| 1635 | break; | 1645 | break; |
| 1636 | } | 1646 | } |
| 1637 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1647 | /* FIRMWARE: bulk sink (maybe accepts short writes) */ |
| 1638 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test1"); | 1648 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test1"); |
| 1639 | simple_free_urb (urb); | 1649 | simple_free_urb(urb); |
| 1640 | break; | 1650 | break; |
| 1641 | case 2: | 1651 | case 2: |
| 1642 | if (dev->in_pipe == 0) | 1652 | if (dev->in_pipe == 0) |
| @@ -1644,14 +1654,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1644 | dev_info(&intf->dev, | 1654 | dev_info(&intf->dev, |
| 1645 | "TEST 2: read %d bytes %u times\n", | 1655 | "TEST 2: read %d bytes %u times\n", |
| 1646 | param->length, param->iterations); | 1656 | param->length, param->iterations); |
| 1647 | urb = simple_alloc_urb (udev, dev->in_pipe, param->length); | 1657 | urb = simple_alloc_urb(udev, dev->in_pipe, param->length); |
| 1648 | if (!urb) { | 1658 | if (!urb) { |
| 1649 | retval = -ENOMEM; | 1659 | retval = -ENOMEM; |
| 1650 | break; | 1660 | break; |
| 1651 | } | 1661 | } |
| 1652 | // FIRMWARE: bulk source (maybe generates short writes) | 1662 | /* FIRMWARE: bulk source (maybe generates short writes) */ |
| 1653 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test2"); | 1663 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test2"); |
| 1654 | simple_free_urb (urb); | 1664 | simple_free_urb(urb); |
| 1655 | break; | 1665 | break; |
| 1656 | case 3: | 1666 | case 3: |
| 1657 | if (dev->out_pipe == 0 || param->vary == 0) | 1667 | if (dev->out_pipe == 0 || param->vary == 0) |
| @@ -1659,15 +1669,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1659 | dev_info(&intf->dev, | 1669 | dev_info(&intf->dev, |
| 1660 | "TEST 3: write/%d 0..%d bytes %u times\n", | 1670 | "TEST 3: write/%d 0..%d bytes %u times\n", |
| 1661 | param->vary, param->length, param->iterations); | 1671 | param->vary, param->length, param->iterations); |
| 1662 | urb = simple_alloc_urb (udev, dev->out_pipe, param->length); | 1672 | urb = simple_alloc_urb(udev, dev->out_pipe, param->length); |
| 1663 | if (!urb) { | 1673 | if (!urb) { |
| 1664 | retval = -ENOMEM; | 1674 | retval = -ENOMEM; |
| 1665 | break; | 1675 | break; |
| 1666 | } | 1676 | } |
| 1667 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1677 | /* FIRMWARE: bulk sink (maybe accepts short writes) */ |
| 1668 | retval = simple_io(dev, urb, param->iterations, param->vary, | 1678 | retval = simple_io(dev, urb, param->iterations, param->vary, |
| 1669 | 0, "test3"); | 1679 | 0, "test3"); |
| 1670 | simple_free_urb (urb); | 1680 | simple_free_urb(urb); |
| 1671 | break; | 1681 | break; |
| 1672 | case 4: | 1682 | case 4: |
| 1673 | if (dev->in_pipe == 0 || param->vary == 0) | 1683 | if (dev->in_pipe == 0 || param->vary == 0) |
| @@ -1675,15 +1685,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1675 | dev_info(&intf->dev, | 1685 | dev_info(&intf->dev, |
| 1676 | "TEST 4: read/%d 0..%d bytes %u times\n", | 1686 | "TEST 4: read/%d 0..%d bytes %u times\n", |
| 1677 | param->vary, param->length, param->iterations); | 1687 | param->vary, param->length, param->iterations); |
| 1678 | urb = simple_alloc_urb (udev, dev->in_pipe, param->length); | 1688 | urb = simple_alloc_urb(udev, dev->in_pipe, param->length); |
| 1679 | if (!urb) { | 1689 | if (!urb) { |
| 1680 | retval = -ENOMEM; | 1690 | retval = -ENOMEM; |
| 1681 | break; | 1691 | break; |
| 1682 | } | 1692 | } |
| 1683 | // FIRMWARE: bulk source (maybe generates short writes) | 1693 | /* FIRMWARE: bulk source (maybe generates short writes) */ |
| 1684 | retval = simple_io(dev, urb, param->iterations, param->vary, | 1694 | retval = simple_io(dev, urb, param->iterations, param->vary, |
| 1685 | 0, "test4"); | 1695 | 0, "test4"); |
| 1686 | simple_free_urb (urb); | 1696 | simple_free_urb(urb); |
| 1687 | break; | 1697 | break; |
| 1688 | 1698 | ||
| 1689 | /* Queued bulk I/O tests */ | 1699 | /* Queued bulk I/O tests */ |
| @@ -1694,15 +1704,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1694 | "TEST 5: write %d sglists %d entries of %d bytes\n", | 1704 | "TEST 5: write %d sglists %d entries of %d bytes\n", |
| 1695 | param->iterations, | 1705 | param->iterations, |
| 1696 | param->sglen, param->length); | 1706 | param->sglen, param->length); |
| 1697 | sg = alloc_sglist (param->sglen, param->length, 0); | 1707 | sg = alloc_sglist(param->sglen, param->length, 0); |
| 1698 | if (!sg) { | 1708 | if (!sg) { |
| 1699 | retval = -ENOMEM; | 1709 | retval = -ENOMEM; |
| 1700 | break; | 1710 | break; |
| 1701 | } | 1711 | } |
| 1702 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1712 | /* FIRMWARE: bulk sink (maybe accepts short writes) */ |
| 1703 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, | 1713 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, |
| 1704 | &req, sg, param->sglen); | 1714 | &req, sg, param->sglen); |
| 1705 | free_sglist (sg, param->sglen); | 1715 | free_sglist(sg, param->sglen); |
| 1706 | break; | 1716 | break; |
| 1707 | 1717 | ||
| 1708 | case 6: | 1718 | case 6: |
| @@ -1712,15 +1722,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1712 | "TEST 6: read %d sglists %d entries of %d bytes\n", | 1722 | "TEST 6: read %d sglists %d entries of %d bytes\n", |
| 1713 | param->iterations, | 1723 | param->iterations, |
| 1714 | param->sglen, param->length); | 1724 | param->sglen, param->length); |
| 1715 | sg = alloc_sglist (param->sglen, param->length, 0); | 1725 | sg = alloc_sglist(param->sglen, param->length, 0); |
| 1716 | if (!sg) { | 1726 | if (!sg) { |
| 1717 | retval = -ENOMEM; | 1727 | retval = -ENOMEM; |
| 1718 | break; | 1728 | break; |
| 1719 | } | 1729 | } |
| 1720 | // FIRMWARE: bulk source (maybe generates short writes) | 1730 | /* FIRMWARE: bulk source (maybe generates short writes) */ |
| 1721 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, | 1731 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, |
| 1722 | &req, sg, param->sglen); | 1732 | &req, sg, param->sglen); |
| 1723 | free_sglist (sg, param->sglen); | 1733 | free_sglist(sg, param->sglen); |
| 1724 | break; | 1734 | break; |
| 1725 | case 7: | 1735 | case 7: |
| 1726 | if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0) | 1736 | if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0) |
| @@ -1729,15 +1739,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1729 | "TEST 7: write/%d %d sglists %d entries 0..%d bytes\n", | 1739 | "TEST 7: write/%d %d sglists %d entries 0..%d bytes\n", |
| 1730 | param->vary, param->iterations, | 1740 | param->vary, param->iterations, |
| 1731 | param->sglen, param->length); | 1741 | param->sglen, param->length); |
| 1732 | sg = alloc_sglist (param->sglen, param->length, param->vary); | 1742 | sg = alloc_sglist(param->sglen, param->length, param->vary); |
| 1733 | if (!sg) { | 1743 | if (!sg) { |
| 1734 | retval = -ENOMEM; | 1744 | retval = -ENOMEM; |
| 1735 | break; | 1745 | break; |
| 1736 | } | 1746 | } |
| 1737 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1747 | /* FIRMWARE: bulk sink (maybe accepts short writes) */ |
| 1738 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, | 1748 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, |
| 1739 | &req, sg, param->sglen); | 1749 | &req, sg, param->sglen); |
| 1740 | free_sglist (sg, param->sglen); | 1750 | free_sglist(sg, param->sglen); |
| 1741 | break; | 1751 | break; |
| 1742 | case 8: | 1752 | case 8: |
| 1743 | if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0) | 1753 | if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0) |
| @@ -1746,15 +1756,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1746 | "TEST 8: read/%d %d sglists %d entries 0..%d bytes\n", | 1756 | "TEST 8: read/%d %d sglists %d entries 0..%d bytes\n", |
| 1747 | param->vary, param->iterations, | 1757 | param->vary, param->iterations, |
| 1748 | param->sglen, param->length); | 1758 | param->sglen, param->length); |
| 1749 | sg = alloc_sglist (param->sglen, param->length, param->vary); | 1759 | sg = alloc_sglist(param->sglen, param->length, param->vary); |
| 1750 | if (!sg) { | 1760 | if (!sg) { |
| 1751 | retval = -ENOMEM; | 1761 | retval = -ENOMEM; |
| 1752 | break; | 1762 | break; |
| 1753 | } | 1763 | } |
| 1754 | // FIRMWARE: bulk source (maybe generates short writes) | 1764 | /* FIRMWARE: bulk source (maybe generates short writes) */ |
| 1755 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, | 1765 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, |
| 1756 | &req, sg, param->sglen); | 1766 | &req, sg, param->sglen); |
| 1757 | free_sglist (sg, param->sglen); | 1767 | free_sglist(sg, param->sglen); |
| 1758 | break; | 1768 | break; |
| 1759 | 1769 | ||
| 1760 | /* non-queued sanity tests for control (chapter 9 subset) */ | 1770 | /* non-queued sanity tests for control (chapter 9 subset) */ |
| @@ -1764,7 +1774,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1764 | "TEST 9: ch9 (subset) control tests, %d times\n", | 1774 | "TEST 9: ch9 (subset) control tests, %d times\n", |
| 1765 | param->iterations); | 1775 | param->iterations); |
| 1766 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1776 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
| 1767 | retval = ch9_postconfig (dev); | 1777 | retval = ch9_postconfig(dev); |
| 1768 | if (retval) | 1778 | if (retval) |
| 1769 | dev_err(&intf->dev, "ch9 subset failed, " | 1779 | dev_err(&intf->dev, "ch9 subset failed, " |
| 1770 | "iterations left %d\n", i); | 1780 | "iterations left %d\n", i); |
| @@ -1779,7 +1789,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1779 | "TEST 10: queue %d control calls, %d times\n", | 1789 | "TEST 10: queue %d control calls, %d times\n", |
| 1780 | param->sglen, | 1790 | param->sglen, |
| 1781 | param->iterations); | 1791 | param->iterations); |
| 1782 | retval = test_ctrl_queue (dev, param); | 1792 | retval = test_ctrl_queue(dev, param); |
| 1783 | break; | 1793 | break; |
| 1784 | 1794 | ||
| 1785 | /* simple non-queued unlinks (ring with one urb) */ | 1795 | /* simple non-queued unlinks (ring with one urb) */ |
| @@ -1790,7 +1800,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1790 | dev_info(&intf->dev, "TEST 11: unlink %d reads of %d\n", | 1800 | dev_info(&intf->dev, "TEST 11: unlink %d reads of %d\n", |
| 1791 | param->iterations, param->length); | 1801 | param->iterations, param->length); |
| 1792 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1802 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
| 1793 | retval = unlink_simple (dev, dev->in_pipe, | 1803 | retval = unlink_simple(dev, dev->in_pipe, |
| 1794 | param->length); | 1804 | param->length); |
| 1795 | if (retval) | 1805 | if (retval) |
| 1796 | dev_err(&intf->dev, "unlink reads failed %d, " | 1806 | dev_err(&intf->dev, "unlink reads failed %d, " |
| @@ -1803,7 +1813,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1803 | dev_info(&intf->dev, "TEST 12: unlink %d writes of %d\n", | 1813 | dev_info(&intf->dev, "TEST 12: unlink %d writes of %d\n", |
| 1804 | param->iterations, param->length); | 1814 | param->iterations, param->length); |
| 1805 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1815 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
| 1806 | retval = unlink_simple (dev, dev->out_pipe, | 1816 | retval = unlink_simple(dev, dev->out_pipe, |
| 1807 | param->length); | 1817 | param->length); |
| 1808 | if (retval) | 1818 | if (retval) |
| 1809 | dev_err(&intf->dev, "unlink writes failed %d, " | 1819 | dev_err(&intf->dev, "unlink writes failed %d, " |
| @@ -1818,7 +1828,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1818 | dev_info(&intf->dev, "TEST 13: set/clear %d halts\n", | 1828 | dev_info(&intf->dev, "TEST 13: set/clear %d halts\n", |
| 1819 | param->iterations); | 1829 | param->iterations); |
| 1820 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1830 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
| 1821 | retval = halt_simple (dev); | 1831 | retval = halt_simple(dev); |
| 1822 | 1832 | ||
| 1823 | if (retval) | 1833 | if (retval) |
| 1824 | ERROR(dev, "halts failed, iterations left %d\n", i); | 1834 | ERROR(dev, "halts failed, iterations left %d\n", i); |
| @@ -1844,8 +1854,8 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1844 | "TEST 15: write %d iso, %d entries of %d bytes\n", | 1854 | "TEST 15: write %d iso, %d entries of %d bytes\n", |
| 1845 | param->iterations, | 1855 | param->iterations, |
| 1846 | param->sglen, param->length); | 1856 | param->sglen, param->length); |
| 1847 | // FIRMWARE: iso sink | 1857 | /* FIRMWARE: iso sink */ |
| 1848 | retval = test_iso_queue (dev, param, | 1858 | retval = test_iso_queue(dev, param, |
| 1849 | dev->out_iso_pipe, dev->iso_out); | 1859 | dev->out_iso_pipe, dev->iso_out); |
| 1850 | break; | 1860 | break; |
| 1851 | 1861 | ||
| @@ -1857,17 +1867,17 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1857 | "TEST 16: read %d iso, %d entries of %d bytes\n", | 1867 | "TEST 16: read %d iso, %d entries of %d bytes\n", |
| 1858 | param->iterations, | 1868 | param->iterations, |
| 1859 | param->sglen, param->length); | 1869 | param->sglen, param->length); |
| 1860 | // FIRMWARE: iso source | 1870 | /* FIRMWARE: iso source */ |
| 1861 | retval = test_iso_queue (dev, param, | 1871 | retval = test_iso_queue(dev, param, |
| 1862 | dev->in_iso_pipe, dev->iso_in); | 1872 | dev->in_iso_pipe, dev->iso_in); |
| 1863 | break; | 1873 | break; |
| 1864 | 1874 | ||
| 1865 | // FIXME unlink from queue (ring with N urbs) | 1875 | /* FIXME unlink from queue (ring with N urbs) */ |
| 1866 | 1876 | ||
| 1867 | // FIXME scatterlist cancel (needs helper thread) | 1877 | /* FIXME scatterlist cancel (needs helper thread) */ |
| 1868 | 1878 | ||
| 1869 | } | 1879 | } |
| 1870 | do_gettimeofday (¶m->duration); | 1880 | do_gettimeofday(¶m->duration); |
| 1871 | param->duration.tv_sec -= start.tv_sec; | 1881 | param->duration.tv_sec -= start.tv_sec; |
| 1872 | param->duration.tv_usec -= start.tv_usec; | 1882 | param->duration.tv_usec -= start.tv_usec; |
| 1873 | if (param->duration.tv_usec < 0) { | 1883 | if (param->duration.tv_usec < 0) { |
| @@ -1880,22 +1890,22 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
| 1880 | 1890 | ||
| 1881 | /*-------------------------------------------------------------------------*/ | 1891 | /*-------------------------------------------------------------------------*/ |
| 1882 | 1892 | ||
| 1883 | static unsigned force_interrupt = 0; | 1893 | static unsigned force_interrupt; |
| 1884 | module_param (force_interrupt, uint, 0); | 1894 | module_param(force_interrupt, uint, 0); |
| 1885 | MODULE_PARM_DESC (force_interrupt, "0 = test default; else interrupt"); | 1895 | MODULE_PARM_DESC(force_interrupt, "0 = test default; else interrupt"); |
| 1886 | 1896 | ||
| 1887 | #ifdef GENERIC | 1897 | #ifdef GENERIC |
| 1888 | static unsigned short vendor; | 1898 | static unsigned short vendor; |
| 1889 | module_param(vendor, ushort, 0); | 1899 | module_param(vendor, ushort, 0); |
| 1890 | MODULE_PARM_DESC (vendor, "vendor code (from usb-if)"); | 1900 | MODULE_PARM_DESC(vendor, "vendor code (from usb-if)"); |
| 1891 | 1901 | ||
| 1892 | static unsigned short product; | 1902 | static unsigned short product; |
| 1893 | module_param(product, ushort, 0); | 1903 | module_param(product, ushort, 0); |
| 1894 | MODULE_PARM_DESC (product, "product code (from vendor)"); | 1904 | MODULE_PARM_DESC(product, "product code (from vendor)"); |
| 1895 | #endif | 1905 | #endif |
| 1896 | 1906 | ||
| 1897 | static int | 1907 | static int |
| 1898 | usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | 1908 | usbtest_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 1899 | { | 1909 | { |
| 1900 | struct usb_device *udev; | 1910 | struct usb_device *udev; |
| 1901 | struct usbtest_dev *dev; | 1911 | struct usbtest_dev *dev; |
| @@ -1903,7 +1913,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1903 | char *rtest, *wtest; | 1913 | char *rtest, *wtest; |
| 1904 | char *irtest, *iwtest; | 1914 | char *irtest, *iwtest; |
| 1905 | 1915 | ||
| 1906 | udev = interface_to_usbdev (intf); | 1916 | udev = interface_to_usbdev(intf); |
| 1907 | 1917 | ||
| 1908 | #ifdef GENERIC | 1918 | #ifdef GENERIC |
| 1909 | /* specify devices by module parameters? */ | 1919 | /* specify devices by module parameters? */ |
| @@ -1930,8 +1940,9 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1930 | dev->intf = intf; | 1940 | dev->intf = intf; |
| 1931 | 1941 | ||
| 1932 | /* cacheline-aligned scratch for i/o */ | 1942 | /* cacheline-aligned scratch for i/o */ |
| 1933 | if ((dev->buf = kmalloc (TBUF_SIZE, GFP_KERNEL)) == NULL) { | 1943 | dev->buf = kmalloc(TBUF_SIZE, GFP_KERNEL); |
| 1934 | kfree (dev); | 1944 | if (dev->buf == NULL) { |
| 1945 | kfree(dev); | ||
| 1935 | return -ENOMEM; | 1946 | return -ENOMEM; |
| 1936 | } | 1947 | } |
| 1937 | 1948 | ||
| @@ -1943,18 +1954,18 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1943 | irtest = iwtest = ""; | 1954 | irtest = iwtest = ""; |
| 1944 | if (force_interrupt || udev->speed == USB_SPEED_LOW) { | 1955 | if (force_interrupt || udev->speed == USB_SPEED_LOW) { |
| 1945 | if (info->ep_in) { | 1956 | if (info->ep_in) { |
| 1946 | dev->in_pipe = usb_rcvintpipe (udev, info->ep_in); | 1957 | dev->in_pipe = usb_rcvintpipe(udev, info->ep_in); |
| 1947 | rtest = " intr-in"; | 1958 | rtest = " intr-in"; |
| 1948 | } | 1959 | } |
| 1949 | if (info->ep_out) { | 1960 | if (info->ep_out) { |
| 1950 | dev->out_pipe = usb_sndintpipe (udev, info->ep_out); | 1961 | dev->out_pipe = usb_sndintpipe(udev, info->ep_out); |
| 1951 | wtest = " intr-out"; | 1962 | wtest = " intr-out"; |
| 1952 | } | 1963 | } |
| 1953 | } else { | 1964 | } else { |
| 1954 | if (info->autoconf) { | 1965 | if (info->autoconf) { |
| 1955 | int status; | 1966 | int status; |
| 1956 | 1967 | ||
| 1957 | status = get_endpoints (dev, intf); | 1968 | status = get_endpoints(dev, intf); |
| 1958 | if (status < 0) { | 1969 | if (status < 0) { |
| 1959 | WARNING(dev, "couldn't get endpoints, %d\n", | 1970 | WARNING(dev, "couldn't get endpoints, %d\n", |
| 1960 | status); | 1971 | status); |
| @@ -1963,10 +1974,10 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1963 | /* may find bulk or ISO pipes */ | 1974 | /* may find bulk or ISO pipes */ |
| 1964 | } else { | 1975 | } else { |
| 1965 | if (info->ep_in) | 1976 | if (info->ep_in) |
| 1966 | dev->in_pipe = usb_rcvbulkpipe (udev, | 1977 | dev->in_pipe = usb_rcvbulkpipe(udev, |
| 1967 | info->ep_in); | 1978 | info->ep_in); |
| 1968 | if (info->ep_out) | 1979 | if (info->ep_out) |
| 1969 | dev->out_pipe = usb_sndbulkpipe (udev, | 1980 | dev->out_pipe = usb_sndbulkpipe(udev, |
| 1970 | info->ep_out); | 1981 | info->ep_out); |
| 1971 | } | 1982 | } |
| 1972 | if (dev->in_pipe) | 1983 | if (dev->in_pipe) |
| @@ -1979,15 +1990,23 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1979 | iwtest = " iso-out"; | 1990 | iwtest = " iso-out"; |
| 1980 | } | 1991 | } |
| 1981 | 1992 | ||
| 1982 | usb_set_intfdata (intf, dev); | 1993 | usb_set_intfdata(intf, dev); |
| 1983 | dev_info (&intf->dev, "%s\n", info->name); | 1994 | dev_info(&intf->dev, "%s\n", info->name); |
| 1984 | dev_info (&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n", | 1995 | dev_info(&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n", |
| 1985 | ({ char *tmp; | 1996 | ({ char *tmp; |
| 1986 | switch (udev->speed) { | 1997 | switch (udev->speed) { |
| 1987 | case USB_SPEED_LOW: tmp = "low"; break; | 1998 | case USB_SPEED_LOW: |
| 1988 | case USB_SPEED_FULL: tmp = "full"; break; | 1999 | tmp = "low"; |
| 1989 | case USB_SPEED_HIGH: tmp = "high"; break; | 2000 | break; |
| 1990 | default: tmp = "unknown"; break; | 2001 | case USB_SPEED_FULL: |
| 2002 | tmp = "full"; | ||
| 2003 | break; | ||
| 2004 | case USB_SPEED_HIGH: | ||
| 2005 | tmp = "high"; | ||
| 2006 | break; | ||
| 2007 | default: | ||
| 2008 | tmp = "unknown"; | ||
| 2009 | break; | ||
| 1991 | }; tmp; }), | 2010 | }; tmp; }), |
| 1992 | info->ctrl_out ? " in/out" : "", | 2011 | info->ctrl_out ? " in/out" : "", |
| 1993 | rtest, wtest, | 2012 | rtest, wtest, |
| @@ -1996,24 +2015,24 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1996 | return 0; | 2015 | return 0; |
| 1997 | } | 2016 | } |
| 1998 | 2017 | ||
| 1999 | static int usbtest_suspend (struct usb_interface *intf, pm_message_t message) | 2018 | static int usbtest_suspend(struct usb_interface *intf, pm_message_t message) |
| 2000 | { | 2019 | { |
| 2001 | return 0; | 2020 | return 0; |
| 2002 | } | 2021 | } |
| 2003 | 2022 | ||
| 2004 | static int usbtest_resume (struct usb_interface *intf) | 2023 | static int usbtest_resume(struct usb_interface *intf) |
| 2005 | { | 2024 | { |
| 2006 | return 0; | 2025 | return 0; |
| 2007 | } | 2026 | } |
| 2008 | 2027 | ||
| 2009 | 2028 | ||
| 2010 | static void usbtest_disconnect (struct usb_interface *intf) | 2029 | static void usbtest_disconnect(struct usb_interface *intf) |
| 2011 | { | 2030 | { |
| 2012 | struct usbtest_dev *dev = usb_get_intfdata (intf); | 2031 | struct usbtest_dev *dev = usb_get_intfdata(intf); |
| 2013 | 2032 | ||
| 2014 | usb_set_intfdata (intf, NULL); | 2033 | usb_set_intfdata(intf, NULL); |
| 2015 | dev_dbg (&intf->dev, "disconnect\n"); | 2034 | dev_dbg(&intf->dev, "disconnect\n"); |
| 2016 | kfree (dev); | 2035 | kfree(dev); |
| 2017 | } | 2036 | } |
| 2018 | 2037 | ||
| 2019 | /* Basic testing only needs a device that can source or sink bulk traffic. | 2038 | /* Basic testing only needs a device that can source or sink bulk traffic. |
| @@ -2050,9 +2069,9 @@ static struct usbtest_info fw_info = { | |||
| 2050 | .ep_in = 2, | 2069 | .ep_in = 2, |
| 2051 | .ep_out = 2, | 2070 | .ep_out = 2, |
| 2052 | .alt = 1, | 2071 | .alt = 1, |
| 2053 | .autoconf = 1, // iso and ctrl_out need autoconf | 2072 | .autoconf = 1, /* iso and ctrl_out need autoconf */ |
| 2054 | .ctrl_out = 1, | 2073 | .ctrl_out = 1, |
| 2055 | .iso = 1, // iso_ep's are #8 in/out | 2074 | .iso = 1, /* iso_ep's are #8 in/out */ |
| 2056 | }; | 2075 | }; |
| 2057 | 2076 | ||
| 2058 | /* peripheral running Linux and 'zero.c' test firmware, or | 2077 | /* peripheral running Linux and 'zero.c' test firmware, or |
| @@ -2109,56 +2128,56 @@ static const struct usb_device_id id_table[] = { | |||
| 2109 | */ | 2128 | */ |
| 2110 | 2129 | ||
| 2111 | /* generic EZ-USB FX controller */ | 2130 | /* generic EZ-USB FX controller */ |
| 2112 | { USB_DEVICE (0x0547, 0x2235), | 2131 | { USB_DEVICE(0x0547, 0x2235), |
| 2113 | .driver_info = (unsigned long) &ez1_info, | 2132 | .driver_info = (unsigned long) &ez1_info, |
| 2114 | }, | 2133 | }, |
| 2115 | 2134 | ||
| 2116 | /* CY3671 development board with EZ-USB FX */ | 2135 | /* CY3671 development board with EZ-USB FX */ |
| 2117 | { USB_DEVICE (0x0547, 0x0080), | 2136 | { USB_DEVICE(0x0547, 0x0080), |
| 2118 | .driver_info = (unsigned long) &ez1_info, | 2137 | .driver_info = (unsigned long) &ez1_info, |
| 2119 | }, | 2138 | }, |
| 2120 | 2139 | ||
| 2121 | /* generic EZ-USB FX2 controller (or development board) */ | 2140 | /* generic EZ-USB FX2 controller (or development board) */ |
| 2122 | { USB_DEVICE (0x04b4, 0x8613), | 2141 | { USB_DEVICE(0x04b4, 0x8613), |
| 2123 | .driver_info = (unsigned long) &ez2_info, | 2142 | .driver_info = (unsigned long) &ez2_info, |
| 2124 | }, | 2143 | }, |
| 2125 | 2144 | ||
| 2126 | /* re-enumerated usb test device firmware */ | 2145 | /* re-enumerated usb test device firmware */ |
| 2127 | { USB_DEVICE (0xfff0, 0xfff0), | 2146 | { USB_DEVICE(0xfff0, 0xfff0), |
| 2128 | .driver_info = (unsigned long) &fw_info, | 2147 | .driver_info = (unsigned long) &fw_info, |
| 2129 | }, | 2148 | }, |
| 2130 | 2149 | ||
| 2131 | /* "Gadget Zero" firmware runs under Linux */ | 2150 | /* "Gadget Zero" firmware runs under Linux */ |
| 2132 | { USB_DEVICE (0x0525, 0xa4a0), | 2151 | { USB_DEVICE(0x0525, 0xa4a0), |
| 2133 | .driver_info = (unsigned long) &gz_info, | 2152 | .driver_info = (unsigned long) &gz_info, |
| 2134 | }, | 2153 | }, |
| 2135 | 2154 | ||
| 2136 | /* so does a user-mode variant */ | 2155 | /* so does a user-mode variant */ |
| 2137 | { USB_DEVICE (0x0525, 0xa4a4), | 2156 | { USB_DEVICE(0x0525, 0xa4a4), |
| 2138 | .driver_info = (unsigned long) &um_info, | 2157 | .driver_info = (unsigned long) &um_info, |
| 2139 | }, | 2158 | }, |
| 2140 | 2159 | ||
| 2141 | /* ... and a user-mode variant that talks iso */ | 2160 | /* ... and a user-mode variant that talks iso */ |
| 2142 | { USB_DEVICE (0x0525, 0xa4a3), | 2161 | { USB_DEVICE(0x0525, 0xa4a3), |
| 2143 | .driver_info = (unsigned long) &um2_info, | 2162 | .driver_info = (unsigned long) &um2_info, |
| 2144 | }, | 2163 | }, |
| 2145 | 2164 | ||
| 2146 | #ifdef KEYSPAN_19Qi | 2165 | #ifdef KEYSPAN_19Qi |
| 2147 | /* Keyspan 19qi uses an21xx (original EZ-USB) */ | 2166 | /* Keyspan 19qi uses an21xx (original EZ-USB) */ |
| 2148 | // this does not coexist with the real Keyspan 19qi driver! | 2167 | /* this does not coexist with the real Keyspan 19qi driver! */ |
| 2149 | { USB_DEVICE (0x06cd, 0x010b), | 2168 | { USB_DEVICE(0x06cd, 0x010b), |
| 2150 | .driver_info = (unsigned long) &ez1_info, | 2169 | .driver_info = (unsigned long) &ez1_info, |
| 2151 | }, | 2170 | }, |
| 2152 | #endif | 2171 | #endif |
| 2153 | 2172 | ||
| 2154 | /*-------------------------------------------------------------*/ | 2173 | /*-------------------------------------------------------------*/ |
| 2155 | 2174 | ||
| 2156 | #ifdef IBOT2 | 2175 | #ifdef IBOT2 |
| 2157 | /* iBOT2 makes a nice source of high speed bulk-in data */ | 2176 | /* iBOT2 makes a nice source of high speed bulk-in data */ |
| 2158 | // this does not coexist with a real iBOT2 driver! | 2177 | /* this does not coexist with a real iBOT2 driver! */ |
| 2159 | { USB_DEVICE (0x0b62, 0x0059), | 2178 | { USB_DEVICE(0x0b62, 0x0059), |
| 2160 | .driver_info = (unsigned long) &ibot2_info, | 2179 | .driver_info = (unsigned long) &ibot2_info, |
| 2161 | }, | 2180 | }, |
| 2162 | #endif | 2181 | #endif |
| 2163 | 2182 | ||
| 2164 | /*-------------------------------------------------------------*/ | 2183 | /*-------------------------------------------------------------*/ |
| @@ -2172,7 +2191,7 @@ static const struct usb_device_id id_table[] = { | |||
| 2172 | 2191 | ||
| 2173 | { } | 2192 | { } |
| 2174 | }; | 2193 | }; |
| 2175 | MODULE_DEVICE_TABLE (usb, id_table); | 2194 | MODULE_DEVICE_TABLE(usb, id_table); |
| 2176 | 2195 | ||
| 2177 | static struct usb_driver usbtest_driver = { | 2196 | static struct usb_driver usbtest_driver = { |
| 2178 | .name = "usbtest", | 2197 | .name = "usbtest", |
| @@ -2186,22 +2205,22 @@ static struct usb_driver usbtest_driver = { | |||
| 2186 | 2205 | ||
| 2187 | /*-------------------------------------------------------------------------*/ | 2206 | /*-------------------------------------------------------------------------*/ |
| 2188 | 2207 | ||
| 2189 | static int __init usbtest_init (void) | 2208 | static int __init usbtest_init(void) |
| 2190 | { | 2209 | { |
| 2191 | #ifdef GENERIC | 2210 | #ifdef GENERIC |
| 2192 | if (vendor) | 2211 | if (vendor) |
| 2193 | pr_debug("params: vend=0x%04x prod=0x%04x\n", vendor, product); | 2212 | pr_debug("params: vend=0x%04x prod=0x%04x\n", vendor, product); |
| 2194 | #endif | 2213 | #endif |
| 2195 | return usb_register (&usbtest_driver); | 2214 | return usb_register(&usbtest_driver); |
| 2196 | } | 2215 | } |
| 2197 | module_init (usbtest_init); | 2216 | module_init(usbtest_init); |
| 2198 | 2217 | ||
| 2199 | static void __exit usbtest_exit (void) | 2218 | static void __exit usbtest_exit(void) |
| 2200 | { | 2219 | { |
| 2201 | usb_deregister (&usbtest_driver); | 2220 | usb_deregister(&usbtest_driver); |
| 2202 | } | 2221 | } |
| 2203 | module_exit (usbtest_exit); | 2222 | module_exit(usbtest_exit); |
| 2204 | 2223 | ||
| 2205 | MODULE_DESCRIPTION ("USB Core/HCD Testing Driver"); | 2224 | MODULE_DESCRIPTION("USB Core/HCD Testing Driver"); |
| 2206 | MODULE_LICENSE ("GPL"); | 2225 | MODULE_LICENSE("GPL"); |
| 2207 | 2226 | ||
