提交 7a93d040 编写于 作者: A Andrzej Pietrasiewicz 提交者: Felipe Balbi

usb: gadget: f_mass_storage: remove compatibility layer

There are no more old interface users left. Remove it.
Signed-off-by: NAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: NKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 1bcce939
...@@ -228,13 +228,6 @@ ...@@ -228,13 +228,6 @@
#define FSG_DRIVER_DESC "Mass Storage Function" #define FSG_DRIVER_DESC "Mass Storage Function"
#define FSG_DRIVER_VERSION "2009/09/11" #define FSG_DRIVER_VERSION "2009/09/11"
/* to avoid a lot of #ifndef-#endif in the temporary compatibility layer */
#ifndef USB_FMS_INCLUDED
#define EXPORT_SYMBOL_GPL_IF_MODULE(m) EXPORT_SYMBOL_GPL(m);
#else
#define EXPORT_SYMBOL_GPL_IF_MODULE(m)
#endif
static const char fsg_string_interface[] = "Mass Storage"; static const char fsg_string_interface[] = "Mass Storage";
#include "storage_common.h" #include "storage_common.h"
...@@ -2651,13 +2644,13 @@ void fsg_common_get(struct fsg_common *common) ...@@ -2651,13 +2644,13 @@ void fsg_common_get(struct fsg_common *common)
{ {
kref_get(&common->ref); kref_get(&common->ref);
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_get); EXPORT_SYMBOL_GPL(fsg_common_get);
void fsg_common_put(struct fsg_common *common) void fsg_common_put(struct fsg_common *common)
{ {
kref_put(&common->ref, fsg_common_release); kref_put(&common->ref, fsg_common_release);
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_put); EXPORT_SYMBOL_GPL(fsg_common_put);
/* check if fsg_num_buffers is within a valid range */ /* check if fsg_num_buffers is within a valid range */
static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers) static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers)
...@@ -2669,7 +2662,7 @@ static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers) ...@@ -2669,7 +2662,7 @@ static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers)
return -EINVAL; return -EINVAL;
} }
static struct fsg_common *fsg_common_setup(struct fsg_common *common, bool zero) static struct fsg_common *fsg_common_setup(struct fsg_common *common)
{ {
if (!common) { if (!common) {
common = kzalloc(sizeof(*common), GFP_KERNEL); common = kzalloc(sizeof(*common), GFP_KERNEL);
...@@ -2677,8 +2670,6 @@ static struct fsg_common *fsg_common_setup(struct fsg_common *common, bool zero) ...@@ -2677,8 +2670,6 @@ static struct fsg_common *fsg_common_setup(struct fsg_common *common, bool zero)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
common->free_storage_on_release = 1; common->free_storage_on_release = 1;
} else { } else {
if (zero)
memset(common, 0, sizeof(*common));
common->free_storage_on_release = 0; common->free_storage_on_release = 0;
} }
init_rwsem(&common->filesem); init_rwsem(&common->filesem);
...@@ -2695,7 +2686,7 @@ void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs) ...@@ -2695,7 +2686,7 @@ void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs)
{ {
common->sysfs = sysfs; common->sysfs = sysfs;
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_set_sysfs); EXPORT_SYMBOL_GPL(fsg_common_set_sysfs);
static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n) static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n)
{ {
...@@ -2751,7 +2742,7 @@ int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n) ...@@ -2751,7 +2742,7 @@ int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n)
return -ENOMEM; return -ENOMEM;
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_set_num_buffers); EXPORT_SYMBOL_GPL(fsg_common_set_num_buffers);
static inline void fsg_common_remove_sysfs(struct fsg_lun *lun) static inline void fsg_common_remove_sysfs(struct fsg_lun *lun)
{ {
...@@ -2790,7 +2781,7 @@ void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs) ...@@ -2790,7 +2781,7 @@ void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs)
fsg_lun_close(lun); fsg_lun_close(lun);
kfree(lun); kfree(lun);
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_remove_lun); EXPORT_SYMBOL_GPL(fsg_common_remove_lun);
static void _fsg_common_remove_luns(struct fsg_common *common, int n) static void _fsg_common_remove_luns(struct fsg_common *common, int n)
{ {
...@@ -2802,7 +2793,7 @@ static void _fsg_common_remove_luns(struct fsg_common *common, int n) ...@@ -2802,7 +2793,7 @@ static void _fsg_common_remove_luns(struct fsg_common *common, int n)
common->luns[i] = NULL; common->luns[i] = NULL;
} }
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_remove_luns); EXPORT_SYMBOL_GPL(fsg_common_remove_luns);
void fsg_common_remove_luns(struct fsg_common *common) void fsg_common_remove_luns(struct fsg_common *common)
{ {
...@@ -2815,7 +2806,7 @@ void fsg_common_free_luns(struct fsg_common *common) ...@@ -2815,7 +2806,7 @@ void fsg_common_free_luns(struct fsg_common *common)
kfree(common->luns); kfree(common->luns);
common->luns = NULL; common->luns = NULL;
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_free_luns); EXPORT_SYMBOL_GPL(fsg_common_free_luns);
int fsg_common_set_nluns(struct fsg_common *common, int nluns) int fsg_common_set_nluns(struct fsg_common *common, int nluns)
{ {
...@@ -2841,21 +2832,21 @@ int fsg_common_set_nluns(struct fsg_common *common, int nluns) ...@@ -2841,21 +2832,21 @@ int fsg_common_set_nluns(struct fsg_common *common, int nluns)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_set_nluns); EXPORT_SYMBOL_GPL(fsg_common_set_nluns);
void fsg_common_set_ops(struct fsg_common *common, void fsg_common_set_ops(struct fsg_common *common,
const struct fsg_operations *ops) const struct fsg_operations *ops)
{ {
common->ops = ops; common->ops = ops;
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_set_ops); EXPORT_SYMBOL_GPL(fsg_common_set_ops);
void fsg_common_free_buffers(struct fsg_common *common) void fsg_common_free_buffers(struct fsg_common *common)
{ {
_fsg_common_free_buffers(common->buffhds, common->fsg_num_buffers); _fsg_common_free_buffers(common->buffhds, common->fsg_num_buffers);
common->buffhds = NULL; common->buffhds = NULL;
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_free_buffers); EXPORT_SYMBOL_GPL(fsg_common_free_buffers);
int fsg_common_set_cdev(struct fsg_common *common, int fsg_common_set_cdev(struct fsg_common *common,
struct usb_composite_dev *cdev, bool can_stall) struct usb_composite_dev *cdev, bool can_stall)
...@@ -2883,7 +2874,7 @@ int fsg_common_set_cdev(struct fsg_common *common, ...@@ -2883,7 +2874,7 @@ int fsg_common_set_cdev(struct fsg_common *common,
return 0; return 0;
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_set_cdev); EXPORT_SYMBOL_GPL(fsg_common_set_cdev);
static inline int fsg_common_add_sysfs(struct fsg_common *common, static inline int fsg_common_add_sysfs(struct fsg_common *common,
struct fsg_lun *lun) struct fsg_lun *lun)
...@@ -3006,7 +2997,7 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg, ...@@ -3006,7 +2997,7 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg,
kfree(lun); kfree(lun);
return rc; return rc;
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_create_lun); EXPORT_SYMBOL_GPL(fsg_common_create_lun);
int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg) int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg)
{ {
...@@ -3028,7 +3019,7 @@ int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg) ...@@ -3028,7 +3019,7 @@ int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg)
_fsg_common_remove_luns(common, i); _fsg_common_remove_luns(common, i);
return rc; return rc;
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_create_luns); EXPORT_SYMBOL_GPL(fsg_common_create_luns);
void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
const char *pn) const char *pn)
...@@ -3045,7 +3036,7 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, ...@@ -3045,7 +3036,7 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
: "File-Stor Gadget"), : "File-Stor Gadget"),
i); i);
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_set_inquiry_string); EXPORT_SYMBOL_GPL(fsg_common_set_inquiry_string);
int fsg_common_run_thread(struct fsg_common *common) int fsg_common_run_thread(struct fsg_common *common)
{ {
...@@ -3064,61 +3055,7 @@ int fsg_common_run_thread(struct fsg_common *common) ...@@ -3064,61 +3055,7 @@ int fsg_common_run_thread(struct fsg_common *common)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_run_thread); EXPORT_SYMBOL_GPL(fsg_common_run_thread);
struct fsg_common *fsg_common_init(struct fsg_common *common,
struct usb_composite_dev *cdev,
struct fsg_config *cfg)
{
int rc;
common = fsg_common_setup(common, !!common);
if (IS_ERR(common))
return common;
fsg_common_set_sysfs(common, true);
common->state = FSG_STATE_IDLE;
rc = fsg_common_set_num_buffers(common, cfg->fsg_num_buffers);
if (rc) {
if (common->free_storage_on_release)
kfree(common);
return ERR_PTR(rc);
}
common->ops = cfg->ops;
common->private_data = cfg->private_data;
rc = fsg_common_set_cdev(common, cdev, cfg->can_stall);
if (rc)
goto error_release;
rc = fsg_common_set_nluns(common, cfg->nluns);
if (rc)
goto error_release;
rc = fsg_common_create_luns(common, cfg);
if (rc)
goto error_release;
fsg_common_set_inquiry_string(common, cfg->vendor_name,
cfg->product_name);
/* Information */
INFO(common, FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n");
rc = fsg_common_run_thread(common);
if (rc)
goto error_release;
return common;
error_release:
common->state = FSG_STATE_TERMINATED; /* The thread is dead */
/* Call fsg_common_release() directly, ref might be not initialised. */
fsg_common_release(&common->ref);
return ERR_PTR(rc);
}
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_init);
static void fsg_common_release(struct kref *ref) static void fsg_common_release(struct kref *ref)
{ {
...@@ -3166,9 +3103,8 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -3166,9 +3103,8 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
struct usb_ep *ep; struct usb_ep *ep;
unsigned max_burst; unsigned max_burst;
int ret; int ret;
#ifndef USB_FMS_INCLUDED
struct fsg_opts *opts; struct fsg_opts *opts;
opts = fsg_opts_from_func_inst(f->fi); opts = fsg_opts_from_func_inst(f->fi);
if (!opts->no_configfs) { if (!opts->no_configfs) {
ret = fsg_common_set_cdev(fsg->common, c->cdev, ret = fsg_common_set_cdev(fsg->common, c->cdev,
...@@ -3180,7 +3116,6 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -3180,7 +3116,6 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
if (ret) if (ret)
return ret; return ret;
} }
#endif
fsg->gadget = gadget; fsg->gadget = gadget;
...@@ -3248,54 +3183,9 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f) ...@@ -3248,54 +3183,9 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f)
wait_event(common->fsg_wait, common->fsg != fsg); wait_event(common->fsg_wait, common->fsg != fsg);
} }
#ifdef USB_FMS_INCLUDED
fsg_common_put(common);
#endif
usb_free_all_descriptors(&fsg->function); usb_free_all_descriptors(&fsg->function);
#ifdef USB_FMS_INCLUDED
kfree(fsg);
#endif
}
#ifdef USB_FMS_INCLUDED
static int fsg_bind_config(struct usb_composite_dev *cdev,
struct usb_configuration *c,
struct fsg_common *common)
{
struct fsg_dev *fsg;
int rc;
fsg = kzalloc(sizeof *fsg, GFP_KERNEL);
if (unlikely(!fsg))
return -ENOMEM;
fsg->function.name = FSG_DRIVER_DESC;
fsg->function.bind = fsg_bind;
fsg->function.unbind = fsg_unbind;
fsg->function.setup = fsg_setup;
fsg->function.set_alt = fsg_set_alt;
fsg->function.disable = fsg_disable;
fsg->common = common;
/*
* Our caller holds a reference to common structure so we
* don't have to be worry about it being freed until we return
* from this function. So instead of incrementing counter now
* and decrement in error recovery we increment it only when
* call to usb_add_function() was successful.
*/
rc = usb_add_function(c, &fsg->function);
if (unlikely(rc))
kfree(fsg);
else
fsg_common_get(fsg->common);
return rc;
} }
#else
static inline struct fsg_lun_opts *to_fsg_lun_opts(struct config_item *item) static inline struct fsg_lun_opts *to_fsg_lun_opts(struct config_item *item)
{ {
return container_of(to_config_group(item), struct fsg_lun_opts, group); return container_of(to_config_group(item), struct fsg_lun_opts, group);
...@@ -3652,7 +3542,7 @@ static struct usb_function_instance *fsg_alloc_inst(void) ...@@ -3652,7 +3542,7 @@ static struct usb_function_instance *fsg_alloc_inst(void)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
mutex_init(&opts->lock); mutex_init(&opts->lock);
opts->func_inst.free_func_inst = fsg_free_inst; opts->func_inst.free_func_inst = fsg_free_inst;
opts->common = fsg_common_setup(opts->common, false); opts->common = fsg_common_setup(opts->common);
if (IS_ERR(opts->common)) { if (IS_ERR(opts->common)) {
rc = PTR_ERR(opts->common); rc = PTR_ERR(opts->common);
goto release_opts; goto release_opts;
...@@ -3734,8 +3624,6 @@ DECLARE_USB_FUNCTION_INIT(mass_storage, fsg_alloc_inst, fsg_alloc); ...@@ -3734,8 +3624,6 @@ DECLARE_USB_FUNCTION_INIT(mass_storage, fsg_alloc_inst, fsg_alloc);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Michal Nazarewicz"); MODULE_AUTHOR("Michal Nazarewicz");
#endif
/************************* Module parameters *************************/ /************************* Module parameters *************************/
...@@ -3771,5 +3659,5 @@ void fsg_config_from_params(struct fsg_config *cfg, ...@@ -3771,5 +3659,5 @@ void fsg_config_from_params(struct fsg_config *cfg,
cfg->can_stall = params->stall; cfg->can_stall = params->stall;
cfg->fsg_num_buffers = fsg_num_buffers; cfg->fsg_num_buffers = fsg_num_buffers;
} }
EXPORT_SYMBOL_GPL_IF_MODULE(fsg_config_from_params); EXPORT_SYMBOL_GPL(fsg_config_from_params);
...@@ -128,10 +128,6 @@ void fsg_common_get(struct fsg_common *common); ...@@ -128,10 +128,6 @@ void fsg_common_get(struct fsg_common *common);
void fsg_common_put(struct fsg_common *common); void fsg_common_put(struct fsg_common *common);
struct fsg_common *fsg_common_init(struct fsg_common *common,
struct usb_composite_dev *cdev,
struct fsg_config *cfg);
void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs); void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs);
int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n); int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n);
...@@ -167,21 +163,4 @@ void fsg_config_from_params(struct fsg_config *cfg, ...@@ -167,21 +163,4 @@ void fsg_config_from_params(struct fsg_config *cfg,
const struct fsg_module_parameters *params, const struct fsg_module_parameters *params,
unsigned int fsg_num_buffers); unsigned int fsg_num_buffers);
static inline struct fsg_common *
fsg_common_from_params(struct fsg_common *common,
struct usb_composite_dev *cdev,
const struct fsg_module_parameters *params,
unsigned int fsg_num_buffers)
__attribute__((unused));
static inline struct fsg_common *
fsg_common_from_params(struct fsg_common *common,
struct usb_composite_dev *cdev,
const struct fsg_module_parameters *params,
unsigned int fsg_num_buffers)
{
struct fsg_config cfg;
fsg_config_from_params(&cfg, params, fsg_num_buffers);
return fsg_common_init(common, cdev, &cfg);
}
#endif /* USB_F_MASS_STORAGE_H */ #endif /* USB_F_MASS_STORAGE_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册