diff options
author | Michal Nazarewicz <m.nazarewicz@samsung.com> | 2010-07-05 10:38:04 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 17:35:38 -0400 |
commit | d0893264db29b9bfdb1bc66e731f4ed7f8b52795 (patch) | |
tree | b72a6637bcb4541e0e9429c0019e5f7e45805070 /drivers/usb | |
parent | 1e413943fabdc228e86e4fbaa11e77efa861c23f (diff) |
USB: gadget: storage_common: comments updated
Updated comment to describe why printing macros are needed even
thought they are copied form the composite.h. Also, made multiline
comments follow the coding standard.
Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/storage_common.c | 69 |
1 files changed, 48 insertions, 21 deletions
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 04c462ff0ea6..a10faecfabcd 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c | |||
@@ -57,10 +57,12 @@ | |||
57 | #include <asm/unaligned.h> | 57 | #include <asm/unaligned.h> |
58 | 58 | ||
59 | 59 | ||
60 | /* Thanks to NetChip Technologies for donating this product ID. | 60 | /* |
61 | * Thanks to NetChip Technologies for donating this product ID. | ||
61 | * | 62 | * |
62 | * DO NOT REUSE THESE IDs with any other driver!! Ever!! | 63 | * DO NOT REUSE THESE IDs with any other driver!! Ever!! |
63 | * Instead: allocate your own, using normal USB-IF procedures. */ | 64 | * Instead: allocate your own, using normal USB-IF procedures. |
65 | */ | ||
64 | #define FSG_VENDOR_ID 0x0525 /* NetChip */ | 66 | #define FSG_VENDOR_ID 0x0525 /* NetChip */ |
65 | #define FSG_PRODUCT_ID 0xa4a5 /* Linux-USB File-backed Storage Gadget */ | 67 | #define FSG_PRODUCT_ID 0xa4a5 /* Linux-USB File-backed Storage Gadget */ |
66 | 68 | ||
@@ -84,14 +86,27 @@ | |||
84 | #define LWARN(lun, fmt, args...) dev_warn(&(lun)->dev, fmt, ## args) | 86 | #define LWARN(lun, fmt, args...) dev_warn(&(lun)->dev, fmt, ## args) |
85 | #define LINFO(lun, fmt, args...) dev_info(&(lun)->dev, fmt, ## args) | 87 | #define LINFO(lun, fmt, args...) dev_info(&(lun)->dev, fmt, ## args) |
86 | 88 | ||
87 | /* Keep those macros in sync with thos in | 89 | /* |
88 | * include/linux/ubs/composite.h or else GCC will complain. If they | 90 | * Keep those macros in sync with those in |
91 | * include/linux/usb/composite.h or else GCC will complain. If they | ||
89 | * are identical (the same names of arguments, white spaces in the | 92 | * are identical (the same names of arguments, white spaces in the |
90 | * same places) GCC will allow redefinition otherwise (even if some | 93 | * same places) GCC will allow redefinition otherwise (even if some |
91 | * white space is removed or added) warning will be issued. No | 94 | * white space is removed or added) warning will be issued. |
92 | * checking if those symbols is defined is performed because warning | 95 | * |
93 | * is desired when those macros were defined by someone else to mean | 96 | * Those macros are needed here because File Storage Gadget does not |
94 | * something else. */ | 97 | * include the composite.h header. For composite gadgets those macros |
98 | * are redundant since composite.h is included any way. | ||
99 | * | ||
100 | * One could check whether those macros are already defined (which | ||
101 | * would indicate composite.h had been included) or not (which would | ||
102 | * indicate we were in FSG) but this is not done because a warning is | ||
103 | * desired if definitions here differ from the ones in composite.h. | ||
104 | * | ||
105 | * We want the definitions to match and be the same in File Storage | ||
106 | * Gadget as well as Mass Storage Function (and so composite gadgets | ||
107 | * using MSF). If someone changes them in composite.h it will produce | ||
108 | * a warning in this file when building MSF. | ||
109 | */ | ||
95 | #define DBG(d, fmt, args...) dev_dbg(&(d)->gadget->dev , fmt , ## args) | 110 | #define DBG(d, fmt, args...) dev_dbg(&(d)->gadget->dev , fmt , ## args) |
96 | #define VDBG(d, fmt, args...) dev_vdbg(&(d)->gadget->dev , fmt , ## args) | 111 | #define VDBG(d, fmt, args...) dev_vdbg(&(d)->gadget->dev , fmt , ## args) |
97 | #define ERROR(d, fmt, args...) dev_err(&(d)->gadget->dev , fmt , ## args) | 112 | #define ERROR(d, fmt, args...) dev_err(&(d)->gadget->dev , fmt , ## args) |
@@ -313,9 +328,11 @@ struct fsg_buffhd { | |||
313 | enum fsg_buffer_state state; | 328 | enum fsg_buffer_state state; |
314 | struct fsg_buffhd *next; | 329 | struct fsg_buffhd *next; |
315 | 330 | ||
316 | /* The NetChip 2280 is faster, and handles some protocol faults | 331 | /* |
332 | * The NetChip 2280 is faster, and handles some protocol faults | ||
317 | * better, if we don't submit any short bulk-out read requests. | 333 | * better, if we don't submit any short bulk-out read requests. |
318 | * So we will record the intended request length here. */ | 334 | * So we will record the intended request length here. |
335 | */ | ||
319 | unsigned int bulk_out_intended_length; | 336 | unsigned int bulk_out_intended_length; |
320 | 337 | ||
321 | struct usb_request *inreq; | 338 | struct usb_request *inreq; |
@@ -395,8 +412,10 @@ fsg_intf_desc = { | |||
395 | .iInterface = FSG_STRING_INTERFACE, | 412 | .iInterface = FSG_STRING_INTERFACE, |
396 | }; | 413 | }; |
397 | 414 | ||
398 | /* Three full-speed endpoint descriptors: bulk-in, bulk-out, | 415 | /* |
399 | * and interrupt-in. */ | 416 | * Three full-speed endpoint descriptors: bulk-in, bulk-out, and |
417 | * interrupt-in. | ||
418 | */ | ||
400 | 419 | ||
401 | static struct usb_endpoint_descriptor | 420 | static struct usb_endpoint_descriptor |
402 | fsg_fs_bulk_in_desc = { | 421 | fsg_fs_bulk_in_desc = { |
@@ -459,7 +478,7 @@ static struct usb_descriptor_header *fsg_fs_function[] = { | |||
459 | * | 478 | * |
460 | * That means alternate endpoint descriptors (bigger packets) | 479 | * That means alternate endpoint descriptors (bigger packets) |
461 | * and a "device qualifier" ... plus more construction options | 480 | * and a "device qualifier" ... plus more construction options |
462 | * for the config descriptor. | 481 | * for the configuration descriptor. |
463 | */ | 482 | */ |
464 | static struct usb_endpoint_descriptor | 483 | static struct usb_endpoint_descriptor |
465 | fsg_hs_bulk_in_desc = { | 484 | fsg_hs_bulk_in_desc = { |
@@ -547,8 +566,10 @@ static struct usb_gadget_strings fsg_stringtab = { | |||
547 | 566 | ||
548 | /*-------------------------------------------------------------------------*/ | 567 | /*-------------------------------------------------------------------------*/ |
549 | 568 | ||
550 | /* If the next two routines are called while the gadget is registered, | 569 | /* |
551 | * the caller must own fsg->filesem for writing. */ | 570 | * If the next two routines are called while the gadget is registered, |
571 | * the caller must own fsg->filesem for writing. | ||
572 | */ | ||
552 | 573 | ||
553 | static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) | 574 | static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) |
554 | { | 575 | { |
@@ -587,8 +608,10 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) | |||
587 | goto out; | 608 | goto out; |
588 | } | 609 | } |
589 | 610 | ||
590 | /* If we can't read the file, it's no good. | 611 | /* |
591 | * If we can't write the file, use it read-only. */ | 612 | * If we can't read the file, it's no good. |
613 | * If we can't write the file, use it read-only. | ||
614 | */ | ||
592 | if (!filp->f_op || !(filp->f_op->read || filp->f_op->aio_read)) { | 615 | if (!filp->f_op || !(filp->f_op->read || filp->f_op->aio_read)) { |
593 | LINFO(curlun, "file not readable: %s\n", filename); | 616 | LINFO(curlun, "file not readable: %s\n", filename); |
594 | goto out; | 617 | goto out; |
@@ -646,8 +669,10 @@ static void fsg_lun_close(struct fsg_lun *curlun) | |||
646 | 669 | ||
647 | /*-------------------------------------------------------------------------*/ | 670 | /*-------------------------------------------------------------------------*/ |
648 | 671 | ||
649 | /* Sync the file data, don't bother with the metadata. | 672 | /* |
650 | * This code was copied from fs/buffer.c:sys_fdatasync(). */ | 673 | * Sync the file data, don't bother with the metadata. |
674 | * This code was copied from fs/buffer.c:sys_fdatasync(). | ||
675 | */ | ||
651 | static int fsg_lun_fsync_sub(struct fsg_lun *curlun) | 676 | static int fsg_lun_fsync_sub(struct fsg_lun *curlun) |
652 | { | 677 | { |
653 | struct file *filp = curlun->filp; | 678 | struct file *filp = curlun->filp; |
@@ -728,8 +753,10 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr, | |||
728 | if (sscanf(buf, "%d", &i) != 1) | 753 | if (sscanf(buf, "%d", &i) != 1) |
729 | return -EINVAL; | 754 | return -EINVAL; |
730 | 755 | ||
731 | /* Allow the write-enable status to change only while the backing file | 756 | /* |
732 | * is closed. */ | 757 | * Allow the write-enable status to change only while the |
758 | * backing file is closed. | ||
759 | */ | ||
733 | down_read(filesem); | 760 | down_read(filesem); |
734 | if (fsg_lun_is_open(curlun)) { | 761 | if (fsg_lun_is_open(curlun)) { |
735 | LDBG(curlun, "read-only status change prevented\n"); | 762 | LDBG(curlun, "read-only status change prevented\n"); |