diff options
Diffstat (limited to 'drivers/usb/gadget/config.c')
-rw-r--r-- | drivers/usb/gadget/config.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index e3a98929d346..34e12fc52c23 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c | |||
@@ -19,7 +19,7 @@ | |||
19 | 19 | ||
20 | #include <linux/usb/ch9.h> | 20 | #include <linux/usb/ch9.h> |
21 | #include <linux/usb/gadget.h> | 21 | #include <linux/usb/gadget.h> |
22 | 22 | #include <linux/usb/composite.h> | |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * usb_descriptor_fillbuf - fill buffer with descriptors | 25 | * usb_descriptor_fillbuf - fill buffer with descriptors |
@@ -158,3 +158,40 @@ usb_copy_descriptors(struct usb_descriptor_header **src) | |||
158 | return ret; | 158 | return ret; |
159 | } | 159 | } |
160 | EXPORT_SYMBOL_GPL(usb_copy_descriptors); | 160 | EXPORT_SYMBOL_GPL(usb_copy_descriptors); |
161 | |||
162 | int usb_assign_descriptors(struct usb_function *f, | ||
163 | struct usb_descriptor_header **fs, | ||
164 | struct usb_descriptor_header **hs, | ||
165 | struct usb_descriptor_header **ss) | ||
166 | { | ||
167 | struct usb_gadget *g = f->config->cdev->gadget; | ||
168 | |||
169 | if (fs) { | ||
170 | f->fs_descriptors = usb_copy_descriptors(fs); | ||
171 | if (!f->fs_descriptors) | ||
172 | goto err; | ||
173 | } | ||
174 | if (hs && gadget_is_dualspeed(g)) { | ||
175 | f->hs_descriptors = usb_copy_descriptors(hs); | ||
176 | if (!f->hs_descriptors) | ||
177 | goto err; | ||
178 | } | ||
179 | if (ss && gadget_is_superspeed(g)) { | ||
180 | f->ss_descriptors = usb_copy_descriptors(ss); | ||
181 | if (!f->ss_descriptors) | ||
182 | goto err; | ||
183 | } | ||
184 | return 0; | ||
185 | err: | ||
186 | usb_free_all_descriptors(f); | ||
187 | return -ENOMEM; | ||
188 | } | ||
189 | EXPORT_SYMBOL_GPL(usb_assign_descriptors); | ||
190 | |||
191 | void usb_free_all_descriptors(struct usb_function *f) | ||
192 | { | ||
193 | usb_free_descriptors(f->fs_descriptors); | ||
194 | usb_free_descriptors(f->hs_descriptors); | ||
195 | usb_free_descriptors(f->ss_descriptors); | ||
196 | } | ||
197 | EXPORT_SYMBOL_GPL(usb_free_all_descriptors); | ||