aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_sourcesink.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/f_sourcesink.c')
-rw-r--r--drivers/usb/gadget/f_sourcesink.c104
1 files changed, 49 insertions, 55 deletions
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c
index 3c126fde6e7e..102d49beb9df 100644
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -319,6 +319,7 @@ sourcesink_bind(struct usb_configuration *c, struct usb_function *f)
319 struct usb_composite_dev *cdev = c->cdev; 319 struct usb_composite_dev *cdev = c->cdev;
320 struct f_sourcesink *ss = func_to_ss(f); 320 struct f_sourcesink *ss = func_to_ss(f);
321 int id; 321 int id;
322 int ret;
322 323
323 /* allocate interface ID(s) */ 324 /* allocate interface ID(s) */
324 id = usb_interface_id(c, f); 325 id = usb_interface_id(c, f);
@@ -387,64 +388,57 @@ no_iso:
387 isoc_maxpacket = 1024; 388 isoc_maxpacket = 1024;
388 389
389 /* support high speed hardware */ 390 /* support high speed hardware */
390 if (gadget_is_dualspeed(c->cdev->gadget)) { 391 hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress;
391 hs_source_desc.bEndpointAddress = 392 hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress;
392 fs_source_desc.bEndpointAddress;
393 hs_sink_desc.bEndpointAddress =
394 fs_sink_desc.bEndpointAddress;
395 393
396 /* 394 /*
397 * Fill in the HS isoc descriptors from the module parameters. 395 * Fill in the HS isoc descriptors from the module parameters.
398 * We assume that the user knows what they are doing and won't 396 * We assume that the user knows what they are doing and won't
399 * give parameters that their UDC doesn't support. 397 * give parameters that their UDC doesn't support.
400 */ 398 */
401 hs_iso_source_desc.wMaxPacketSize = isoc_maxpacket; 399 hs_iso_source_desc.wMaxPacketSize = isoc_maxpacket;
402 hs_iso_source_desc.wMaxPacketSize |= isoc_mult << 11; 400 hs_iso_source_desc.wMaxPacketSize |= isoc_mult << 11;
403 hs_iso_source_desc.bInterval = isoc_interval; 401 hs_iso_source_desc.bInterval = isoc_interval;
404 hs_iso_source_desc.bEndpointAddress = 402 hs_iso_source_desc.bEndpointAddress =
405 fs_iso_source_desc.bEndpointAddress; 403 fs_iso_source_desc.bEndpointAddress;
406 404
407 hs_iso_sink_desc.wMaxPacketSize = isoc_maxpacket; 405 hs_iso_sink_desc.wMaxPacketSize = isoc_maxpacket;
408 hs_iso_sink_desc.wMaxPacketSize |= isoc_mult << 11; 406 hs_iso_sink_desc.wMaxPacketSize |= isoc_mult << 11;
409 hs_iso_sink_desc.bInterval = isoc_interval; 407 hs_iso_sink_desc.bInterval = isoc_interval;
410 hs_iso_sink_desc.bEndpointAddress = 408 hs_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress;
411 fs_iso_sink_desc.bEndpointAddress;
412
413 f->hs_descriptors = hs_source_sink_descs;
414 }
415 409
416 /* support super speed hardware */ 410 /* support super speed hardware */
417 if (gadget_is_superspeed(c->cdev->gadget)) { 411 ss_source_desc.bEndpointAddress =
418 ss_source_desc.bEndpointAddress = 412 fs_source_desc.bEndpointAddress;
419 fs_source_desc.bEndpointAddress; 413 ss_sink_desc.bEndpointAddress =
420 ss_sink_desc.bEndpointAddress = 414 fs_sink_desc.bEndpointAddress;
421 fs_sink_desc.bEndpointAddress;
422 415
423 /* 416 /*
424 * Fill in the SS isoc descriptors from the module parameters. 417 * Fill in the SS isoc descriptors from the module parameters.
425 * We assume that the user knows what they are doing and won't 418 * We assume that the user knows what they are doing and won't
426 * give parameters that their UDC doesn't support. 419 * give parameters that their UDC doesn't support.
427 */ 420 */
428 ss_iso_source_desc.wMaxPacketSize = isoc_maxpacket; 421 ss_iso_source_desc.wMaxPacketSize = isoc_maxpacket;
429 ss_iso_source_desc.bInterval = isoc_interval; 422 ss_iso_source_desc.bInterval = isoc_interval;
430 ss_iso_source_comp_desc.bmAttributes = isoc_mult; 423 ss_iso_source_comp_desc.bmAttributes = isoc_mult;
431 ss_iso_source_comp_desc.bMaxBurst = isoc_maxburst; 424 ss_iso_source_comp_desc.bMaxBurst = isoc_maxburst;
432 ss_iso_source_comp_desc.wBytesPerInterval = 425 ss_iso_source_comp_desc.wBytesPerInterval =
433 isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); 426 isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1);
434 ss_iso_source_desc.bEndpointAddress = 427 ss_iso_source_desc.bEndpointAddress =
435 fs_iso_source_desc.bEndpointAddress; 428 fs_iso_source_desc.bEndpointAddress;
436 429
437 ss_iso_sink_desc.wMaxPacketSize = isoc_maxpacket; 430 ss_iso_sink_desc.wMaxPacketSize = isoc_maxpacket;
438 ss_iso_sink_desc.bInterval = isoc_interval; 431 ss_iso_sink_desc.bInterval = isoc_interval;
439 ss_iso_sink_comp_desc.bmAttributes = isoc_mult; 432 ss_iso_sink_comp_desc.bmAttributes = isoc_mult;
440 ss_iso_sink_comp_desc.bMaxBurst = isoc_maxburst; 433 ss_iso_sink_comp_desc.bMaxBurst = isoc_maxburst;
441 ss_iso_sink_comp_desc.wBytesPerInterval = 434 ss_iso_sink_comp_desc.wBytesPerInterval =
442 isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); 435 isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1);
443 ss_iso_sink_desc.bEndpointAddress = 436 ss_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress;
444 fs_iso_sink_desc.bEndpointAddress; 437
445 438 ret = usb_assign_descriptors(f, fs_source_sink_descs,
446 f->ss_descriptors = ss_source_sink_descs; 439 hs_source_sink_descs, ss_source_sink_descs);
447 } 440 if (ret)
441 return ret;
448 442
449 DBG(cdev, "%s speed %s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s\n", 443 DBG(cdev, "%s speed %s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s\n",
450 (gadget_is_superspeed(c->cdev->gadget) ? "super" : 444 (gadget_is_superspeed(c->cdev->gadget) ? "super" :
@@ -458,6 +452,7 @@ no_iso:
458static void 452static void
459sourcesink_unbind(struct usb_configuration *c, struct usb_function *f) 453sourcesink_unbind(struct usb_configuration *c, struct usb_function *f)
460{ 454{
455 usb_free_all_descriptors(f);
461 kfree(func_to_ss(f)); 456 kfree(func_to_ss(f));
462} 457}
463 458
@@ -773,7 +768,6 @@ static int __init sourcesink_bind_config(struct usb_configuration *c)
773 return -ENOMEM; 768 return -ENOMEM;
774 769
775 ss->function.name = "source/sink"; 770 ss->function.name = "source/sink";
776 ss->function.descriptors = fs_source_sink_descs;
777 ss->function.bind = sourcesink_bind; 771 ss->function.bind = sourcesink_bind;
778 ss->function.unbind = sourcesink_unbind; 772 ss->function.unbind = sourcesink_unbind;
779 ss->function.set_alt = sourcesink_set_alt; 773 ss->function.set_alt = sourcesink_set_alt;