aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_obex.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2012-10-22 16:15:06 -0400
committerFelipe Balbi <balbi@ti.com>2012-10-31 09:09:44 -0400
commit10287baec761d33f0a82d84b46e37a44030350d8 (patch)
treeb769a6dddfd4ccf81a986386bf5771182d1b0c55 /drivers/usb/gadget/f_obex.c
parent0f9df939385527049c8062a099fbfa1479fe7ce0 (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_obex.c')
-rw-r--r--drivers/usb/gadget/f_obex.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index 5f400f66aa9b..d74491ad82cb 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -331,23 +331,19 @@ obex_bind(struct usb_configuration *c, struct usb_function *f)
331 obex->port.out = ep; 331 obex->port.out = ep;
332 ep->driver_data = cdev; /* claim */ 332 ep->driver_data = cdev; /* claim */
333 333
334 /* copy descriptors, and track endpoint copies */
335 f->descriptors = usb_copy_descriptors(fs_function);
336
337 /* support all relevant hardware speeds... we expect that when 334 /* support all relevant hardware speeds... we expect that when
338 * hardware is dual speed, all bulk-capable endpoints work at 335 * hardware is dual speed, all bulk-capable endpoints work at
339 * both speeds 336 * both speeds
340 */ 337 */
341 if (gadget_is_dualspeed(c->cdev->gadget)) {
342 338
343 obex_hs_ep_in_desc.bEndpointAddress = 339 obex_hs_ep_in_desc.bEndpointAddress =
344 obex_fs_ep_in_desc.bEndpointAddress; 340 obex_fs_ep_in_desc.bEndpointAddress;
345 obex_hs_ep_out_desc.bEndpointAddress = 341 obex_hs_ep_out_desc.bEndpointAddress =
346 obex_fs_ep_out_desc.bEndpointAddress; 342 obex_fs_ep_out_desc.bEndpointAddress;
347 343
348 /* copy descriptors, and track endpoint copies */ 344 status = usb_assign_descriptors(f, fs_function, hs_function, NULL);
349 f->hs_descriptors = usb_copy_descriptors(hs_function); 345 if (status)
350 } 346 goto fail;
351 347
352 /* Avoid letting this gadget enumerate until the userspace 348 /* Avoid letting this gadget enumerate until the userspace
353 * OBEX server is active. 349 * OBEX server is active.
@@ -368,6 +364,7 @@ obex_bind(struct usb_configuration *c, struct usb_function *f)
368 return 0; 364 return 0;
369 365
370fail: 366fail:
367 usb_free_all_descriptors(f);
371 /* we might as well release our claims on endpoints */ 368 /* we might as well release our claims on endpoints */
372 if (obex->port.out) 369 if (obex->port.out)
373 obex->port.out->driver_data = NULL; 370 obex->port.out->driver_data = NULL;
@@ -382,9 +379,7 @@ fail:
382static void 379static void
383obex_unbind(struct usb_configuration *c, struct usb_function *f) 380obex_unbind(struct usb_configuration *c, struct usb_function *f)
384{ 381{
385 if (gadget_is_dualspeed(c->cdev->gadget)) 382 usb_free_all_descriptors(f);
386 usb_free_descriptors(f->hs_descriptors);
387 usb_free_descriptors(f->descriptors);
388 kfree(func_to_obex(f)); 383 kfree(func_to_obex(f));
389} 384}
390 385