usb: gadget: f_mass_storage: convert to new function interface with backward compatib...
[firefly-linux-kernel-4.4.55.git] / drivers / usb / gadget / f_mass_storage.h
index 1b88eae75283972bd8321b3d2e39a4dc4eb9720e..42f7db4084781adaa69d94836eb712e35d5b74ec 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef USB_F_MASS_STORAGE_H
 #define USB_F_MASS_STORAGE_H
 
+#include <linux/usb/composite.h>
 #include "storage_common.h"
 
 struct fsg_module_parameters {
@@ -70,6 +71,12 @@ struct fsg_operations {
        int (*thread_exits)(struct fsg_common *common);
 };
 
+struct fsg_opts {
+       struct fsg_common *common;
+       struct usb_function_instance func_inst;
+       bool no_configfs; /* for legacy gadgets */
+};
+
 struct fsg_lun_config {
        const char *filename;
        char ro;
@@ -94,6 +101,12 @@ struct fsg_config {
        unsigned int            fsg_num_buffers;
 };
 
+static inline struct fsg_opts *
+fsg_opts_from_func_inst(const struct usb_function_instance *fi)
+{
+       return container_of(fi, struct fsg_opts, func_inst);
+}
+
 void fsg_common_get(struct fsg_common *common);
 
 void fsg_common_put(struct fsg_common *common);
@@ -104,6 +117,32 @@ struct fsg_common *fsg_common_init(struct fsg_common *common,
 
 void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs);
 
+int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n);
+
+void fsg_common_free_buffers(struct fsg_common *common);
+
+int fsg_common_set_cdev(struct fsg_common *common,
+                       struct usb_composite_dev *cdev, bool can_stall);
+
+void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs);
+
+void fsg_common_remove_luns(struct fsg_common *common);
+
+void fsg_common_free_luns(struct fsg_common *common);
+
+int fsg_common_set_nluns(struct fsg_common *common, int nluns);
+
+int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg,
+                         unsigned int id, const char *name,
+                         const char **name_pfx);
+
+int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg);
+
+void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
+                                  const char *pn);
+
+int fsg_common_run_thread(struct fsg_common *common);
+
 void fsg_config_from_params(struct fsg_config *cfg,
                            const struct fsg_module_parameters *params,
                            unsigned int fsg_num_buffers);