diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2012-10-22 16:15:06 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-10-31 09:09:44 -0400 |
commit | 10287baec761d33f0a82d84b46e37a44030350d8 (patch) | |
tree | b769a6dddfd4ccf81a986386bf5771182d1b0c55 /drivers/usb/gadget/f_subset.c | |
parent | 0f9df939385527049c8062a099fbfa1479fe7ce0 (diff) |
usb: gadget: always update HS/SS descriptors and create a copy of them
HS and SS descriptors are staticaly created. They are updated during the
bind process with the endpoint address, string id or interface numbers.
After that, the descriptor chain is linked to struct usb_function which
is used by composite in order to serve the GET_DESCRIPTOR requests,
number of available configs and so on.
There is no need to assign the HS descriptor only if the UDC supports
HS speed because composite won't report those to the host if HS support
has not been reached. The same reasoning is valid for SS.
This patch makes sure each function updates HS/SS descriptors
unconditionally and uses the newly introduced helper function to create a
copy the descriptors for the speed which is supported by the UDC.
While at that, also rename f->descriptors to f->fs_descriptors in order
to make it more explicit what that means.
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/f_subset.c')
-rw-r--r-- | drivers/usb/gadget/f_subset.c | 48 |
1 files changed, 12 insertions, 36 deletions
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c index deb437c3b53e..856dbae586f1 100644 --- a/drivers/usb/gadget/f_subset.c +++ b/drivers/usb/gadget/f_subset.c | |||
@@ -319,38 +319,22 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) | |||
319 | geth->port.out_ep = ep; | 319 | geth->port.out_ep = ep; |
320 | ep->driver_data = cdev; /* claim */ | 320 | ep->driver_data = cdev; /* claim */ |
321 | 321 | ||
322 | /* copy descriptors, and track endpoint copies */ | ||
323 | f->descriptors = usb_copy_descriptors(fs_eth_function); | ||
324 | if (!f->descriptors) | ||
325 | goto fail; | ||
326 | |||
327 | /* support all relevant hardware speeds... we expect that when | 322 | /* support all relevant hardware speeds... we expect that when |
328 | * hardware is dual speed, all bulk-capable endpoints work at | 323 | * hardware is dual speed, all bulk-capable endpoints work at |
329 | * both speeds | 324 | * both speeds |
330 | */ | 325 | */ |
331 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 326 | hs_subset_in_desc.bEndpointAddress = fs_subset_in_desc.bEndpointAddress; |
332 | hs_subset_in_desc.bEndpointAddress = | 327 | hs_subset_out_desc.bEndpointAddress = |
333 | fs_subset_in_desc.bEndpointAddress; | 328 | fs_subset_out_desc.bEndpointAddress; |
334 | hs_subset_out_desc.bEndpointAddress = | ||
335 | fs_subset_out_desc.bEndpointAddress; | ||
336 | |||
337 | /* copy descriptors, and track endpoint copies */ | ||
338 | f->hs_descriptors = usb_copy_descriptors(hs_eth_function); | ||
339 | if (!f->hs_descriptors) | ||
340 | goto fail; | ||
341 | } | ||
342 | 329 | ||
343 | if (gadget_is_superspeed(c->cdev->gadget)) { | 330 | ss_subset_in_desc.bEndpointAddress = fs_subset_in_desc.bEndpointAddress; |
344 | ss_subset_in_desc.bEndpointAddress = | 331 | ss_subset_out_desc.bEndpointAddress = |
345 | fs_subset_in_desc.bEndpointAddress; | 332 | fs_subset_out_desc.bEndpointAddress; |
346 | ss_subset_out_desc.bEndpointAddress = | ||
347 | fs_subset_out_desc.bEndpointAddress; | ||
348 | 333 | ||
349 | /* copy descriptors, and track endpoint copies */ | 334 | status = usb_assign_descriptors(f, fs_eth_function, hs_eth_function, |
350 | f->ss_descriptors = usb_copy_descriptors(ss_eth_function); | 335 | ss_eth_function); |
351 | if (!f->ss_descriptors) | 336 | if (status) |
352 | goto fail; | 337 | goto fail; |
353 | } | ||
354 | 338 | ||
355 | /* NOTE: all that is done without knowing or caring about | 339 | /* NOTE: all that is done without knowing or caring about |
356 | * the network link ... which is unavailable to this code | 340 | * the network link ... which is unavailable to this code |
@@ -364,11 +348,7 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) | |||
364 | return 0; | 348 | return 0; |
365 | 349 | ||
366 | fail: | 350 | fail: |
367 | if (f->descriptors) | 351 | usb_free_all_descriptors(f); |
368 | usb_free_descriptors(f->descriptors); | ||
369 | if (f->hs_descriptors) | ||
370 | usb_free_descriptors(f->hs_descriptors); | ||
371 | |||
372 | /* we might as well release our claims on endpoints */ | 352 | /* we might as well release our claims on endpoints */ |
373 | if (geth->port.out_ep) | 353 | if (geth->port.out_ep) |
374 | geth->port.out_ep->driver_data = NULL; | 354 | geth->port.out_ep->driver_data = NULL; |
@@ -383,11 +363,7 @@ fail: | |||
383 | static void | 363 | static void |
384 | geth_unbind(struct usb_configuration *c, struct usb_function *f) | 364 | geth_unbind(struct usb_configuration *c, struct usb_function *f) |
385 | { | 365 | { |
386 | if (gadget_is_superspeed(c->cdev->gadget)) | 366 | usb_free_all_descriptors(f); |
387 | usb_free_descriptors(f->ss_descriptors); | ||
388 | if (gadget_is_dualspeed(c->cdev->gadget)) | ||
389 | usb_free_descriptors(f->hs_descriptors); | ||
390 | usb_free_descriptors(f->descriptors); | ||
391 | geth_string_defs[1].s = NULL; | 367 | geth_string_defs[1].s = NULL; |
392 | kfree(func_to_geth(f)); | 368 | kfree(func_to_geth(f)); |
393 | } | 369 | } |