diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2013-10-09 04:08:28 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-10-10 11:24:53 -0400 |
commit | 7a93d040e01ec9053ec6ea4486f21829d48f903a (patch) | |
tree | f7f52ee29c0fc3567e69ca9cabf3744f8f3f9f6b /drivers/usb/gadget/f_mass_storage.c | |
parent | 1bcce939478f894b46a592aed28ccc9caaf1a52a (diff) |
usb: gadget: f_mass_storage: remove compatibility layer
There are no more old interface users left. Remove it.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/f_mass_storage.c')
-rw-r--r-- | drivers/usb/gadget/f_mass_storage.c | 150 |
1 files changed, 19 insertions, 131 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 00d3687594bb..6e5a6daf1a12 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -228,13 +228,6 @@ | |||
228 | #define FSG_DRIVER_DESC "Mass Storage Function" | 228 | #define FSG_DRIVER_DESC "Mass Storage Function" |
229 | #define FSG_DRIVER_VERSION "2009/09/11" | 229 | #define FSG_DRIVER_VERSION "2009/09/11" |
230 | 230 | ||
231 | /* to avoid a lot of #ifndef-#endif in the temporary compatibility layer */ | ||
232 | #ifndef USB_FMS_INCLUDED | ||
233 | #define EXPORT_SYMBOL_GPL_IF_MODULE(m) EXPORT_SYMBOL_GPL(m); | ||
234 | #else | ||
235 | #define EXPORT_SYMBOL_GPL_IF_MODULE(m) | ||
236 | #endif | ||
237 | |||
238 | static const char fsg_string_interface[] = "Mass Storage"; | 231 | static const char fsg_string_interface[] = "Mass Storage"; |
239 | 232 | ||
240 | #include "storage_common.h" | 233 | #include "storage_common.h" |
@@ -2651,13 +2644,13 @@ void fsg_common_get(struct fsg_common *common) | |||
2651 | { | 2644 | { |
2652 | kref_get(&common->ref); | 2645 | kref_get(&common->ref); |
2653 | } | 2646 | } |
2654 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_get); | 2647 | EXPORT_SYMBOL_GPL(fsg_common_get); |
2655 | 2648 | ||
2656 | void fsg_common_put(struct fsg_common *common) | 2649 | void fsg_common_put(struct fsg_common *common) |
2657 | { | 2650 | { |
2658 | kref_put(&common->ref, fsg_common_release); | 2651 | kref_put(&common->ref, fsg_common_release); |
2659 | } | 2652 | } |
2660 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_put); | 2653 | EXPORT_SYMBOL_GPL(fsg_common_put); |
2661 | 2654 | ||
2662 | /* check if fsg_num_buffers is within a valid range */ | 2655 | /* check if fsg_num_buffers is within a valid range */ |
2663 | static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers) | 2656 | 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 | return -EINVAL; | 2662 | return -EINVAL; |
2670 | } | 2663 | } |
2671 | 2664 | ||
2672 | static struct fsg_common *fsg_common_setup(struct fsg_common *common, bool zero) | 2665 | static struct fsg_common *fsg_common_setup(struct fsg_common *common) |
2673 | { | 2666 | { |
2674 | if (!common) { | 2667 | if (!common) { |
2675 | common = kzalloc(sizeof(*common), GFP_KERNEL); | 2668 | common = kzalloc(sizeof(*common), GFP_KERNEL); |
@@ -2677,8 +2670,6 @@ static struct fsg_common *fsg_common_setup(struct fsg_common *common, bool zero) | |||
2677 | return ERR_PTR(-ENOMEM); | 2670 | return ERR_PTR(-ENOMEM); |
2678 | common->free_storage_on_release = 1; | 2671 | common->free_storage_on_release = 1; |
2679 | } else { | 2672 | } else { |
2680 | if (zero) | ||
2681 | memset(common, 0, sizeof(*common)); | ||
2682 | common->free_storage_on_release = 0; | 2673 | common->free_storage_on_release = 0; |
2683 | } | 2674 | } |
2684 | init_rwsem(&common->filesem); | 2675 | init_rwsem(&common->filesem); |
@@ -2695,7 +2686,7 @@ void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs) | |||
2695 | { | 2686 | { |
2696 | common->sysfs = sysfs; | 2687 | common->sysfs = sysfs; |
2697 | } | 2688 | } |
2698 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_set_sysfs); | 2689 | EXPORT_SYMBOL_GPL(fsg_common_set_sysfs); |
2699 | 2690 | ||
2700 | static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n) | 2691 | static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n) |
2701 | { | 2692 | { |
@@ -2751,7 +2742,7 @@ error_release: | |||
2751 | 2742 | ||
2752 | return -ENOMEM; | 2743 | return -ENOMEM; |
2753 | } | 2744 | } |
2754 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_set_num_buffers); | 2745 | EXPORT_SYMBOL_GPL(fsg_common_set_num_buffers); |
2755 | 2746 | ||
2756 | static inline void fsg_common_remove_sysfs(struct fsg_lun *lun) | 2747 | static inline void fsg_common_remove_sysfs(struct fsg_lun *lun) |
2757 | { | 2748 | { |
@@ -2790,7 +2781,7 @@ void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs) | |||
2790 | fsg_lun_close(lun); | 2781 | fsg_lun_close(lun); |
2791 | kfree(lun); | 2782 | kfree(lun); |
2792 | } | 2783 | } |
2793 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_remove_lun); | 2784 | EXPORT_SYMBOL_GPL(fsg_common_remove_lun); |
2794 | 2785 | ||
2795 | static void _fsg_common_remove_luns(struct fsg_common *common, int n) | 2786 | static void _fsg_common_remove_luns(struct fsg_common *common, int n) |
2796 | { | 2787 | { |
@@ -2802,7 +2793,7 @@ static void _fsg_common_remove_luns(struct fsg_common *common, int n) | |||
2802 | common->luns[i] = NULL; | 2793 | common->luns[i] = NULL; |
2803 | } | 2794 | } |
2804 | } | 2795 | } |
2805 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_remove_luns); | 2796 | EXPORT_SYMBOL_GPL(fsg_common_remove_luns); |
2806 | 2797 | ||
2807 | void fsg_common_remove_luns(struct fsg_common *common) | 2798 | void fsg_common_remove_luns(struct fsg_common *common) |
2808 | { | 2799 | { |
@@ -2815,7 +2806,7 @@ void fsg_common_free_luns(struct fsg_common *common) | |||
2815 | kfree(common->luns); | 2806 | kfree(common->luns); |
2816 | common->luns = NULL; | 2807 | common->luns = NULL; |
2817 | } | 2808 | } |
2818 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_free_luns); | 2809 | EXPORT_SYMBOL_GPL(fsg_common_free_luns); |
2819 | 2810 | ||
2820 | int fsg_common_set_nluns(struct fsg_common *common, int nluns) | 2811 | int fsg_common_set_nluns(struct fsg_common *common, int nluns) |
2821 | { | 2812 | { |
@@ -2841,21 +2832,21 @@ int fsg_common_set_nluns(struct fsg_common *common, int nluns) | |||
2841 | 2832 | ||
2842 | return 0; | 2833 | return 0; |
2843 | } | 2834 | } |
2844 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_set_nluns); | 2835 | EXPORT_SYMBOL_GPL(fsg_common_set_nluns); |
2845 | 2836 | ||
2846 | void fsg_common_set_ops(struct fsg_common *common, | 2837 | void fsg_common_set_ops(struct fsg_common *common, |
2847 | const struct fsg_operations *ops) | 2838 | const struct fsg_operations *ops) |
2848 | { | 2839 | { |
2849 | common->ops = ops; | 2840 | common->ops = ops; |
2850 | } | 2841 | } |
2851 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_set_ops); | 2842 | EXPORT_SYMBOL_GPL(fsg_common_set_ops); |
2852 | 2843 | ||
2853 | void fsg_common_free_buffers(struct fsg_common *common) | 2844 | void fsg_common_free_buffers(struct fsg_common *common) |
2854 | { | 2845 | { |
2855 | _fsg_common_free_buffers(common->buffhds, common->fsg_num_buffers); | 2846 | _fsg_common_free_buffers(common->buffhds, common->fsg_num_buffers); |
2856 | common->buffhds = NULL; | 2847 | common->buffhds = NULL; |
2857 | } | 2848 | } |
2858 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_free_buffers); | 2849 | EXPORT_SYMBOL_GPL(fsg_common_free_buffers); |
2859 | 2850 | ||
2860 | int fsg_common_set_cdev(struct fsg_common *common, | 2851 | int fsg_common_set_cdev(struct fsg_common *common, |
2861 | struct usb_composite_dev *cdev, bool can_stall) | 2852 | struct usb_composite_dev *cdev, bool can_stall) |
@@ -2883,7 +2874,7 @@ int fsg_common_set_cdev(struct fsg_common *common, | |||
2883 | 2874 | ||
2884 | return 0; | 2875 | return 0; |
2885 | } | 2876 | } |
2886 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_set_cdev); | 2877 | EXPORT_SYMBOL_GPL(fsg_common_set_cdev); |
2887 | 2878 | ||
2888 | static inline int fsg_common_add_sysfs(struct fsg_common *common, | 2879 | static inline int fsg_common_add_sysfs(struct fsg_common *common, |
2889 | struct fsg_lun *lun) | 2880 | struct fsg_lun *lun) |
@@ -3006,7 +2997,7 @@ error_sysfs: | |||
3006 | kfree(lun); | 2997 | kfree(lun); |
3007 | return rc; | 2998 | return rc; |
3008 | } | 2999 | } |
3009 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_create_lun); | 3000 | EXPORT_SYMBOL_GPL(fsg_common_create_lun); |
3010 | 3001 | ||
3011 | int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg) | 3002 | int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg) |
3012 | { | 3003 | { |
@@ -3028,7 +3019,7 @@ fail: | |||
3028 | _fsg_common_remove_luns(common, i); | 3019 | _fsg_common_remove_luns(common, i); |
3029 | return rc; | 3020 | return rc; |
3030 | } | 3021 | } |
3031 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_create_luns); | 3022 | EXPORT_SYMBOL_GPL(fsg_common_create_luns); |
3032 | 3023 | ||
3033 | void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, | 3024 | void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, |
3034 | const char *pn) | 3025 | const char *pn) |
@@ -3045,7 +3036,7 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, | |||
3045 | : "File-Stor Gadget"), | 3036 | : "File-Stor Gadget"), |
3046 | i); | 3037 | i); |
3047 | } | 3038 | } |
3048 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_set_inquiry_string); | 3039 | EXPORT_SYMBOL_GPL(fsg_common_set_inquiry_string); |
3049 | 3040 | ||
3050 | int fsg_common_run_thread(struct fsg_common *common) | 3041 | int fsg_common_run_thread(struct fsg_common *common) |
3051 | { | 3042 | { |
@@ -3064,61 +3055,7 @@ int fsg_common_run_thread(struct fsg_common *common) | |||
3064 | 3055 | ||
3065 | return 0; | 3056 | return 0; |
3066 | } | 3057 | } |
3067 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_run_thread); | 3058 | EXPORT_SYMBOL_GPL(fsg_common_run_thread); |
3068 | |||
3069 | struct fsg_common *fsg_common_init(struct fsg_common *common, | ||
3070 | struct usb_composite_dev *cdev, | ||
3071 | struct fsg_config *cfg) | ||
3072 | { | ||
3073 | int rc; | ||
3074 | |||
3075 | common = fsg_common_setup(common, !!common); | ||
3076 | if (IS_ERR(common)) | ||
3077 | return common; | ||
3078 | fsg_common_set_sysfs(common, true); | ||
3079 | common->state = FSG_STATE_IDLE; | ||
3080 | |||
3081 | rc = fsg_common_set_num_buffers(common, cfg->fsg_num_buffers); | ||
3082 | if (rc) { | ||
3083 | if (common->free_storage_on_release) | ||
3084 | kfree(common); | ||
3085 | return ERR_PTR(rc); | ||
3086 | } | ||
3087 | common->ops = cfg->ops; | ||
3088 | common->private_data = cfg->private_data; | ||
3089 | |||
3090 | rc = fsg_common_set_cdev(common, cdev, cfg->can_stall); | ||
3091 | if (rc) | ||
3092 | goto error_release; | ||
3093 | |||
3094 | rc = fsg_common_set_nluns(common, cfg->nluns); | ||
3095 | if (rc) | ||
3096 | goto error_release; | ||
3097 | |||
3098 | rc = fsg_common_create_luns(common, cfg); | ||
3099 | if (rc) | ||
3100 | goto error_release; | ||
3101 | |||
3102 | |||
3103 | fsg_common_set_inquiry_string(common, cfg->vendor_name, | ||
3104 | cfg->product_name); | ||
3105 | |||
3106 | /* Information */ | ||
3107 | INFO(common, FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n"); | ||
3108 | |||
3109 | rc = fsg_common_run_thread(common); | ||
3110 | if (rc) | ||
3111 | goto error_release; | ||
3112 | |||
3113 | return common; | ||
3114 | |||
3115 | error_release: | ||
3116 | common->state = FSG_STATE_TERMINATED; /* The thread is dead */ | ||
3117 | /* Call fsg_common_release() directly, ref might be not initialised. */ | ||
3118 | fsg_common_release(&common->ref); | ||
3119 | return ERR_PTR(rc); | ||
3120 | } | ||
3121 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_common_init); | ||
3122 | 3059 | ||
3123 | static void fsg_common_release(struct kref *ref) | 3060 | static void fsg_common_release(struct kref *ref) |
3124 | { | 3061 | { |
@@ -3166,9 +3103,8 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) | |||
3166 | struct usb_ep *ep; | 3103 | struct usb_ep *ep; |
3167 | unsigned max_burst; | 3104 | unsigned max_burst; |
3168 | int ret; | 3105 | int ret; |
3169 | |||
3170 | #ifndef USB_FMS_INCLUDED | ||
3171 | struct fsg_opts *opts; | 3106 | struct fsg_opts *opts; |
3107 | |||
3172 | opts = fsg_opts_from_func_inst(f->fi); | 3108 | opts = fsg_opts_from_func_inst(f->fi); |
3173 | if (!opts->no_configfs) { | 3109 | if (!opts->no_configfs) { |
3174 | ret = fsg_common_set_cdev(fsg->common, c->cdev, | 3110 | 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 | if (ret) | 3116 | if (ret) |
3181 | return ret; | 3117 | return ret; |
3182 | } | 3118 | } |
3183 | #endif | ||
3184 | 3119 | ||
3185 | fsg->gadget = gadget; | 3120 | fsg->gadget = gadget; |
3186 | 3121 | ||
@@ -3248,54 +3183,9 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f) | |||
3248 | wait_event(common->fsg_wait, common->fsg != fsg); | 3183 | wait_event(common->fsg_wait, common->fsg != fsg); |
3249 | } | 3184 | } |
3250 | 3185 | ||
3251 | #ifdef USB_FMS_INCLUDED | ||
3252 | fsg_common_put(common); | ||
3253 | #endif | ||
3254 | usb_free_all_descriptors(&fsg->function); | 3186 | usb_free_all_descriptors(&fsg->function); |
3255 | #ifdef USB_FMS_INCLUDED | ||
3256 | kfree(fsg); | ||
3257 | #endif | ||
3258 | } | ||
3259 | |||
3260 | #ifdef USB_FMS_INCLUDED | ||
3261 | |||
3262 | static int fsg_bind_config(struct usb_composite_dev *cdev, | ||
3263 | struct usb_configuration *c, | ||
3264 | struct fsg_common *common) | ||
3265 | { | ||
3266 | struct fsg_dev *fsg; | ||
3267 | int rc; | ||
3268 | |||
3269 | fsg = kzalloc(sizeof *fsg, GFP_KERNEL); | ||
3270 | if (unlikely(!fsg)) | ||
3271 | return -ENOMEM; | ||
3272 | |||
3273 | fsg->function.name = FSG_DRIVER_DESC; | ||
3274 | fsg->function.bind = fsg_bind; | ||
3275 | fsg->function.unbind = fsg_unbind; | ||
3276 | fsg->function.setup = fsg_setup; | ||
3277 | fsg->function.set_alt = fsg_set_alt; | ||
3278 | fsg->function.disable = fsg_disable; | ||
3279 | |||
3280 | fsg->common = common; | ||
3281 | /* | ||
3282 | * Our caller holds a reference to common structure so we | ||
3283 | * don't have to be worry about it being freed until we return | ||
3284 | * from this function. So instead of incrementing counter now | ||
3285 | * and decrement in error recovery we increment it only when | ||
3286 | * call to usb_add_function() was successful. | ||
3287 | */ | ||
3288 | |||
3289 | rc = usb_add_function(c, &fsg->function); | ||
3290 | if (unlikely(rc)) | ||
3291 | kfree(fsg); | ||
3292 | else | ||
3293 | fsg_common_get(fsg->common); | ||
3294 | return rc; | ||
3295 | } | 3187 | } |
3296 | 3188 | ||
3297 | #else | ||
3298 | |||
3299 | static inline struct fsg_lun_opts *to_fsg_lun_opts(struct config_item *item) | 3189 | static inline struct fsg_lun_opts *to_fsg_lun_opts(struct config_item *item) |
3300 | { | 3190 | { |
3301 | return container_of(to_config_group(item), struct fsg_lun_opts, group); | 3191 | 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 | return ERR_PTR(-ENOMEM); | 3542 | return ERR_PTR(-ENOMEM); |
3653 | mutex_init(&opts->lock); | 3543 | mutex_init(&opts->lock); |
3654 | opts->func_inst.free_func_inst = fsg_free_inst; | 3544 | opts->func_inst.free_func_inst = fsg_free_inst; |
3655 | opts->common = fsg_common_setup(opts->common, false); | 3545 | opts->common = fsg_common_setup(opts->common); |
3656 | if (IS_ERR(opts->common)) { | 3546 | if (IS_ERR(opts->common)) { |
3657 | rc = PTR_ERR(opts->common); | 3547 | rc = PTR_ERR(opts->common); |
3658 | goto release_opts; | 3548 | goto release_opts; |
@@ -3734,8 +3624,6 @@ DECLARE_USB_FUNCTION_INIT(mass_storage, fsg_alloc_inst, fsg_alloc); | |||
3734 | MODULE_LICENSE("GPL"); | 3624 | MODULE_LICENSE("GPL"); |
3735 | MODULE_AUTHOR("Michal Nazarewicz"); | 3625 | MODULE_AUTHOR("Michal Nazarewicz"); |
3736 | 3626 | ||
3737 | #endif | ||
3738 | |||
3739 | /************************* Module parameters *************************/ | 3627 | /************************* Module parameters *************************/ |
3740 | 3628 | ||
3741 | 3629 | ||
@@ -3771,5 +3659,5 @@ void fsg_config_from_params(struct fsg_config *cfg, | |||
3771 | cfg->can_stall = params->stall; | 3659 | cfg->can_stall = params->stall; |
3772 | cfg->fsg_num_buffers = fsg_num_buffers; | 3660 | cfg->fsg_num_buffers = fsg_num_buffers; |
3773 | } | 3661 | } |
3774 | EXPORT_SYMBOL_GPL_IF_MODULE(fsg_config_from_params); | 3662 | EXPORT_SYMBOL_GPL(fsg_config_from_params); |
3775 | 3663 | ||