diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2013-10-09 04:05:57 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-10-10 11:21:50 -0400 |
commit | a891d7a32f47118ce2ccfc8cac994aded8393fcd (patch) | |
tree | 447bbcea1c41580e7a2a6b358352ddfacab4ab3b /drivers/usb | |
parent | 70634170999a15e338b4091e06bd36ffdd283899 (diff) |
usb: gadget: f_mass_storage: create fsg_common_set_cdev for use in fsg_common_init
fsg_common_init is a lengthy function. Factor a portion of it out.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/f_mass_storage.c | 50 | ||||
-rw-r--r-- | drivers/usb/gadget/f_mass_storage.h | 3 |
2 files changed, 32 insertions, 21 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index cb789fa885fd..e61c0667b53a 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -2810,6 +2810,33 @@ int fsg_common_set_nluns(struct fsg_common *common, int nluns) | |||
2810 | return 0; | 2810 | return 0; |
2811 | } | 2811 | } |
2812 | 2812 | ||
2813 | int fsg_common_set_cdev(struct fsg_common *common, | ||
2814 | struct usb_composite_dev *cdev, bool can_stall) | ||
2815 | { | ||
2816 | struct usb_string *us; | ||
2817 | |||
2818 | common->gadget = cdev->gadget; | ||
2819 | common->ep0 = cdev->gadget->ep0; | ||
2820 | common->ep0req = cdev->req; | ||
2821 | common->cdev = cdev; | ||
2822 | |||
2823 | us = usb_gstrings_attach(cdev, fsg_strings_array, | ||
2824 | ARRAY_SIZE(fsg_strings)); | ||
2825 | if (IS_ERR(us)) | ||
2826 | return PTR_ERR(us); | ||
2827 | |||
2828 | fsg_intf_desc.iInterface = us[FSG_STRING_INTERFACE].id; | ||
2829 | |||
2830 | /* | ||
2831 | * Some peripheral controllers are known not to be able to | ||
2832 | * halt bulk endpoints correctly. If one of them is present, | ||
2833 | * disable stalls. | ||
2834 | */ | ||
2835 | common->can_stall = can_stall && !(gadget_is_at91(common->gadget)); | ||
2836 | |||
2837 | return 0; | ||
2838 | } | ||
2839 | |||
2813 | struct fsg_common *fsg_common_init(struct fsg_common *common, | 2840 | struct fsg_common *fsg_common_init(struct fsg_common *common, |
2814 | struct usb_composite_dev *cdev, | 2841 | struct usb_composite_dev *cdev, |
2815 | struct fsg_config *cfg) | 2842 | struct fsg_config *cfg) |
@@ -2817,7 +2844,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, | |||
2817 | struct usb_gadget *gadget = cdev->gadget; | 2844 | struct usb_gadget *gadget = cdev->gadget; |
2818 | struct fsg_lun **curlun_it; | 2845 | struct fsg_lun **curlun_it; |
2819 | struct fsg_lun_config *lcfg; | 2846 | struct fsg_lun_config *lcfg; |
2820 | struct usb_string *us; | ||
2821 | int nluns, i, rc; | 2847 | int nluns, i, rc; |
2822 | char *pathbuf; | 2848 | char *pathbuf; |
2823 | 2849 | ||
@@ -2837,19 +2863,9 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, | |||
2837 | common->ops = cfg->ops; | 2863 | common->ops = cfg->ops; |
2838 | common->private_data = cfg->private_data; | 2864 | common->private_data = cfg->private_data; |
2839 | 2865 | ||
2840 | common->gadget = gadget; | 2866 | rc = fsg_common_set_cdev(common, cdev, cfg->can_stall); |
2841 | common->ep0 = gadget->ep0; | 2867 | if (rc) |
2842 | common->ep0req = cdev->req; | ||
2843 | common->cdev = cdev; | ||
2844 | |||
2845 | us = usb_gstrings_attach(cdev, fsg_strings_array, | ||
2846 | ARRAY_SIZE(fsg_strings)); | ||
2847 | if (IS_ERR(us)) { | ||
2848 | rc = PTR_ERR(us); | ||
2849 | goto error_release; | 2868 | goto error_release; |
2850 | } | ||
2851 | fsg_intf_desc.iInterface = us[FSG_STRING_INTERFACE].id; | ||
2852 | |||
2853 | 2869 | ||
2854 | rc = fsg_common_set_nluns(common, cfg->nluns); | 2870 | rc = fsg_common_set_nluns(common, cfg->nluns); |
2855 | if (rc) | 2871 | if (rc) |
@@ -2925,14 +2941,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, | |||
2925 | : "File-Stor Gadget"), | 2941 | : "File-Stor Gadget"), |
2926 | i); | 2942 | i); |
2927 | 2943 | ||
2928 | /* | ||
2929 | * Some peripheral controllers are known not to be able to | ||
2930 | * halt bulk endpoints correctly. If one of them is present, | ||
2931 | * disable stalls. | ||
2932 | */ | ||
2933 | common->can_stall = cfg->can_stall && | ||
2934 | !(gadget_is_at91(common->gadget)); | ||
2935 | |||
2936 | 2944 | ||
2937 | /* Tell the thread to start working */ | 2945 | /* Tell the thread to start working */ |
2938 | common->thread_task = | 2946 | common->thread_task = |
diff --git a/drivers/usb/gadget/f_mass_storage.h b/drivers/usb/gadget/f_mass_storage.h index f98c792f36b0..de7aa32565b4 100644 --- a/drivers/usb/gadget/f_mass_storage.h +++ b/drivers/usb/gadget/f_mass_storage.h | |||
@@ -106,6 +106,9 @@ void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs); | |||
106 | 106 | ||
107 | int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n); | 107 | int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n); |
108 | 108 | ||
109 | int fsg_common_set_cdev(struct fsg_common *common, | ||
110 | struct usb_composite_dev *cdev, bool can_stall); | ||
111 | |||
109 | void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs); | 112 | void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs); |
110 | 113 | ||
111 | void fsg_common_remove_luns(struct fsg_common *common); | 114 | void fsg_common_remove_luns(struct fsg_common *common); |