Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: musb: gadget: add musb_match_ep() function

Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching
process. Function does the same that was done by chip-specific code inside
of epautoconf. Now this code can be removed from there to separate generic code
from platform specific logic.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Robert Baldyga and committed by
Felipe Balbi
26b8aa45 8cc67b7b

+34 -23
-23
drivers/usb/gadget/epautoconf.c
··· 83 83 goto found_ep; 84 84 } 85 85 86 - /* First, apply chip-specific "best usage" knowledge. 87 - * This might make a good usb_gadget_ops hook ... 88 - */ 89 - #ifdef CONFIG_BLACKFIN 90 - if (gadget_is_musbhdrc(gadget)) { 91 - if ((USB_ENDPOINT_XFER_BULK == type) || 92 - (USB_ENDPOINT_XFER_ISOC == type)) { 93 - if (USB_DIR_IN & desc->bEndpointAddress) 94 - ep = gadget_find_ep_by_name(gadget, "ep5in"); 95 - else 96 - ep = gadget_find_ep_by_name(gadget, "ep6out"); 97 - } else if (USB_ENDPOINT_XFER_INT == type) { 98 - if (USB_DIR_IN & desc->bEndpointAddress) 99 - ep = gadget_find_ep_by_name(gadget, "ep1in"); 100 - else 101 - ep = gadget_find_ep_by_name(gadget, "ep2out"); 102 - } else 103 - ep = NULL; 104 - if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) 105 - goto found_ep; 106 - } 107 - #endif 108 - 109 86 /* Second, look at endpoints until an unclaimed one looks usable */ 110 87 list_for_each_entry (ep, &gadget->ep_list, ep_list) { 111 88 if (usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
+34
drivers/usb/musb/musb_gadget.c
··· 1684 1684 return 0; 1685 1685 } 1686 1686 1687 + #ifdef CONFIG_BLACKFIN 1688 + static struct usb_ep *musb_match_ep(struct usb_gadget *g, 1689 + struct usb_endpoint_descriptor *desc, 1690 + struct usb_ss_ep_comp_descriptor *ep_comp) 1691 + { 1692 + struct usb_ep *ep = NULL; 1693 + 1694 + switch (usb_endpoint_type(desc)) { 1695 + case USB_ENDPOINT_XFER_ISOC: 1696 + case USB_ENDPOINT_XFER_BULK: 1697 + if (usb_endpoint_dir_in(desc)) 1698 + ep = gadget_find_ep_by_name(g, "ep5in"); 1699 + else 1700 + ep = gadget_find_ep_by_name(g, "ep6out"); 1701 + break; 1702 + case USB_ENDPOINT_XFER_INT: 1703 + if (usb_endpoint_dir_in(desc)) 1704 + ep = gadget_find_ep_by_name(g, "ep1in"); 1705 + else 1706 + ep = gadget_find_ep_by_name(g, "ep2out"); 1707 + break; 1708 + default: 1709 + } 1710 + 1711 + if (ep && usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) 1712 + return ep; 1713 + 1714 + return NULL; 1715 + } 1716 + #else 1717 + #define musb_match_ep NULL 1718 + #endif 1719 + 1687 1720 static int musb_gadget_start(struct usb_gadget *g, 1688 1721 struct usb_gadget_driver *driver); 1689 1722 static int musb_gadget_stop(struct usb_gadget *g); ··· 1730 1697 .pullup = musb_gadget_pullup, 1731 1698 .udc_start = musb_gadget_start, 1732 1699 .udc_stop = musb_gadget_stop, 1700 + .match_ep = musb_match_ep, 1733 1701 }; 1734 1702 1735 1703 /* ----------------------------------------------------------------------- */