Skip to content

Commit

Permalink
USB: gadget: storage_common: comments updated
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michal Nazarewicz authored and Greg Kroah-Hartman committed Aug 10, 2010
1 parent 1e41394 commit d089326
Showing 1 changed file with 48 additions and 21 deletions.
69 changes: 48 additions & 21 deletions drivers/usb/gadget/storage_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@
#include <asm/unaligned.h>


/* Thanks to NetChip Technologies for donating this product ID.
/*
* Thanks to NetChip Technologies for donating this product ID.
*
* DO NOT REUSE THESE IDs with any other driver!! Ever!!
* Instead: allocate your own, using normal USB-IF procedures. */
* Instead: allocate your own, using normal USB-IF procedures.
*/
#define FSG_VENDOR_ID 0x0525 /* NetChip */
#define FSG_PRODUCT_ID 0xa4a5 /* Linux-USB File-backed Storage Gadget */

Expand All @@ -84,14 +86,27 @@
#define LWARN(lun, fmt, args...) dev_warn(&(lun)->dev, fmt, ## args)
#define LINFO(lun, fmt, args...) dev_info(&(lun)->dev, fmt, ## args)

/* Keep those macros in sync with thos in
* include/linux/ubs/composite.h or else GCC will complain. If they
/*
* Keep those macros in sync with those in
* include/linux/usb/composite.h or else GCC will complain. If they
* are identical (the same names of arguments, white spaces in the
* same places) GCC will allow redefinition otherwise (even if some
* white space is removed or added) warning will be issued. No
* checking if those symbols is defined is performed because warning
* is desired when those macros were defined by someone else to mean
* something else. */
* white space is removed or added) warning will be issued.
*
* Those macros are needed here because File Storage Gadget does not
* include the composite.h header. For composite gadgets those macros
* are redundant since composite.h is included any way.
*
* One could check whether those macros are already defined (which
* would indicate composite.h had been included) or not (which would
* indicate we were in FSG) but this is not done because a warning is
* desired if definitions here differ from the ones in composite.h.
*
* We want the definitions to match and be the same in File Storage
* Gadget as well as Mass Storage Function (and so composite gadgets
* using MSF). If someone changes them in composite.h it will produce
* a warning in this file when building MSF.
*/
#define DBG(d, fmt, args...) dev_dbg(&(d)->gadget->dev , fmt , ## args)
#define VDBG(d, fmt, args...) dev_vdbg(&(d)->gadget->dev , fmt , ## args)
#define ERROR(d, fmt, args...) dev_err(&(d)->gadget->dev , fmt , ## args)
Expand Down Expand Up @@ -313,9 +328,11 @@ struct fsg_buffhd {
enum fsg_buffer_state state;
struct fsg_buffhd *next;

/* The NetChip 2280 is faster, and handles some protocol faults
/*
* The NetChip 2280 is faster, and handles some protocol faults
* better, if we don't submit any short bulk-out read requests.
* So we will record the intended request length here. */
* So we will record the intended request length here.
*/
unsigned int bulk_out_intended_length;

struct usb_request *inreq;
Expand Down Expand Up @@ -395,8 +412,10 @@ fsg_intf_desc = {
.iInterface = FSG_STRING_INTERFACE,
};

/* Three full-speed endpoint descriptors: bulk-in, bulk-out,
* and interrupt-in. */
/*
* Three full-speed endpoint descriptors: bulk-in, bulk-out, and
* interrupt-in.
*/

static struct usb_endpoint_descriptor
fsg_fs_bulk_in_desc = {
Expand Down Expand Up @@ -459,7 +478,7 @@ static struct usb_descriptor_header *fsg_fs_function[] = {
*
* That means alternate endpoint descriptors (bigger packets)
* and a "device qualifier" ... plus more construction options
* for the config descriptor.
* for the configuration descriptor.
*/
static struct usb_endpoint_descriptor
fsg_hs_bulk_in_desc = {
Expand Down Expand Up @@ -547,8 +566,10 @@ static struct usb_gadget_strings fsg_stringtab = {

/*-------------------------------------------------------------------------*/

/* If the next two routines are called while the gadget is registered,
* the caller must own fsg->filesem for writing. */
/*
* If the next two routines are called while the gadget is registered,
* the caller must own fsg->filesem for writing.
*/

static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
{
Expand Down Expand Up @@ -587,8 +608,10 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
goto out;
}

/* If we can't read the file, it's no good.
* If we can't write the file, use it read-only. */
/*
* If we can't read the file, it's no good.
* If we can't write the file, use it read-only.
*/
if (!filp->f_op || !(filp->f_op->read || filp->f_op->aio_read)) {
LINFO(curlun, "file not readable: %s\n", filename);
goto out;
Expand Down Expand Up @@ -646,8 +669,10 @@ static void fsg_lun_close(struct fsg_lun *curlun)

/*-------------------------------------------------------------------------*/

/* Sync the file data, don't bother with the metadata.
* This code was copied from fs/buffer.c:sys_fdatasync(). */
/*
* Sync the file data, don't bother with the metadata.
* This code was copied from fs/buffer.c:sys_fdatasync().
*/
static int fsg_lun_fsync_sub(struct fsg_lun *curlun)
{
struct file *filp = curlun->filp;
Expand Down Expand Up @@ -728,8 +753,10 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
if (sscanf(buf, "%d", &i) != 1)
return -EINVAL;

/* Allow the write-enable status to change only while the backing file
* is closed. */
/*
* Allow the write-enable status to change only while the
* backing file is closed.
*/
down_read(filesem);
if (fsg_lun_is_open(curlun)) {
LDBG(curlun, "read-only status change prevented\n");
Expand Down

0 comments on commit d089326

Please sign in to comment.