1 #ifndef USB_F_MASS_STORAGE_H
2 #define USB_F_MASS_STORAGE_H
4 #include "storage_common.h"
6 struct fsg_module_parameters
{
7 char *file
[FSG_MAX_LUNS
];
9 bool removable
[FSG_MAX_LUNS
];
10 bool cdrom
[FSG_MAX_LUNS
];
11 bool nofua
[FSG_MAX_LUNS
];
13 unsigned int file_count
, ro_count
, removable_count
, cdrom_count
;
14 unsigned int nofua_count
;
15 unsigned int luns
; /* nluns */
16 bool stall
; /* can_stall */
19 #define _FSG_MODULE_PARAM_ARRAY(prefix, params, name, type, desc) \
20 module_param_array_named(prefix ## name, params.name, type, \
21 &prefix ## params.name ## _count, \
23 MODULE_PARM_DESC(prefix ## name, desc)
25 #define _FSG_MODULE_PARAM(prefix, params, name, type, desc) \
26 module_param_named(prefix ## name, params.name, type, \
28 MODULE_PARM_DESC(prefix ## name, desc)
30 #define __FSG_MODULE_PARAMETERS(prefix, params) \
31 _FSG_MODULE_PARAM_ARRAY(prefix, params, file, charp, \
32 "names of backing files or devices"); \
33 _FSG_MODULE_PARAM_ARRAY(prefix, params, ro, bool, \
34 "true to force read-only"); \
35 _FSG_MODULE_PARAM_ARRAY(prefix, params, removable, bool, \
36 "true to simulate removable media"); \
37 _FSG_MODULE_PARAM_ARRAY(prefix, params, cdrom, bool, \
38 "true to simulate CD-ROM instead of disk"); \
39 _FSG_MODULE_PARAM_ARRAY(prefix, params, nofua, bool, \
40 "true to ignore SCSI WRITE(10,12) FUA bit"); \
41 _FSG_MODULE_PARAM(prefix, params, luns, uint, \
43 _FSG_MODULE_PARAM(prefix, params, stall, bool, \
44 "false to prevent bulk stalls")
46 #ifdef CONFIG_USB_GADGET_DEBUG_FILES
48 #define FSG_MODULE_PARAMETERS(prefix, params) \
49 __FSG_MODULE_PARAMETERS(prefix, params); \
50 module_param_named(num_buffers, fsg_num_buffers, uint, S_IRUGO);\
51 MODULE_PARM_DESC(num_buffers, "Number of pipeline buffers")
54 #define FSG_MODULE_PARAMETERS(prefix, params) \
55 __FSG_MODULE_PARAMETERS(prefix, params)
61 /* FSF callback functions */
62 struct fsg_operations
{
64 * Callback function to call when thread exits. If no
65 * callback is set or it returns value lower then zero MSF
66 * will force eject all LUNs it operates on (including those
67 * marked as non-removable or with prevent_medium_removal flag
70 int (*thread_exits
)(struct fsg_common
*common
);
73 struct fsg_lun_config
{
83 struct fsg_lun_config luns
[FSG_MAX_LUNS
];
85 /* Callback functions. */
86 const struct fsg_operations
*ops
;
87 /* Gadget's private data. */
90 const char *vendor_name
; /* 8 characters or less */
91 const char *product_name
; /* 16 characters or less */
94 unsigned int fsg_num_buffers
;
97 void fsg_common_get(struct fsg_common
*common
);
99 void fsg_common_put(struct fsg_common
*common
);
101 struct fsg_common
*fsg_common_init(struct fsg_common
*common
,
102 struct usb_composite_dev
*cdev
,
103 struct fsg_config
*cfg
);
105 void fsg_config_from_params(struct fsg_config
*cfg
,
106 const struct fsg_module_parameters
*params
,
107 unsigned int fsg_num_buffers
);
109 static inline struct fsg_common
*
110 fsg_common_from_params(struct fsg_common
*common
,
111 struct usb_composite_dev
*cdev
,
112 const struct fsg_module_parameters
*params
,
113 unsigned int fsg_num_buffers
)
114 __attribute__((unused
));
115 static inline struct fsg_common
*
116 fsg_common_from_params(struct fsg_common
*common
,
117 struct usb_composite_dev
*cdev
,
118 const struct fsg_module_parameters
*params
,
119 unsigned int fsg_num_buffers
)
121 struct fsg_config cfg
;
122 fsg_config_from_params(&cfg
, params
, fsg_num_buffers
);
123 return fsg_common_init(common
, cdev
, &cfg
);
126 #endif /* USB_F_MASS_STORAGE_H */
This page took 0.090033 seconds and 5 git commands to generate.