diff options
author | Martin Fuzzey <mfuzzey@gmail.com> | 2010-09-30 18:20:42 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-22 13:22:01 -0400 |
commit | fabbf2196d0db0b4d175456dcb373aa2440f5728 (patch) | |
tree | b4dafe149903ed21d1874a575aafd89e786b42ba /drivers/usb | |
parent | 80f0cf3947889014d3a3dc0ad60fb87cfda4b12a (diff) |
USB: usbtest fix coding style
Signed-off-by: Martin Fuzzey <mfuzzey@gmail.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/misc/usbtest.c | 665 |
1 files changed, 341 insertions, 324 deletions
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index eef370eb7a54..bb078ebb8e81 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 | ||
@@ -1366,7 +1374,7 @@ static void iso_callback (struct urb *urb) | |||
1366 | 1374 | ||
1367 | if (urb->status == 0 && ctx->count > (ctx->pending - 1) | 1375 | if (urb->status == 0 && ctx->count > (ctx->pending - 1) |
1368 | && !ctx->submit_error) { | 1376 | && !ctx->submit_error) { |
1369 | int status = usb_submit_urb (urb, GFP_ATOMIC); | 1377 | int status = usb_submit_urb(urb, GFP_ATOMIC); |
1370 | switch (status) { | 1378 | switch (status) { |
1371 | case 0: | 1379 | case 0: |
1372 | goto done; | 1380 | goto done; |
@@ -1388,13 +1396,13 @@ static void iso_callback (struct urb *urb) | |||
1388 | dev_err(&ctx->dev->intf->dev, | 1396 | dev_err(&ctx->dev->intf->dev, |
1389 | "iso test, %lu errors out of %lu\n", | 1397 | "iso test, %lu errors out of %lu\n", |
1390 | ctx->errors, ctx->packet_count); | 1398 | ctx->errors, ctx->packet_count); |
1391 | complete (&ctx->done); | 1399 | complete(&ctx->done); |
1392 | } | 1400 | } |
1393 | done: | 1401 | done: |
1394 | spin_unlock(&ctx->lock); | 1402 | spin_unlock(&ctx->lock); |
1395 | } | 1403 | } |
1396 | 1404 | ||
1397 | static struct urb *iso_alloc_urb ( | 1405 | static struct urb *iso_alloc_urb( |
1398 | struct usb_device *udev, | 1406 | struct usb_device *udev, |
1399 | int pipe, | 1407 | int pipe, |
1400 | struct usb_endpoint_descriptor *desc, | 1408 | struct usb_endpoint_descriptor *desc, |
@@ -1410,7 +1418,7 @@ static struct urb *iso_alloc_urb ( | |||
1410 | maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); | 1418 | maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); |
1411 | packets = DIV_ROUND_UP(bytes, maxp); | 1419 | packets = DIV_ROUND_UP(bytes, maxp); |
1412 | 1420 | ||
1413 | urb = usb_alloc_urb (packets, GFP_KERNEL); | 1421 | urb = usb_alloc_urb(packets, GFP_KERNEL); |
1414 | if (!urb) | 1422 | if (!urb) |
1415 | return urb; | 1423 | return urb; |
1416 | urb->dev = udev; | 1424 | urb->dev = udev; |
@@ -1418,30 +1426,30 @@ static struct urb *iso_alloc_urb ( | |||
1418 | 1426 | ||
1419 | urb->number_of_packets = packets; | 1427 | urb->number_of_packets = packets; |
1420 | urb->transfer_buffer_length = bytes; | 1428 | urb->transfer_buffer_length = bytes; |
1421 | urb->transfer_buffer = usb_alloc_coherent (udev, bytes, GFP_KERNEL, | 1429 | urb->transfer_buffer = usb_alloc_coherent(udev, bytes, GFP_KERNEL, |
1422 | &urb->transfer_dma); | 1430 | &urb->transfer_dma); |
1423 | if (!urb->transfer_buffer) { | 1431 | if (!urb->transfer_buffer) { |
1424 | usb_free_urb (urb); | 1432 | usb_free_urb(urb); |
1425 | return NULL; | 1433 | return NULL; |
1426 | } | 1434 | } |
1427 | memset (urb->transfer_buffer, 0, bytes); | 1435 | memset(urb->transfer_buffer, 0, bytes); |
1428 | for (i = 0; i < packets; i++) { | 1436 | for (i = 0; i < packets; i++) { |
1429 | /* here, only the last packet will be short */ | 1437 | /* here, only the last packet will be short */ |
1430 | urb->iso_frame_desc[i].length = min ((unsigned) bytes, maxp); | 1438 | urb->iso_frame_desc[i].length = min((unsigned) bytes, maxp); |
1431 | bytes -= urb->iso_frame_desc[i].length; | 1439 | bytes -= urb->iso_frame_desc[i].length; |
1432 | 1440 | ||
1433 | urb->iso_frame_desc[i].offset = maxp * i; | 1441 | urb->iso_frame_desc[i].offset = maxp * i; |
1434 | } | 1442 | } |
1435 | 1443 | ||
1436 | urb->complete = iso_callback; | 1444 | urb->complete = iso_callback; |
1437 | // urb->context = SET BY CALLER | 1445 | /* urb->context = SET BY CALLER */ |
1438 | urb->interval = 1 << (desc->bInterval - 1); | 1446 | urb->interval = 1 << (desc->bInterval - 1); |
1439 | urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; | 1447 | urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; |
1440 | return urb; | 1448 | return urb; |
1441 | } | 1449 | } |
1442 | 1450 | ||
1443 | static int | 1451 | static int |
1444 | test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | 1452 | test_iso_queue(struct usbtest_dev *dev, struct usbtest_param *param, |
1445 | int pipe, struct usb_endpoint_descriptor *desc) | 1453 | int pipe, struct usb_endpoint_descriptor *desc) |
1446 | { | 1454 | { |
1447 | struct iso_context context; | 1455 | struct iso_context context; |
@@ -1457,11 +1465,11 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
1457 | memset(&context, 0, sizeof context); | 1465 | memset(&context, 0, sizeof context); |
1458 | context.count = param->iterations * param->sglen; | 1466 | context.count = param->iterations * param->sglen; |
1459 | context.dev = dev; | 1467 | context.dev = dev; |
1460 | init_completion (&context.done); | 1468 | init_completion(&context.done); |
1461 | spin_lock_init (&context.lock); | 1469 | spin_lock_init(&context.lock); |
1462 | 1470 | ||
1463 | memset (urbs, 0, sizeof urbs); | 1471 | memset(urbs, 0, sizeof urbs); |
1464 | udev = testdev_to_usbdev (dev); | 1472 | udev = testdev_to_usbdev(dev); |
1465 | dev_info(&dev->intf->dev, | 1473 | dev_info(&dev->intf->dev, |
1466 | "... iso period %d %sframes, wMaxPacket %04x\n", | 1474 | "... iso period %d %sframes, wMaxPacket %04x\n", |
1467 | 1 << (desc->bInterval - 1), | 1475 | 1 << (desc->bInterval - 1), |
@@ -1469,14 +1477,14 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
1469 | le16_to_cpu(desc->wMaxPacketSize)); | 1477 | le16_to_cpu(desc->wMaxPacketSize)); |
1470 | 1478 | ||
1471 | for (i = 0; i < param->sglen; i++) { | 1479 | for (i = 0; i < param->sglen; i++) { |
1472 | urbs [i] = iso_alloc_urb (udev, pipe, desc, | 1480 | urbs[i] = iso_alloc_urb(udev, pipe, desc, |
1473 | param->length); | 1481 | param->length); |
1474 | if (!urbs [i]) { | 1482 | if (!urbs[i]) { |
1475 | status = -ENOMEM; | 1483 | status = -ENOMEM; |
1476 | goto fail; | 1484 | goto fail; |
1477 | } | 1485 | } |
1478 | packets += urbs[i]->number_of_packets; | 1486 | packets += urbs[i]->number_of_packets; |
1479 | urbs [i]->context = &context; | 1487 | urbs[i]->context = &context; |
1480 | } | 1488 | } |
1481 | packets *= param->iterations; | 1489 | packets *= param->iterations; |
1482 | dev_info(&dev->intf->dev, | 1490 | dev_info(&dev->intf->dev, |
@@ -1485,27 +1493,27 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
1485 | / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1), | 1493 | / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1), |
1486 | packets); | 1494 | packets); |
1487 | 1495 | ||
1488 | spin_lock_irq (&context.lock); | 1496 | spin_lock_irq(&context.lock); |
1489 | for (i = 0; i < param->sglen; i++) { | 1497 | for (i = 0; i < param->sglen; i++) { |
1490 | ++context.pending; | 1498 | ++context.pending; |
1491 | status = usb_submit_urb (urbs [i], GFP_ATOMIC); | 1499 | status = usb_submit_urb(urbs[i], GFP_ATOMIC); |
1492 | if (status < 0) { | 1500 | if (status < 0) { |
1493 | ERROR (dev, "submit iso[%d], error %d\n", i, status); | 1501 | ERROR(dev, "submit iso[%d], error %d\n", i, status); |
1494 | if (i == 0) { | 1502 | if (i == 0) { |
1495 | spin_unlock_irq (&context.lock); | 1503 | spin_unlock_irq(&context.lock); |
1496 | goto fail; | 1504 | goto fail; |
1497 | } | 1505 | } |
1498 | 1506 | ||
1499 | simple_free_urb (urbs [i]); | 1507 | simple_free_urb(urbs[i]); |
1500 | urbs[i] = NULL; | 1508 | urbs[i] = NULL; |
1501 | context.pending--; | 1509 | context.pending--; |
1502 | context.submit_error = 1; | 1510 | context.submit_error = 1; |
1503 | break; | 1511 | break; |
1504 | } | 1512 | } |
1505 | } | 1513 | } |
1506 | spin_unlock_irq (&context.lock); | 1514 | spin_unlock_irq(&context.lock); |
1507 | 1515 | ||
1508 | wait_for_completion (&context.done); | 1516 | wait_for_completion(&context.done); |
1509 | 1517 | ||
1510 | for (i = 0; i < param->sglen; i++) { | 1518 | for (i = 0; i < param->sglen; i++) { |
1511 | if (urbs[i]) | 1519 | if (urbs[i]) |
@@ -1526,8 +1534,8 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
1526 | 1534 | ||
1527 | fail: | 1535 | fail: |
1528 | for (i = 0; i < param->sglen; i++) { | 1536 | for (i = 0; i < param->sglen; i++) { |
1529 | if (urbs [i]) | 1537 | if (urbs[i]) |
1530 | simple_free_urb (urbs [i]); | 1538 | simple_free_urb(urbs[i]); |
1531 | } | 1539 | } |
1532 | return status; | 1540 | return status; |
1533 | } | 1541 | } |
@@ -1557,10 +1565,10 @@ fail: | |||
1557 | 1565 | ||
1558 | /* No BKL needed */ | 1566 | /* No BKL needed */ |
1559 | static int | 1567 | static int |
1560 | usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | 1568 | usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf) |
1561 | { | 1569 | { |
1562 | struct usbtest_dev *dev = usb_get_intfdata (intf); | 1570 | struct usbtest_dev *dev = usb_get_intfdata(intf); |
1563 | struct usb_device *udev = testdev_to_usbdev (dev); | 1571 | struct usb_device *udev = testdev_to_usbdev(dev); |
1564 | struct usbtest_param *param = buf; | 1572 | struct usbtest_param *param = buf; |
1565 | int retval = -EOPNOTSUPP; | 1573 | int retval = -EOPNOTSUPP; |
1566 | struct urb *urb; | 1574 | struct urb *urb; |
@@ -1569,7 +1577,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1569 | struct timeval start; | 1577 | struct timeval start; |
1570 | unsigned i; | 1578 | unsigned i; |
1571 | 1579 | ||
1572 | // FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. | 1580 | /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */ |
1573 | 1581 | ||
1574 | pattern = mod_pattern; | 1582 | pattern = mod_pattern; |
1575 | 1583 | ||
@@ -1595,9 +1603,9 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1595 | mutex_unlock(&dev->lock); | 1603 | mutex_unlock(&dev->lock); |
1596 | return -ENODEV; | 1604 | return -ENODEV; |
1597 | } | 1605 | } |
1598 | res = set_altsetting (dev, dev->info->alt); | 1606 | res = set_altsetting(dev, dev->info->alt); |
1599 | if (res) { | 1607 | if (res) { |
1600 | dev_err (&intf->dev, | 1608 | dev_err(&intf->dev, |
1601 | "set altsetting to %d failed, %d\n", | 1609 | "set altsetting to %d failed, %d\n", |
1602 | dev->info->alt, res); | 1610 | dev->info->alt, res); |
1603 | mutex_unlock(&dev->lock); | 1611 | mutex_unlock(&dev->lock); |
@@ -1614,7 +1622,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1614 | * FIXME add more tests! cancel requests, verify the data, control | 1622 | * FIXME add more tests! cancel requests, verify the data, control |
1615 | * queueing, concurrent read+write threads, and so on. | 1623 | * queueing, concurrent read+write threads, and so on. |
1616 | */ | 1624 | */ |
1617 | do_gettimeofday (&start); | 1625 | do_gettimeofday(&start); |
1618 | switch (param->test_num) { | 1626 | switch (param->test_num) { |
1619 | 1627 | ||
1620 | case 0: | 1628 | case 0: |
@@ -1629,14 +1637,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1629 | dev_info(&intf->dev, | 1637 | dev_info(&intf->dev, |
1630 | "TEST 1: write %d bytes %u times\n", | 1638 | "TEST 1: write %d bytes %u times\n", |
1631 | param->length, param->iterations); | 1639 | param->length, param->iterations); |
1632 | urb = simple_alloc_urb (udev, dev->out_pipe, param->length); | 1640 | urb = simple_alloc_urb(udev, dev->out_pipe, param->length); |
1633 | if (!urb) { | 1641 | if (!urb) { |
1634 | retval = -ENOMEM; | 1642 | retval = -ENOMEM; |
1635 | break; | 1643 | break; |
1636 | } | 1644 | } |
1637 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1645 | /* FIRMWARE: bulk sink (maybe accepts short writes) */ |
1638 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test1"); | 1646 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test1"); |
1639 | simple_free_urb (urb); | 1647 | simple_free_urb(urb); |
1640 | break; | 1648 | break; |
1641 | case 2: | 1649 | case 2: |
1642 | if (dev->in_pipe == 0) | 1650 | if (dev->in_pipe == 0) |
@@ -1644,14 +1652,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1644 | dev_info(&intf->dev, | 1652 | dev_info(&intf->dev, |
1645 | "TEST 2: read %d bytes %u times\n", | 1653 | "TEST 2: read %d bytes %u times\n", |
1646 | param->length, param->iterations); | 1654 | param->length, param->iterations); |
1647 | urb = simple_alloc_urb (udev, dev->in_pipe, param->length); | 1655 | urb = simple_alloc_urb(udev, dev->in_pipe, param->length); |
1648 | if (!urb) { | 1656 | if (!urb) { |
1649 | retval = -ENOMEM; | 1657 | retval = -ENOMEM; |
1650 | break; | 1658 | break; |
1651 | } | 1659 | } |
1652 | // FIRMWARE: bulk source (maybe generates short writes) | 1660 | /* FIRMWARE: bulk source (maybe generates short writes) */ |
1653 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test2"); | 1661 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test2"); |
1654 | simple_free_urb (urb); | 1662 | simple_free_urb(urb); |
1655 | break; | 1663 | break; |
1656 | case 3: | 1664 | case 3: |
1657 | if (dev->out_pipe == 0 || param->vary == 0) | 1665 | if (dev->out_pipe == 0 || param->vary == 0) |
@@ -1659,15 +1667,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1659 | dev_info(&intf->dev, | 1667 | dev_info(&intf->dev, |
1660 | "TEST 3: write/%d 0..%d bytes %u times\n", | 1668 | "TEST 3: write/%d 0..%d bytes %u times\n", |
1661 | param->vary, param->length, param->iterations); | 1669 | param->vary, param->length, param->iterations); |
1662 | urb = simple_alloc_urb (udev, dev->out_pipe, param->length); | 1670 | urb = simple_alloc_urb(udev, dev->out_pipe, param->length); |
1663 | if (!urb) { | 1671 | if (!urb) { |
1664 | retval = -ENOMEM; | 1672 | retval = -ENOMEM; |
1665 | break; | 1673 | break; |
1666 | } | 1674 | } |
1667 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1675 | /* FIRMWARE: bulk sink (maybe accepts short writes) */ |
1668 | retval = simple_io(dev, urb, param->iterations, param->vary, | 1676 | retval = simple_io(dev, urb, param->iterations, param->vary, |
1669 | 0, "test3"); | 1677 | 0, "test3"); |
1670 | simple_free_urb (urb); | 1678 | simple_free_urb(urb); |
1671 | break; | 1679 | break; |
1672 | case 4: | 1680 | case 4: |
1673 | if (dev->in_pipe == 0 || param->vary == 0) | 1681 | if (dev->in_pipe == 0 || param->vary == 0) |
@@ -1675,15 +1683,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1675 | dev_info(&intf->dev, | 1683 | dev_info(&intf->dev, |
1676 | "TEST 4: read/%d 0..%d bytes %u times\n", | 1684 | "TEST 4: read/%d 0..%d bytes %u times\n", |
1677 | param->vary, param->length, param->iterations); | 1685 | param->vary, param->length, param->iterations); |
1678 | urb = simple_alloc_urb (udev, dev->in_pipe, param->length); | 1686 | urb = simple_alloc_urb(udev, dev->in_pipe, param->length); |
1679 | if (!urb) { | 1687 | if (!urb) { |
1680 | retval = -ENOMEM; | 1688 | retval = -ENOMEM; |
1681 | break; | 1689 | break; |
1682 | } | 1690 | } |
1683 | // FIRMWARE: bulk source (maybe generates short writes) | 1691 | /* FIRMWARE: bulk source (maybe generates short writes) */ |
1684 | retval = simple_io(dev, urb, param->iterations, param->vary, | 1692 | retval = simple_io(dev, urb, param->iterations, param->vary, |
1685 | 0, "test4"); | 1693 | 0, "test4"); |
1686 | simple_free_urb (urb); | 1694 | simple_free_urb(urb); |
1687 | break; | 1695 | break; |
1688 | 1696 | ||
1689 | /* Queued bulk I/O tests */ | 1697 | /* Queued bulk I/O tests */ |
@@ -1694,15 +1702,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1694 | "TEST 5: write %d sglists %d entries of %d bytes\n", | 1702 | "TEST 5: write %d sglists %d entries of %d bytes\n", |
1695 | param->iterations, | 1703 | param->iterations, |
1696 | param->sglen, param->length); | 1704 | param->sglen, param->length); |
1697 | sg = alloc_sglist (param->sglen, param->length, 0); | 1705 | sg = alloc_sglist(param->sglen, param->length, 0); |
1698 | if (!sg) { | 1706 | if (!sg) { |
1699 | retval = -ENOMEM; | 1707 | retval = -ENOMEM; |
1700 | break; | 1708 | break; |
1701 | } | 1709 | } |
1702 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1710 | /* FIRMWARE: bulk sink (maybe accepts short writes) */ |
1703 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, | 1711 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, |
1704 | &req, sg, param->sglen); | 1712 | &req, sg, param->sglen); |
1705 | free_sglist (sg, param->sglen); | 1713 | free_sglist(sg, param->sglen); |
1706 | break; | 1714 | break; |
1707 | 1715 | ||
1708 | case 6: | 1716 | case 6: |
@@ -1712,15 +1720,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1712 | "TEST 6: read %d sglists %d entries of %d bytes\n", | 1720 | "TEST 6: read %d sglists %d entries of %d bytes\n", |
1713 | param->iterations, | 1721 | param->iterations, |
1714 | param->sglen, param->length); | 1722 | param->sglen, param->length); |
1715 | sg = alloc_sglist (param->sglen, param->length, 0); | 1723 | sg = alloc_sglist(param->sglen, param->length, 0); |
1716 | if (!sg) { | 1724 | if (!sg) { |
1717 | retval = -ENOMEM; | 1725 | retval = -ENOMEM; |
1718 | break; | 1726 | break; |
1719 | } | 1727 | } |
1720 | // FIRMWARE: bulk source (maybe generates short writes) | 1728 | /* FIRMWARE: bulk source (maybe generates short writes) */ |
1721 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, | 1729 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, |
1722 | &req, sg, param->sglen); | 1730 | &req, sg, param->sglen); |
1723 | free_sglist (sg, param->sglen); | 1731 | free_sglist(sg, param->sglen); |
1724 | break; | 1732 | break; |
1725 | case 7: | 1733 | case 7: |
1726 | if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0) | 1734 | if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0) |
@@ -1729,15 +1737,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", | 1737 | "TEST 7: write/%d %d sglists %d entries 0..%d bytes\n", |
1730 | param->vary, param->iterations, | 1738 | param->vary, param->iterations, |
1731 | param->sglen, param->length); | 1739 | param->sglen, param->length); |
1732 | sg = alloc_sglist (param->sglen, param->length, param->vary); | 1740 | sg = alloc_sglist(param->sglen, param->length, param->vary); |
1733 | if (!sg) { | 1741 | if (!sg) { |
1734 | retval = -ENOMEM; | 1742 | retval = -ENOMEM; |
1735 | break; | 1743 | break; |
1736 | } | 1744 | } |
1737 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1745 | /* FIRMWARE: bulk sink (maybe accepts short writes) */ |
1738 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, | 1746 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, |
1739 | &req, sg, param->sglen); | 1747 | &req, sg, param->sglen); |
1740 | free_sglist (sg, param->sglen); | 1748 | free_sglist(sg, param->sglen); |
1741 | break; | 1749 | break; |
1742 | case 8: | 1750 | case 8: |
1743 | if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0) | 1751 | if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0) |
@@ -1746,15 +1754,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", | 1754 | "TEST 8: read/%d %d sglists %d entries 0..%d bytes\n", |
1747 | param->vary, param->iterations, | 1755 | param->vary, param->iterations, |
1748 | param->sglen, param->length); | 1756 | param->sglen, param->length); |
1749 | sg = alloc_sglist (param->sglen, param->length, param->vary); | 1757 | sg = alloc_sglist(param->sglen, param->length, param->vary); |
1750 | if (!sg) { | 1758 | if (!sg) { |
1751 | retval = -ENOMEM; | 1759 | retval = -ENOMEM; |
1752 | break; | 1760 | break; |
1753 | } | 1761 | } |
1754 | // FIRMWARE: bulk source (maybe generates short writes) | 1762 | /* FIRMWARE: bulk source (maybe generates short writes) */ |
1755 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, | 1763 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, |
1756 | &req, sg, param->sglen); | 1764 | &req, sg, param->sglen); |
1757 | free_sglist (sg, param->sglen); | 1765 | free_sglist(sg, param->sglen); |
1758 | break; | 1766 | break; |
1759 | 1767 | ||
1760 | /* non-queued sanity tests for control (chapter 9 subset) */ | 1768 | /* non-queued sanity tests for control (chapter 9 subset) */ |
@@ -1764,7 +1772,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1764 | "TEST 9: ch9 (subset) control tests, %d times\n", | 1772 | "TEST 9: ch9 (subset) control tests, %d times\n", |
1765 | param->iterations); | 1773 | param->iterations); |
1766 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1774 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
1767 | retval = ch9_postconfig (dev); | 1775 | retval = ch9_postconfig(dev); |
1768 | if (retval) | 1776 | if (retval) |
1769 | dev_err(&intf->dev, "ch9 subset failed, " | 1777 | dev_err(&intf->dev, "ch9 subset failed, " |
1770 | "iterations left %d\n", i); | 1778 | "iterations left %d\n", i); |
@@ -1779,7 +1787,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1779 | "TEST 10: queue %d control calls, %d times\n", | 1787 | "TEST 10: queue %d control calls, %d times\n", |
1780 | param->sglen, | 1788 | param->sglen, |
1781 | param->iterations); | 1789 | param->iterations); |
1782 | retval = test_ctrl_queue (dev, param); | 1790 | retval = test_ctrl_queue(dev, param); |
1783 | break; | 1791 | break; |
1784 | 1792 | ||
1785 | /* simple non-queued unlinks (ring with one urb) */ | 1793 | /* simple non-queued unlinks (ring with one urb) */ |
@@ -1790,7 +1798,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", | 1798 | dev_info(&intf->dev, "TEST 11: unlink %d reads of %d\n", |
1791 | param->iterations, param->length); | 1799 | param->iterations, param->length); |
1792 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1800 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
1793 | retval = unlink_simple (dev, dev->in_pipe, | 1801 | retval = unlink_simple(dev, dev->in_pipe, |
1794 | param->length); | 1802 | param->length); |
1795 | if (retval) | 1803 | if (retval) |
1796 | dev_err(&intf->dev, "unlink reads failed %d, " | 1804 | dev_err(&intf->dev, "unlink reads failed %d, " |
@@ -1803,7 +1811,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", | 1811 | dev_info(&intf->dev, "TEST 12: unlink %d writes of %d\n", |
1804 | param->iterations, param->length); | 1812 | param->iterations, param->length); |
1805 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1813 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
1806 | retval = unlink_simple (dev, dev->out_pipe, | 1814 | retval = unlink_simple(dev, dev->out_pipe, |
1807 | param->length); | 1815 | param->length); |
1808 | if (retval) | 1816 | if (retval) |
1809 | dev_err(&intf->dev, "unlink writes failed %d, " | 1817 | dev_err(&intf->dev, "unlink writes failed %d, " |
@@ -1818,7 +1826,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1818 | dev_info(&intf->dev, "TEST 13: set/clear %d halts\n", | 1826 | dev_info(&intf->dev, "TEST 13: set/clear %d halts\n", |
1819 | param->iterations); | 1827 | param->iterations); |
1820 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1828 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
1821 | retval = halt_simple (dev); | 1829 | retval = halt_simple(dev); |
1822 | 1830 | ||
1823 | if (retval) | 1831 | if (retval) |
1824 | ERROR(dev, "halts failed, iterations left %d\n", i); | 1832 | ERROR(dev, "halts failed, iterations left %d\n", i); |
@@ -1844,8 +1852,8 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1844 | "TEST 15: write %d iso, %d entries of %d bytes\n", | 1852 | "TEST 15: write %d iso, %d entries of %d bytes\n", |
1845 | param->iterations, | 1853 | param->iterations, |
1846 | param->sglen, param->length); | 1854 | param->sglen, param->length); |
1847 | // FIRMWARE: iso sink | 1855 | /* FIRMWARE: iso sink */ |
1848 | retval = test_iso_queue (dev, param, | 1856 | retval = test_iso_queue(dev, param, |
1849 | dev->out_iso_pipe, dev->iso_out); | 1857 | dev->out_iso_pipe, dev->iso_out); |
1850 | break; | 1858 | break; |
1851 | 1859 | ||
@@ -1857,17 +1865,17 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1857 | "TEST 16: read %d iso, %d entries of %d bytes\n", | 1865 | "TEST 16: read %d iso, %d entries of %d bytes\n", |
1858 | param->iterations, | 1866 | param->iterations, |
1859 | param->sglen, param->length); | 1867 | param->sglen, param->length); |
1860 | // FIRMWARE: iso source | 1868 | /* FIRMWARE: iso source */ |
1861 | retval = test_iso_queue (dev, param, | 1869 | retval = test_iso_queue(dev, param, |
1862 | dev->in_iso_pipe, dev->iso_in); | 1870 | dev->in_iso_pipe, dev->iso_in); |
1863 | break; | 1871 | break; |
1864 | 1872 | ||
1865 | // FIXME unlink from queue (ring with N urbs) | 1873 | /* FIXME unlink from queue (ring with N urbs) */ |
1866 | 1874 | ||
1867 | // FIXME scatterlist cancel (needs helper thread) | 1875 | /* FIXME scatterlist cancel (needs helper thread) */ |
1868 | 1876 | ||
1869 | } | 1877 | } |
1870 | do_gettimeofday (¶m->duration); | 1878 | do_gettimeofday(¶m->duration); |
1871 | param->duration.tv_sec -= start.tv_sec; | 1879 | param->duration.tv_sec -= start.tv_sec; |
1872 | param->duration.tv_usec -= start.tv_usec; | 1880 | param->duration.tv_usec -= start.tv_usec; |
1873 | if (param->duration.tv_usec < 0) { | 1881 | if (param->duration.tv_usec < 0) { |
@@ -1880,22 +1888,22 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1880 | 1888 | ||
1881 | /*-------------------------------------------------------------------------*/ | 1889 | /*-------------------------------------------------------------------------*/ |
1882 | 1890 | ||
1883 | static unsigned force_interrupt = 0; | 1891 | static unsigned force_interrupt; |
1884 | module_param (force_interrupt, uint, 0); | 1892 | module_param(force_interrupt, uint, 0); |
1885 | MODULE_PARM_DESC (force_interrupt, "0 = test default; else interrupt"); | 1893 | MODULE_PARM_DESC(force_interrupt, "0 = test default; else interrupt"); |
1886 | 1894 | ||
1887 | #ifdef GENERIC | 1895 | #ifdef GENERIC |
1888 | static unsigned short vendor; | 1896 | static unsigned short vendor; |
1889 | module_param(vendor, ushort, 0); | 1897 | module_param(vendor, ushort, 0); |
1890 | MODULE_PARM_DESC (vendor, "vendor code (from usb-if)"); | 1898 | MODULE_PARM_DESC(vendor, "vendor code (from usb-if)"); |
1891 | 1899 | ||
1892 | static unsigned short product; | 1900 | static unsigned short product; |
1893 | module_param(product, ushort, 0); | 1901 | module_param(product, ushort, 0); |
1894 | MODULE_PARM_DESC (product, "product code (from vendor)"); | 1902 | MODULE_PARM_DESC(product, "product code (from vendor)"); |
1895 | #endif | 1903 | #endif |
1896 | 1904 | ||
1897 | static int | 1905 | static int |
1898 | usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | 1906 | usbtest_probe(struct usb_interface *intf, const struct usb_device_id *id) |
1899 | { | 1907 | { |
1900 | struct usb_device *udev; | 1908 | struct usb_device *udev; |
1901 | struct usbtest_dev *dev; | 1909 | struct usbtest_dev *dev; |
@@ -1903,7 +1911,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1903 | char *rtest, *wtest; | 1911 | char *rtest, *wtest; |
1904 | char *irtest, *iwtest; | 1912 | char *irtest, *iwtest; |
1905 | 1913 | ||
1906 | udev = interface_to_usbdev (intf); | 1914 | udev = interface_to_usbdev(intf); |
1907 | 1915 | ||
1908 | #ifdef GENERIC | 1916 | #ifdef GENERIC |
1909 | /* specify devices by module parameters? */ | 1917 | /* specify devices by module parameters? */ |
@@ -1930,8 +1938,9 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1930 | dev->intf = intf; | 1938 | dev->intf = intf; |
1931 | 1939 | ||
1932 | /* cacheline-aligned scratch for i/o */ | 1940 | /* cacheline-aligned scratch for i/o */ |
1933 | if ((dev->buf = kmalloc (TBUF_SIZE, GFP_KERNEL)) == NULL) { | 1941 | dev->buf = kmalloc(TBUF_SIZE, GFP_KERNEL); |
1934 | kfree (dev); | 1942 | if (dev->buf == NULL) { |
1943 | kfree(dev); | ||
1935 | return -ENOMEM; | 1944 | return -ENOMEM; |
1936 | } | 1945 | } |
1937 | 1946 | ||
@@ -1943,18 +1952,18 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1943 | irtest = iwtest = ""; | 1952 | irtest = iwtest = ""; |
1944 | if (force_interrupt || udev->speed == USB_SPEED_LOW) { | 1953 | if (force_interrupt || udev->speed == USB_SPEED_LOW) { |
1945 | if (info->ep_in) { | 1954 | if (info->ep_in) { |
1946 | dev->in_pipe = usb_rcvintpipe (udev, info->ep_in); | 1955 | dev->in_pipe = usb_rcvintpipe(udev, info->ep_in); |
1947 | rtest = " intr-in"; | 1956 | rtest = " intr-in"; |
1948 | } | 1957 | } |
1949 | if (info->ep_out) { | 1958 | if (info->ep_out) { |
1950 | dev->out_pipe = usb_sndintpipe (udev, info->ep_out); | 1959 | dev->out_pipe = usb_sndintpipe(udev, info->ep_out); |
1951 | wtest = " intr-out"; | 1960 | wtest = " intr-out"; |
1952 | } | 1961 | } |
1953 | } else { | 1962 | } else { |
1954 | if (info->autoconf) { | 1963 | if (info->autoconf) { |
1955 | int status; | 1964 | int status; |
1956 | 1965 | ||
1957 | status = get_endpoints (dev, intf); | 1966 | status = get_endpoints(dev, intf); |
1958 | if (status < 0) { | 1967 | if (status < 0) { |
1959 | WARNING(dev, "couldn't get endpoints, %d\n", | 1968 | WARNING(dev, "couldn't get endpoints, %d\n", |
1960 | status); | 1969 | status); |
@@ -1963,10 +1972,10 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1963 | /* may find bulk or ISO pipes */ | 1972 | /* may find bulk or ISO pipes */ |
1964 | } else { | 1973 | } else { |
1965 | if (info->ep_in) | 1974 | if (info->ep_in) |
1966 | dev->in_pipe = usb_rcvbulkpipe (udev, | 1975 | dev->in_pipe = usb_rcvbulkpipe(udev, |
1967 | info->ep_in); | 1976 | info->ep_in); |
1968 | if (info->ep_out) | 1977 | if (info->ep_out) |
1969 | dev->out_pipe = usb_sndbulkpipe (udev, | 1978 | dev->out_pipe = usb_sndbulkpipe(udev, |
1970 | info->ep_out); | 1979 | info->ep_out); |
1971 | } | 1980 | } |
1972 | if (dev->in_pipe) | 1981 | if (dev->in_pipe) |
@@ -1979,15 +1988,23 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1979 | iwtest = " iso-out"; | 1988 | iwtest = " iso-out"; |
1980 | } | 1989 | } |
1981 | 1990 | ||
1982 | usb_set_intfdata (intf, dev); | 1991 | usb_set_intfdata(intf, dev); |
1983 | dev_info (&intf->dev, "%s\n", info->name); | 1992 | dev_info(&intf->dev, "%s\n", info->name); |
1984 | dev_info (&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n", | 1993 | dev_info(&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n", |
1985 | ({ char *tmp; | 1994 | ({ char *tmp; |
1986 | switch (udev->speed) { | 1995 | switch (udev->speed) { |
1987 | case USB_SPEED_LOW: tmp = "low"; break; | 1996 | case USB_SPEED_LOW: |
1988 | case USB_SPEED_FULL: tmp = "full"; break; | 1997 | tmp = "low"; |
1989 | case USB_SPEED_HIGH: tmp = "high"; break; | 1998 | break; |
1990 | default: tmp = "unknown"; break; | 1999 | case USB_SPEED_FULL: |
2000 | tmp = "full"; | ||
2001 | break; | ||
2002 | case USB_SPEED_HIGH: | ||
2003 | tmp = "high"; | ||
2004 | break; | ||
2005 | default: | ||
2006 | tmp = "unknown"; | ||
2007 | break; | ||
1991 | }; tmp; }), | 2008 | }; tmp; }), |
1992 | info->ctrl_out ? " in/out" : "", | 2009 | info->ctrl_out ? " in/out" : "", |
1993 | rtest, wtest, | 2010 | rtest, wtest, |
@@ -1996,24 +2013,24 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1996 | return 0; | 2013 | return 0; |
1997 | } | 2014 | } |
1998 | 2015 | ||
1999 | static int usbtest_suspend (struct usb_interface *intf, pm_message_t message) | 2016 | static int usbtest_suspend(struct usb_interface *intf, pm_message_t message) |
2000 | { | 2017 | { |
2001 | return 0; | 2018 | return 0; |
2002 | } | 2019 | } |
2003 | 2020 | ||
2004 | static int usbtest_resume (struct usb_interface *intf) | 2021 | static int usbtest_resume(struct usb_interface *intf) |
2005 | { | 2022 | { |
2006 | return 0; | 2023 | return 0; |
2007 | } | 2024 | } |
2008 | 2025 | ||
2009 | 2026 | ||
2010 | static void usbtest_disconnect (struct usb_interface *intf) | 2027 | static void usbtest_disconnect(struct usb_interface *intf) |
2011 | { | 2028 | { |
2012 | struct usbtest_dev *dev = usb_get_intfdata (intf); | 2029 | struct usbtest_dev *dev = usb_get_intfdata(intf); |
2013 | 2030 | ||
2014 | usb_set_intfdata (intf, NULL); | 2031 | usb_set_intfdata(intf, NULL); |
2015 | dev_dbg (&intf->dev, "disconnect\n"); | 2032 | dev_dbg(&intf->dev, "disconnect\n"); |
2016 | kfree (dev); | 2033 | kfree(dev); |
2017 | } | 2034 | } |
2018 | 2035 | ||
2019 | /* Basic testing only needs a device that can source or sink bulk traffic. | 2036 | /* Basic testing only needs a device that can source or sink bulk traffic. |
@@ -2050,9 +2067,9 @@ static struct usbtest_info fw_info = { | |||
2050 | .ep_in = 2, | 2067 | .ep_in = 2, |
2051 | .ep_out = 2, | 2068 | .ep_out = 2, |
2052 | .alt = 1, | 2069 | .alt = 1, |
2053 | .autoconf = 1, // iso and ctrl_out need autoconf | 2070 | .autoconf = 1, /* iso and ctrl_out need autoconf */ |
2054 | .ctrl_out = 1, | 2071 | .ctrl_out = 1, |
2055 | .iso = 1, // iso_ep's are #8 in/out | 2072 | .iso = 1, /* iso_ep's are #8 in/out */ |
2056 | }; | 2073 | }; |
2057 | 2074 | ||
2058 | /* peripheral running Linux and 'zero.c' test firmware, or | 2075 | /* peripheral running Linux and 'zero.c' test firmware, or |
@@ -2109,56 +2126,56 @@ static const struct usb_device_id id_table[] = { | |||
2109 | */ | 2126 | */ |
2110 | 2127 | ||
2111 | /* generic EZ-USB FX controller */ | 2128 | /* generic EZ-USB FX controller */ |
2112 | { USB_DEVICE (0x0547, 0x2235), | 2129 | { USB_DEVICE(0x0547, 0x2235), |
2113 | .driver_info = (unsigned long) &ez1_info, | 2130 | .driver_info = (unsigned long) &ez1_info, |
2114 | }, | 2131 | }, |
2115 | 2132 | ||
2116 | /* CY3671 development board with EZ-USB FX */ | 2133 | /* CY3671 development board with EZ-USB FX */ |
2117 | { USB_DEVICE (0x0547, 0x0080), | 2134 | { USB_DEVICE(0x0547, 0x0080), |
2118 | .driver_info = (unsigned long) &ez1_info, | 2135 | .driver_info = (unsigned long) &ez1_info, |
2119 | }, | 2136 | }, |
2120 | 2137 | ||
2121 | /* generic EZ-USB FX2 controller (or development board) */ | 2138 | /* generic EZ-USB FX2 controller (or development board) */ |
2122 | { USB_DEVICE (0x04b4, 0x8613), | 2139 | { USB_DEVICE(0x04b4, 0x8613), |
2123 | .driver_info = (unsigned long) &ez2_info, | 2140 | .driver_info = (unsigned long) &ez2_info, |
2124 | }, | 2141 | }, |
2125 | 2142 | ||
2126 | /* re-enumerated usb test device firmware */ | 2143 | /* re-enumerated usb test device firmware */ |
2127 | { USB_DEVICE (0xfff0, 0xfff0), | 2144 | { USB_DEVICE(0xfff0, 0xfff0), |
2128 | .driver_info = (unsigned long) &fw_info, | 2145 | .driver_info = (unsigned long) &fw_info, |
2129 | }, | 2146 | }, |
2130 | 2147 | ||
2131 | /* "Gadget Zero" firmware runs under Linux */ | 2148 | /* "Gadget Zero" firmware runs under Linux */ |
2132 | { USB_DEVICE (0x0525, 0xa4a0), | 2149 | { USB_DEVICE(0x0525, 0xa4a0), |
2133 | .driver_info = (unsigned long) &gz_info, | 2150 | .driver_info = (unsigned long) &gz_info, |
2134 | }, | 2151 | }, |
2135 | 2152 | ||
2136 | /* so does a user-mode variant */ | 2153 | /* so does a user-mode variant */ |
2137 | { USB_DEVICE (0x0525, 0xa4a4), | 2154 | { USB_DEVICE(0x0525, 0xa4a4), |
2138 | .driver_info = (unsigned long) &um_info, | 2155 | .driver_info = (unsigned long) &um_info, |
2139 | }, | 2156 | }, |
2140 | 2157 | ||
2141 | /* ... and a user-mode variant that talks iso */ | 2158 | /* ... and a user-mode variant that talks iso */ |
2142 | { USB_DEVICE (0x0525, 0xa4a3), | 2159 | { USB_DEVICE(0x0525, 0xa4a3), |
2143 | .driver_info = (unsigned long) &um2_info, | 2160 | .driver_info = (unsigned long) &um2_info, |
2144 | }, | 2161 | }, |
2145 | 2162 | ||
2146 | #ifdef KEYSPAN_19Qi | 2163 | #ifdef KEYSPAN_19Qi |
2147 | /* Keyspan 19qi uses an21xx (original EZ-USB) */ | 2164 | /* Keyspan 19qi uses an21xx (original EZ-USB) */ |
2148 | // this does not coexist with the real Keyspan 19qi driver! | 2165 | /* this does not coexist with the real Keyspan 19qi driver! */ |
2149 | { USB_DEVICE (0x06cd, 0x010b), | 2166 | { USB_DEVICE(0x06cd, 0x010b), |
2150 | .driver_info = (unsigned long) &ez1_info, | 2167 | .driver_info = (unsigned long) &ez1_info, |
2151 | }, | 2168 | }, |
2152 | #endif | 2169 | #endif |
2153 | 2170 | ||
2154 | /*-------------------------------------------------------------*/ | 2171 | /*-------------------------------------------------------------*/ |
2155 | 2172 | ||
2156 | #ifdef IBOT2 | 2173 | #ifdef IBOT2 |
2157 | /* iBOT2 makes a nice source of high speed bulk-in data */ | 2174 | /* iBOT2 makes a nice source of high speed bulk-in data */ |
2158 | // this does not coexist with a real iBOT2 driver! | 2175 | /* this does not coexist with a real iBOT2 driver! */ |
2159 | { USB_DEVICE (0x0b62, 0x0059), | 2176 | { USB_DEVICE(0x0b62, 0x0059), |
2160 | .driver_info = (unsigned long) &ibot2_info, | 2177 | .driver_info = (unsigned long) &ibot2_info, |
2161 | }, | 2178 | }, |
2162 | #endif | 2179 | #endif |
2163 | 2180 | ||
2164 | /*-------------------------------------------------------------*/ | 2181 | /*-------------------------------------------------------------*/ |
@@ -2172,7 +2189,7 @@ static const struct usb_device_id id_table[] = { | |||
2172 | 2189 | ||
2173 | { } | 2190 | { } |
2174 | }; | 2191 | }; |
2175 | MODULE_DEVICE_TABLE (usb, id_table); | 2192 | MODULE_DEVICE_TABLE(usb, id_table); |
2176 | 2193 | ||
2177 | static struct usb_driver usbtest_driver = { | 2194 | static struct usb_driver usbtest_driver = { |
2178 | .name = "usbtest", | 2195 | .name = "usbtest", |
@@ -2186,22 +2203,22 @@ static struct usb_driver usbtest_driver = { | |||
2186 | 2203 | ||
2187 | /*-------------------------------------------------------------------------*/ | 2204 | /*-------------------------------------------------------------------------*/ |
2188 | 2205 | ||
2189 | static int __init usbtest_init (void) | 2206 | static int __init usbtest_init(void) |
2190 | { | 2207 | { |
2191 | #ifdef GENERIC | 2208 | #ifdef GENERIC |
2192 | if (vendor) | 2209 | if (vendor) |
2193 | pr_debug("params: vend=0x%04x prod=0x%04x\n", vendor, product); | 2210 | pr_debug("params: vend=0x%04x prod=0x%04x\n", vendor, product); |
2194 | #endif | 2211 | #endif |
2195 | return usb_register (&usbtest_driver); | 2212 | return usb_register(&usbtest_driver); |
2196 | } | 2213 | } |
2197 | module_init (usbtest_init); | 2214 | module_init(usbtest_init); |
2198 | 2215 | ||
2199 | static void __exit usbtest_exit (void) | 2216 | static void __exit usbtest_exit(void) |
2200 | { | 2217 | { |
2201 | usb_deregister (&usbtest_driver); | 2218 | usb_deregister(&usbtest_driver); |
2202 | } | 2219 | } |
2203 | module_exit (usbtest_exit); | 2220 | module_exit(usbtest_exit); |
2204 | 2221 | ||
2205 | MODULE_DESCRIPTION ("USB Core/HCD Testing Driver"); | 2222 | MODULE_DESCRIPTION("USB Core/HCD Testing Driver"); |
2206 | MODULE_LICENSE ("GPL"); | 2223 | MODULE_LICENSE("GPL"); |
2207 | 2224 | ||