aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_mass_storage.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/f_mass_storage.c')
-rw-r--r--drivers/usb/gadget/f_mass_storage.c63
1 files changed, 20 insertions, 43 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 3a7668bde3ef..5d027b3e1ef0 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -228,10 +228,6 @@
228 228
229static const char fsg_string_interface[] = "Mass Storage"; 229static const char fsg_string_interface[] = "Mass Storage";
230 230
231#define FSG_NO_DEVICE_STRINGS 1
232#define FSG_NO_OTG 1
233#define FSG_NO_INTR_EP 1
234
235#include "storage_common.c" 231#include "storage_common.c"
236 232
237 233
@@ -2904,9 +2900,7 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f)
2904 } 2900 }
2905 2901
2906 fsg_common_put(common); 2902 fsg_common_put(common);
2907 usb_free_descriptors(fsg->function.descriptors); 2903 usb_free_all_descriptors(&fsg->function);
2908 usb_free_descriptors(fsg->function.hs_descriptors);
2909 usb_free_descriptors(fsg->function.ss_descriptors);
2910 kfree(fsg); 2904 kfree(fsg);
2911} 2905}
2912 2906
@@ -2916,6 +2910,8 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
2916 struct usb_gadget *gadget = c->cdev->gadget; 2910 struct usb_gadget *gadget = c->cdev->gadget;
2917 int i; 2911 int i;
2918 struct usb_ep *ep; 2912 struct usb_ep *ep;
2913 unsigned max_burst;
2914 int ret;
2919 2915
2920 fsg->gadget = gadget; 2916 fsg->gadget = gadget;
2921 2917
@@ -2939,45 +2935,27 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
2939 ep->driver_data = fsg->common; /* claim the endpoint */ 2935 ep->driver_data = fsg->common; /* claim the endpoint */
2940 fsg->bulk_out = ep; 2936 fsg->bulk_out = ep;
2941 2937
2942 /* Copy descriptors */ 2938 /* Assume endpoint addresses are the same for both speeds */
2943 f->descriptors = usb_copy_descriptors(fsg_fs_function); 2939 fsg_hs_bulk_in_desc.bEndpointAddress =
2944 if (unlikely(!f->descriptors)) 2940 fsg_fs_bulk_in_desc.bEndpointAddress;
2945 return -ENOMEM; 2941 fsg_hs_bulk_out_desc.bEndpointAddress =
2946 2942 fsg_fs_bulk_out_desc.bEndpointAddress;
2947 if (gadget_is_dualspeed(gadget)) {
2948 /* Assume endpoint addresses are the same for both speeds */
2949 fsg_hs_bulk_in_desc.bEndpointAddress =
2950 fsg_fs_bulk_in_desc.bEndpointAddress;
2951 fsg_hs_bulk_out_desc.bEndpointAddress =
2952 fsg_fs_bulk_out_desc.bEndpointAddress;
2953 f->hs_descriptors = usb_copy_descriptors(fsg_hs_function);
2954 if (unlikely(!f->hs_descriptors)) {
2955 usb_free_descriptors(f->descriptors);
2956 return -ENOMEM;
2957 }
2958 }
2959
2960 if (gadget_is_superspeed(gadget)) {
2961 unsigned max_burst;
2962 2943
2963 /* Calculate bMaxBurst, we know packet size is 1024 */ 2944 /* Calculate bMaxBurst, we know packet size is 1024 */
2964 max_burst = min_t(unsigned, FSG_BUFLEN / 1024, 15); 2945 max_burst = min_t(unsigned, FSG_BUFLEN / 1024, 15);
2965 2946
2966 fsg_ss_bulk_in_desc.bEndpointAddress = 2947 fsg_ss_bulk_in_desc.bEndpointAddress =
2967 fsg_fs_bulk_in_desc.bEndpointAddress; 2948 fsg_fs_bulk_in_desc.bEndpointAddress;
2968 fsg_ss_bulk_in_comp_desc.bMaxBurst = max_burst; 2949 fsg_ss_bulk_in_comp_desc.bMaxBurst = max_burst;
2969 2950
2970 fsg_ss_bulk_out_desc.bEndpointAddress = 2951 fsg_ss_bulk_out_desc.bEndpointAddress =
2971 fsg_fs_bulk_out_desc.bEndpointAddress; 2952 fsg_fs_bulk_out_desc.bEndpointAddress;
2972 fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst; 2953 fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst;
2973 2954
2974 f->ss_descriptors = usb_copy_descriptors(fsg_ss_function); 2955 ret = usb_assign_descriptors(f, fsg_fs_function, fsg_hs_function,
2975 if (unlikely(!f->ss_descriptors)) { 2956 fsg_ss_function);
2976 usb_free_descriptors(f->hs_descriptors); 2957 if (ret)
2977 usb_free_descriptors(f->descriptors); 2958 goto autoconf_fail;
2978 return -ENOMEM;
2979 }
2980 }
2981 2959
2982 return 0; 2960 return 0;
2983 2961
@@ -2986,7 +2964,6 @@ autoconf_fail:
2986 return -ENOTSUPP; 2964 return -ENOTSUPP;
2987} 2965}
2988 2966
2989
2990/****************************** ADD FUNCTION ******************************/ 2967/****************************** ADD FUNCTION ******************************/
2991 2968
2992static struct usb_gadget_strings *fsg_strings_array[] = { 2969static struct usb_gadget_strings *fsg_strings_array[] = {