Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations
storage_common.c File Reference
#include <linux/usb/storage.h>
#include <scsi/scsi.h>
#include <asm/unaligned.h>

Go to the source code of this file.

Data Structures

struct  interrupt_data
 
struct  fsg_lun
 
struct  fsg_buffhd
 

Macros

#define FSG_VENDOR_ID   0x0525 /* NetChip */
 
#define FSG_PRODUCT_ID   0xa4a5 /* Linux-USB File-backed Storage Gadget */
 
#define VLDBG(lun, fmt, args...)   do { } while (0)
 
#define LDBG(lun, fmt, args...)   dev_dbg (&(lun)->dev, fmt, ## args)
 
#define LERROR(lun, fmt, args...)   dev_err (&(lun)->dev, fmt, ## args)
 
#define LWARN(lun, fmt, args...)   dev_warn(&(lun)->dev, fmt, ## args)
 
#define LINFO(lun, fmt, args...)   dev_info(&(lun)->dev, fmt, ## args)
 
#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)
 
#define WARNING(d, fmt, args...)   dev_warn(&(d)->gadget->dev , fmt , ## args)
 
#define INFO(d, fmt, args...)   dev_info(&(d)->gadget->dev , fmt , ## args)
 
#define dump_msg(fsg, label, buf, length)   do { } while (0)
 
#define dump_cdb(fsg)   do { } while (0)
 
#define CBI_INTERRUPT_DATA_LEN   2
 
#define USB_CBI_ADSC_REQUEST   0x00
 
#define MAX_COMMAND_SIZE   16
 
#define SS_NO_SENSE   0
 
#define SS_COMMUNICATION_FAILURE   0x040800
 
#define SS_INVALID_COMMAND   0x052000
 
#define SS_INVALID_FIELD_IN_CDB   0x052400
 
#define SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE   0x052100
 
#define SS_LOGICAL_UNIT_NOT_SUPPORTED   0x052500
 
#define SS_MEDIUM_NOT_PRESENT   0x023a00
 
#define SS_MEDIUM_REMOVAL_PREVENTED   0x055302
 
#define SS_NOT_READY_TO_READY_TRANSITION   0x062800
 
#define SS_RESET_OCCURRED   0x062900
 
#define SS_SAVING_PARAMETERS_NOT_SUPPORTED   0x053900
 
#define SS_UNRECOVERED_READ_ERROR   0x031100
 
#define SS_WRITE_ERROR   0x030c02
 
#define SS_WRITE_PROTECTED   0x072700
 
#define SK(x)   ((u8) ((x) >> 16)) /* Sense Key byte, etc. */
 
#define ASC(x)   ((u8) ((x) >> 8))
 
#define ASCQ(x)   ((u8) (x))
 
#define fsg_lun_is_open(curlun)   ((curlun)->filp != NULL)
 
#define EP0_BUFSIZE   256
 
#define DELAYED_STATUS   (EP0_BUFSIZE + 999) /* An impossibly large value */
 
#define fsg_num_buffers   CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS
 
#define FSG_BUFLEN   ((u32)16384)
 
#define FSG_MAX_LUNS   8
 
#define FSG_FS_FUNCTION_PRE_EP_ENTRIES   2
 
#define FSG_HS_FUNCTION_PRE_EP_ENTRIES   2
 
#define FSG_SS_FUNCTION_PRE_EP_ENTRIES   2
 

Enumerations

enum  fsg_buffer_state {
  BUF_STATE_EMPTY = 0, BUF_STATE_FULL, BUF_STATE_BUSY, BUF_STATE_EMPTY = 0,
  BUF_STATE_FULL, BUF_STATE_BUSY
}
 
enum  fsg_state {
  FSG_STATE_COMMAND_PHASE = -10, FSG_STATE_DATA_PHASE, FSG_STATE_STATUS_PHASE, FSG_STATE_IDLE = 0,
  FSG_STATE_ABORT_BULK_OUT, FSG_STATE_RESET, FSG_STATE_INTERFACE_CHANGE, FSG_STATE_CONFIG_CHANGE,
  FSG_STATE_DISCONNECT, FSG_STATE_EXIT, FSG_STATE_TERMINATED, FSG_STATE_COMMAND_PHASE = -10,
  FSG_STATE_DATA_PHASE, FSG_STATE_STATUS_PHASE, FSG_STATE_IDLE = 0, FSG_STATE_ABORT_BULK_OUT,
  FSG_STATE_RESET, FSG_STATE_INTERFACE_CHANGE, FSG_STATE_CONFIG_CHANGE, FSG_STATE_DISCONNECT,
  FSG_STATE_EXIT, FSG_STATE_TERMINATED
}
 
enum  data_direction {
  DATA_DIR_NONE = 0x0, DATA_DIR_IN = 0x01, DATA_DIR_OUT = 0x02, DATA_DIR_BYRECIPIENT = 0x04,
  DATA_DIR_UNKNOWN = 0, DATA_DIR_FROM_HOST, DATA_DIR_TO_HOST, DATA_DIR_NONE,
  DATA_DIR_UNKNOWN = 0, DATA_DIR_FROM_HOST, DATA_DIR_TO_HOST, DATA_DIR_NONE
}
 
enum  {
  FSG_STRING_MANUFACTURER = 1, FSG_STRING_PRODUCT, FSG_STRING_SERIAL, FSG_STRING_CONFIG,
  FSG_STRING_INTERFACE
}
 

Macro Definition Documentation

#define ASC (   x)    ((u8) ((x) >> 8))

Definition at line 176 of file storage_common.c.

#define ASCQ (   x)    ((u8) (x))

Definition at line 177 of file storage_common.c.

#define CBI_INTERRUPT_DATA_LEN   2

Definition at line 150 of file storage_common.c.

#define DBG (   d,
  fmt,
  args... 
)    dev_dbg(&(d)->gadget->dev , fmt , ## args)

Definition at line 102 of file storage_common.c.

#define DELAYED_STATUS   (EP0_BUFSIZE + 999) /* An impossibly large value */

Definition at line 216 of file storage_common.c.

#define dump_cdb (   fsg)    do { } while (0)

Definition at line 136 of file storage_common.c.

#define dump_msg (   fsg,
  label,
  buf,
  length 
)    do { } while (0)

Definition at line 125 of file storage_common.c.

#define EP0_BUFSIZE   256

Definition at line 215 of file storage_common.c.

#define ERROR (   d,
  fmt,
  args... 
)    dev_err(&(d)->gadget->dev , fmt , ## args)

Definition at line 104 of file storage_common.c.

#define FSG_BUFLEN   ((u32)16384)

Definition at line 245 of file storage_common.c.

#define FSG_FS_FUNCTION_PRE_EP_ENTRIES   2

Definition at line 384 of file storage_common.c.

#define FSG_HS_FUNCTION_PRE_EP_ENTRIES   2

Definition at line 448 of file storage_common.c.

#define fsg_lun_is_open (   curlun)    ((curlun)->filp != NULL)

Definition at line 206 of file storage_common.c.

#define FSG_MAX_LUNS   8

Definition at line 248 of file storage_common.c.

#define fsg_num_buffers   CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS

Definition at line 230 of file storage_common.c.

#define FSG_PRODUCT_ID   0xa4a5 /* Linux-USB File-backed Storage Gadget */

Definition at line 59 of file storage_common.c.

#define FSG_SS_FUNCTION_PRE_EP_ENTRIES   2

Definition at line 523 of file storage_common.c.

#define FSG_VENDOR_ID   0x0525 /* NetChip */

Definition at line 58 of file storage_common.c.

#define INFO (   d,
  fmt,
  args... 
)    dev_info(&(d)->gadget->dev , fmt , ## args)

Definition at line 106 of file storage_common.c.

#define LDBG (   lun,
  fmt,
  args... 
)    dev_dbg (&(lun)->dev, fmt, ## args)

Definition at line 76 of file storage_common.c.

#define LERROR (   lun,
  fmt,
  args... 
)    dev_err (&(lun)->dev, fmt, ## args)

Definition at line 77 of file storage_common.c.

#define LINFO (   lun,
  fmt,
  args... 
)    dev_info(&(lun)->dev, fmt, ## args)

Definition at line 79 of file storage_common.c.

#define LWARN (   lun,
  fmt,
  args... 
)    dev_warn(&(lun)->dev, fmt, ## args)

Definition at line 78 of file storage_common.c.

#define MAX_COMMAND_SIZE   16

Definition at line 157 of file storage_common.c.

#define SK (   x)    ((u8) ((x) >> 16)) /* Sense Key byte, etc. */

Definition at line 175 of file storage_common.c.

#define SS_COMMUNICATION_FAILURE   0x040800

Definition at line 161 of file storage_common.c.

#define SS_INVALID_COMMAND   0x052000

Definition at line 162 of file storage_common.c.

#define SS_INVALID_FIELD_IN_CDB   0x052400

Definition at line 163 of file storage_common.c.

#define SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE   0x052100

Definition at line 164 of file storage_common.c.

#define SS_LOGICAL_UNIT_NOT_SUPPORTED   0x052500

Definition at line 165 of file storage_common.c.

#define SS_MEDIUM_NOT_PRESENT   0x023a00

Definition at line 166 of file storage_common.c.

#define SS_MEDIUM_REMOVAL_PREVENTED   0x055302

Definition at line 167 of file storage_common.c.

#define SS_NO_SENSE   0

Definition at line 160 of file storage_common.c.

#define SS_NOT_READY_TO_READY_TRANSITION   0x062800

Definition at line 168 of file storage_common.c.

#define SS_RESET_OCCURRED   0x062900

Definition at line 169 of file storage_common.c.

#define SS_SAVING_PARAMETERS_NOT_SUPPORTED   0x053900

Definition at line 170 of file storage_common.c.

#define SS_UNRECOVERED_READ_ERROR   0x031100

Definition at line 171 of file storage_common.c.

#define SS_WRITE_ERROR   0x030c02

Definition at line 172 of file storage_common.c.

#define SS_WRITE_PROTECTED   0x072700

Definition at line 173 of file storage_common.c.

#define USB_CBI_ADSC_REQUEST   0x00

Definition at line 153 of file storage_common.c.

#define VDBG (   d,
  fmt,
  args... 
)    dev_vdbg(&(d)->gadget->dev , fmt , ## args)

Definition at line 103 of file storage_common.c.

#define VLDBG (   lun,
  fmt,
  args... 
)    do { } while (0)

Definition at line 73 of file storage_common.c.

#define WARNING (   d,
  fmt,
  args... 
)    dev_warn(&(d)->gadget->dev , fmt , ## args)

Definition at line 105 of file storage_common.c.

Enumeration Type Documentation

anonymous enum
Enumerator:
FSG_STRING_MANUFACTURER 
FSG_STRING_PRODUCT 
FSG_STRING_SERIAL 
FSG_STRING_CONFIG 
FSG_STRING_INTERFACE 

Definition at line 310 of file storage_common.c.

Enumerator:
DATA_DIR_NONE 
DATA_DIR_IN 
DATA_DIR_OUT 
DATA_DIR_BYRECIPIENT 
DATA_DIR_UNKNOWN 
DATA_DIR_FROM_HOST 
DATA_DIR_TO_HOST 
DATA_DIR_NONE 
DATA_DIR_UNKNOWN 
DATA_DIR_FROM_HOST 
DATA_DIR_TO_HOST 
DATA_DIR_NONE 

Definition at line 290 of file storage_common.c.

Enumerator:
BUF_STATE_EMPTY 
BUF_STATE_FULL 
BUF_STATE_BUSY 
BUF_STATE_EMPTY 
BUF_STATE_FULL 
BUF_STATE_BUSY 

Definition at line 250 of file storage_common.c.

enum fsg_state
Enumerator:
FSG_STATE_COMMAND_PHASE 
FSG_STATE_DATA_PHASE 
FSG_STATE_STATUS_PHASE 
FSG_STATE_IDLE 
FSG_STATE_ABORT_BULK_OUT 
FSG_STATE_RESET 
FSG_STATE_INTERFACE_CHANGE 
FSG_STATE_CONFIG_CHANGE 
FSG_STATE_DISCONNECT 
FSG_STATE_EXIT 
FSG_STATE_TERMINATED 
FSG_STATE_COMMAND_PHASE 
FSG_STATE_DATA_PHASE 
FSG_STATE_STATUS_PHASE 
FSG_STATE_IDLE 
FSG_STATE_ABORT_BULK_OUT 
FSG_STATE_RESET 
FSG_STATE_INTERFACE_CHANGE 
FSG_STATE_CONFIG_CHANGE 
FSG_STATE_DISCONNECT 
FSG_STATE_EXIT 
FSG_STATE_TERMINATED 

Definition at line 274 of file storage_common.c.