diff options
author | Michal Nazarewicz <m.nazarewicz@samsung.com> | 2009-10-28 11:57:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-11 14:55:19 -0500 |
commit | 93bcf12e7123f20d30757d35d8052832e3c4d647 (patch) | |
tree | 71a8ccbd467d3de3c8485c03a9465d49ea72d763 /drivers/usb/gadget/storage_common.c | |
parent | d5e2b67aae79f01720d8b962c23b0abc7063201c (diff) |
USB: g_mass_storage: testing code from f_mass_storage.c removed
Removed code that was included when CONFIG_USB_FILE_STORAGE_TEST
was defined. If this functionality is required one may still use
the original File-backed Storage Gadget. It has been agreed that
testing functionality is not required in the composite function.
Also removed fsg_suspend() and fsg_resume() which were no
operations.
Moreover, storage_common.c has been modified in such a way that
defining certain macros skips parts of the file. Those macros
are:
* FSG_NO_INTR_EP -- skips interrupt endpoint descriptors
* FSG_NO_DEVICE_STRINGS -- skips certain strings
* FSG_NO_OTG -- skips OTG descriptor
Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/storage_common.c')
-rw-r--r-- | drivers/usb/gadget/storage_common.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 6523cb6f4c4d..e76c8ced41e2 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c | |||
@@ -33,6 +33,20 @@ | |||
33 | * macro is defined prior to including this file. | 33 | * macro is defined prior to including this file. |
34 | */ | 34 | */ |
35 | 35 | ||
36 | /* | ||
37 | * When FSG_NO_INTR_EP is defined fsg_fs_intr_in_desc and | ||
38 | * fsg_hs_intr_in_desc objects as well as | ||
39 | * FSG_FS_FUNCTION_PRE_EP_ENTRIES and FSG_HS_FUNCTION_PRE_EP_ENTRIES | ||
40 | * macros are not defined. | ||
41 | * | ||
42 | * When FSG_NO_DEVICE_STRINGS is defined FSG_STRING_MANUFACTURER, | ||
43 | * FSG_STRING_PRODUCT, FSG_STRING_SERIAL and FSG_STRING_CONFIG are not | ||
44 | * defined (as well as corresponding entries in string tables are | ||
45 | * missing) and FSG_STRING_INTERFACE has value of zero. | ||
46 | * | ||
47 | * When FSG_NO_OTG is defined fsg_otg_desc won't be defined. | ||
48 | */ | ||
49 | |||
36 | 50 | ||
37 | #include <asm/unaligned.h> | 51 | #include <asm/unaligned.h> |
38 | 52 | ||
@@ -327,14 +341,17 @@ static inline u32 get_unaligned_be24(u8 *buf) | |||
327 | 341 | ||
328 | 342 | ||
329 | enum { | 343 | enum { |
344 | #ifndef FSG_NO_DEVICE_STRINGS | ||
330 | FSG_STRING_MANUFACTURER = 1, | 345 | FSG_STRING_MANUFACTURER = 1, |
331 | FSG_STRING_PRODUCT, | 346 | FSG_STRING_PRODUCT, |
332 | FSG_STRING_SERIAL, | 347 | FSG_STRING_SERIAL, |
333 | FSG_STRING_CONFIG, | 348 | FSG_STRING_CONFIG, |
349 | #endif | ||
334 | FSG_STRING_INTERFACE | 350 | FSG_STRING_INTERFACE |
335 | }; | 351 | }; |
336 | 352 | ||
337 | 353 | ||
354 | #ifndef FSG_NO_OTG | ||
338 | static struct usb_otg_descriptor | 355 | static struct usb_otg_descriptor |
339 | fsg_otg_desc = { | 356 | fsg_otg_desc = { |
340 | .bLength = sizeof fsg_otg_desc, | 357 | .bLength = sizeof fsg_otg_desc, |
@@ -342,6 +359,7 @@ fsg_otg_desc = { | |||
342 | 359 | ||
343 | .bmAttributes = USB_OTG_SRP, | 360 | .bmAttributes = USB_OTG_SRP, |
344 | }; | 361 | }; |
362 | #endif | ||
345 | 363 | ||
346 | /* There is only one interface. */ | 364 | /* There is only one interface. */ |
347 | 365 | ||
@@ -380,6 +398,8 @@ fsg_fs_bulk_out_desc = { | |||
380 | /* wMaxPacketSize set by autoconfiguration */ | 398 | /* wMaxPacketSize set by autoconfiguration */ |
381 | }; | 399 | }; |
382 | 400 | ||
401 | #ifndef FSG_NO_INTR_EP | ||
402 | |||
383 | static struct usb_endpoint_descriptor | 403 | static struct usb_endpoint_descriptor |
384 | fsg_fs_intr_in_desc = { | 404 | fsg_fs_intr_in_desc = { |
385 | .bLength = USB_DT_ENDPOINT_SIZE, | 405 | .bLength = USB_DT_ENDPOINT_SIZE, |
@@ -391,15 +411,26 @@ fsg_fs_intr_in_desc = { | |||
391 | .bInterval = 32, // frames -> 32 ms | 411 | .bInterval = 32, // frames -> 32 ms |
392 | }; | 412 | }; |
393 | 413 | ||
414 | #ifndef FSG_NO_OTG | ||
415 | # define FSG_FS_FUNCTION_PRE_EP_ENTRIES 2 | ||
416 | #else | ||
417 | # define FSG_FS_FUNCTION_PRE_EP_ENTRIES 1 | ||
418 | #endif | ||
419 | |||
420 | #endif | ||
421 | |||
394 | static const struct usb_descriptor_header *fsg_fs_function[] = { | 422 | static const struct usb_descriptor_header *fsg_fs_function[] = { |
423 | #ifndef FSG_NO_OTG | ||
395 | (struct usb_descriptor_header *) &fsg_otg_desc, | 424 | (struct usb_descriptor_header *) &fsg_otg_desc, |
425 | #endif | ||
396 | (struct usb_descriptor_header *) &fsg_intf_desc, | 426 | (struct usb_descriptor_header *) &fsg_intf_desc, |
397 | (struct usb_descriptor_header *) &fsg_fs_bulk_in_desc, | 427 | (struct usb_descriptor_header *) &fsg_fs_bulk_in_desc, |
398 | (struct usb_descriptor_header *) &fsg_fs_bulk_out_desc, | 428 | (struct usb_descriptor_header *) &fsg_fs_bulk_out_desc, |
429 | #ifndef FSG_NO_INTR_EP | ||
399 | (struct usb_descriptor_header *) &fsg_fs_intr_in_desc, | 430 | (struct usb_descriptor_header *) &fsg_fs_intr_in_desc, |
431 | #endif | ||
400 | NULL, | 432 | NULL, |
401 | }; | 433 | }; |
402 | #define FSG_FS_FUNCTION_PRE_EP_ENTRIES 2 | ||
403 | 434 | ||
404 | 435 | ||
405 | /* | 436 | /* |
@@ -431,6 +462,8 @@ fsg_hs_bulk_out_desc = { | |||
431 | .bInterval = 1, // NAK every 1 uframe | 462 | .bInterval = 1, // NAK every 1 uframe |
432 | }; | 463 | }; |
433 | 464 | ||
465 | #ifndef FSG_NO_INTR_EP | ||
466 | |||
434 | static struct usb_endpoint_descriptor | 467 | static struct usb_endpoint_descriptor |
435 | fsg_hs_intr_in_desc = { | 468 | fsg_hs_intr_in_desc = { |
436 | .bLength = USB_DT_ENDPOINT_SIZE, | 469 | .bLength = USB_DT_ENDPOINT_SIZE, |
@@ -442,15 +475,26 @@ fsg_hs_intr_in_desc = { | |||
442 | .bInterval = 9, // 2**(9-1) = 256 uframes -> 32 ms | 475 | .bInterval = 9, // 2**(9-1) = 256 uframes -> 32 ms |
443 | }; | 476 | }; |
444 | 477 | ||
478 | #ifndef FSG_NO_OTG | ||
479 | # define FSG_HS_FUNCTION_PRE_EP_ENTRIES 2 | ||
480 | #else | ||
481 | # define FSG_HS_FUNCTION_PRE_EP_ENTRIES 1 | ||
482 | #endif | ||
483 | |||
484 | #endif | ||
485 | |||
445 | static const struct usb_descriptor_header *fsg_hs_function[] = { | 486 | static const struct usb_descriptor_header *fsg_hs_function[] = { |
487 | #ifndef FSG_NO_OTG | ||
446 | (struct usb_descriptor_header *) &fsg_otg_desc, | 488 | (struct usb_descriptor_header *) &fsg_otg_desc, |
489 | #endif | ||
447 | (struct usb_descriptor_header *) &fsg_intf_desc, | 490 | (struct usb_descriptor_header *) &fsg_intf_desc, |
448 | (struct usb_descriptor_header *) &fsg_hs_bulk_in_desc, | 491 | (struct usb_descriptor_header *) &fsg_hs_bulk_in_desc, |
449 | (struct usb_descriptor_header *) &fsg_hs_bulk_out_desc, | 492 | (struct usb_descriptor_header *) &fsg_hs_bulk_out_desc, |
493 | #ifndef FSG_NO_INTR_EP | ||
450 | (struct usb_descriptor_header *) &fsg_hs_intr_in_desc, | 494 | (struct usb_descriptor_header *) &fsg_hs_intr_in_desc, |
495 | #endif | ||
451 | NULL, | 496 | NULL, |
452 | }; | 497 | }; |
453 | #define FSG_HS_FUNCTION_PRE_EP_ENTRIES 2 | ||
454 | 498 | ||
455 | /* Maxpacket and other transfer characteristics vary by speed. */ | 499 | /* Maxpacket and other transfer characteristics vary by speed. */ |
456 | static struct usb_endpoint_descriptor * | 500 | static struct usb_endpoint_descriptor * |
@@ -465,10 +509,12 @@ fsg_ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *fs, | |||
465 | 509 | ||
466 | /* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */ | 510 | /* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */ |
467 | static struct usb_string fsg_strings[] = { | 511 | static struct usb_string fsg_strings[] = { |
512 | #ifndef FSG_NO_DEVICE_STRINGS | ||
468 | {FSG_STRING_MANUFACTURER, fsg_string_manufacturer}, | 513 | {FSG_STRING_MANUFACTURER, fsg_string_manufacturer}, |
469 | {FSG_STRING_PRODUCT, fsg_string_product}, | 514 | {FSG_STRING_PRODUCT, fsg_string_product}, |
470 | {FSG_STRING_SERIAL, fsg_string_serial}, | 515 | {FSG_STRING_SERIAL, fsg_string_serial}, |
471 | {FSG_STRING_CONFIG, fsg_string_config}, | 516 | {FSG_STRING_CONFIG, fsg_string_config}, |
517 | #endif | ||
472 | {FSG_STRING_INTERFACE, fsg_string_interface}, | 518 | {FSG_STRING_INTERFACE, fsg_string_interface}, |
473 | {} | 519 | {} |
474 | }; | 520 | }; |