diff options
Diffstat (limited to 'drivers/usb/gadget/f_eem.c')
-rw-r--r-- | drivers/usb/gadget/f_eem.c | 51 |
1 files changed, 12 insertions, 39 deletions
diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c index 1a7b2dd7d408..cf0ebee85563 100644 --- a/drivers/usb/gadget/f_eem.c +++ b/drivers/usb/gadget/f_eem.c | |||
@@ -274,38 +274,20 @@ eem_bind(struct usb_configuration *c, struct usb_function *f) | |||
274 | 274 | ||
275 | status = -ENOMEM; | 275 | status = -ENOMEM; |
276 | 276 | ||
277 | /* copy descriptors, and track endpoint copies */ | ||
278 | f->descriptors = usb_copy_descriptors(eem_fs_function); | ||
279 | if (!f->descriptors) | ||
280 | goto fail; | ||
281 | |||
282 | /* support all relevant hardware speeds... we expect that when | 277 | /* support all relevant hardware speeds... we expect that when |
283 | * hardware is dual speed, all bulk-capable endpoints work at | 278 | * hardware is dual speed, all bulk-capable endpoints work at |
284 | * both speeds | 279 | * both speeds |
285 | */ | 280 | */ |
286 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 281 | eem_hs_in_desc.bEndpointAddress = eem_fs_in_desc.bEndpointAddress; |
287 | eem_hs_in_desc.bEndpointAddress = | 282 | eem_hs_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress; |
288 | eem_fs_in_desc.bEndpointAddress; | ||
289 | eem_hs_out_desc.bEndpointAddress = | ||
290 | eem_fs_out_desc.bEndpointAddress; | ||
291 | |||
292 | /* copy descriptors, and track endpoint copies */ | ||
293 | f->hs_descriptors = usb_copy_descriptors(eem_hs_function); | ||
294 | if (!f->hs_descriptors) | ||
295 | goto fail; | ||
296 | } | ||
297 | 283 | ||
298 | if (gadget_is_superspeed(c->cdev->gadget)) { | 284 | eem_ss_in_desc.bEndpointAddress = eem_fs_in_desc.bEndpointAddress; |
299 | eem_ss_in_desc.bEndpointAddress = | 285 | eem_ss_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress; |
300 | eem_fs_in_desc.bEndpointAddress; | ||
301 | eem_ss_out_desc.bEndpointAddress = | ||
302 | eem_fs_out_desc.bEndpointAddress; | ||
303 | 286 | ||
304 | /* copy descriptors, and track endpoint copies */ | 287 | status = usb_assign_descriptors(f, eem_fs_function, eem_hs_function, |
305 | f->ss_descriptors = usb_copy_descriptors(eem_ss_function); | 288 | eem_ss_function); |
306 | if (!f->ss_descriptors) | 289 | if (status) |
307 | goto fail; | 290 | goto fail; |
308 | } | ||
309 | 291 | ||
310 | DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n", | 292 | DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n", |
311 | gadget_is_superspeed(c->cdev->gadget) ? "super" : | 293 | gadget_is_superspeed(c->cdev->gadget) ? "super" : |
@@ -314,15 +296,10 @@ eem_bind(struct usb_configuration *c, struct usb_function *f) | |||
314 | return 0; | 296 | return 0; |
315 | 297 | ||
316 | fail: | 298 | fail: |
317 | if (f->descriptors) | 299 | usb_free_all_descriptors(f); |
318 | usb_free_descriptors(f->descriptors); | 300 | if (eem->port.out_ep) |
319 | if (f->hs_descriptors) | ||
320 | usb_free_descriptors(f->hs_descriptors); | ||
321 | |||
322 | /* we might as well release our claims on endpoints */ | ||
323 | if (eem->port.out_ep->desc) | ||
324 | eem->port.out_ep->driver_data = NULL; | 301 | eem->port.out_ep->driver_data = NULL; |
325 | if (eem->port.in_ep->desc) | 302 | if (eem->port.in_ep) |
326 | eem->port.in_ep->driver_data = NULL; | 303 | eem->port.in_ep->driver_data = NULL; |
327 | 304 | ||
328 | ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); | 305 | ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); |
@@ -337,11 +314,7 @@ eem_unbind(struct usb_configuration *c, struct usb_function *f) | |||
337 | 314 | ||
338 | DBG(c->cdev, "eem unbind\n"); | 315 | DBG(c->cdev, "eem unbind\n"); |
339 | 316 | ||
340 | if (gadget_is_superspeed(c->cdev->gadget)) | 317 | usb_free_all_descriptors(f); |
341 | usb_free_descriptors(f->ss_descriptors); | ||
342 | if (gadget_is_dualspeed(c->cdev->gadget)) | ||
343 | usb_free_descriptors(f->hs_descriptors); | ||
344 | usb_free_descriptors(f->descriptors); | ||
345 | kfree(eem); | 318 | kfree(eem); |
346 | } | 319 | } |
347 | 320 | ||