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

usb: gadget: goku_udc: add goku_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.

[ balbi@ti.com : fix build breakage ]

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
8cc67b7b 3e8b2318

+32 -18
+2 -18
drivers/usb/gadget/epautoconf.c
··· 86 86 /* First, apply chip-specific "best usage" knowledge. 87 87 * This might make a good usb_gadget_ops hook ... 88 88 */ 89 - if (gadget_is_goku(gadget)) { 90 - if (USB_ENDPOINT_XFER_INT == type) { 91 - /* single buffering is enough */ 92 - ep = gadget_find_ep_by_name(gadget, "ep3-bulk"); 93 - if (ep && usb_gadget_ep_match_desc(gadget, 94 - ep, desc, ep_comp)) 95 - goto found_ep; 96 - } else if (USB_ENDPOINT_XFER_BULK == type 97 - && (USB_DIR_IN & desc->bEndpointAddress)) { 98 - /* DMA may be available */ 99 - ep = gadget_find_ep_by_name(gadget, "ep2-bulk"); 100 - if (ep && usb_gadget_ep_match_desc(gadget, 101 - ep, desc, ep_comp)) 102 - goto found_ep; 103 - } 104 - 105 89 #ifdef CONFIG_BLACKFIN 106 - } else if (gadget_is_musbhdrc(gadget)) { 90 + if (gadget_is_musbhdrc(gadget)) { 107 91 if ((USB_ENDPOINT_XFER_BULK == type) || 108 92 (USB_ENDPOINT_XFER_ISOC == type)) { 109 93 if (USB_DIR_IN & desc->bEndpointAddress) ··· 103 119 ep = NULL; 104 120 if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) 105 121 goto found_ep; 106 - #endif 107 122 } 123 + #endif 108 124 109 125 /* Second, look at endpoints until an unclaimed one looks usable */ 110 126 list_for_each_entry (ep, &gadget->ep_list, ep_list) {
+30
drivers/usb/gadget/udc/goku_udc.c
··· 990 990 return -EOPNOTSUPP; 991 991 } 992 992 993 + static struct usb_ep *goku_match_ep(struct usb_gadget *g, 994 + struct usb_endpoint_descriptor *desc, 995 + struct usb_ss_ep_comp_descriptor *ep_comp) 996 + { 997 + struct goku_udc *dev = to_goku_udc(g); 998 + struct usb_ep *ep; 999 + 1000 + switch (usb_endpoint_type(desc)) { 1001 + case USB_ENDPOINT_XFER_INT: 1002 + /* single buffering is enough */ 1003 + ep = &dev->ep[3].ep; 1004 + if (usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) 1005 + return ep; 1006 + break; 1007 + case USB_ENDPOINT_XFER_BULK: 1008 + if (usb_endpoint_dir_in(desc)) { 1009 + /* DMA may be available */ 1010 + ep = &dev->ep[2].ep; 1011 + if (usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) 1012 + return ep; 1013 + } 1014 + break; 1015 + default: 1016 + /* nothing */ ; 1017 + } 1018 + 1019 + return NULL; 1020 + } 1021 + 993 1022 static int goku_udc_start(struct usb_gadget *g, 994 1023 struct usb_gadget_driver *driver); 995 1024 static int goku_udc_stop(struct usb_gadget *g); ··· 1027 998 .get_frame = goku_get_frame, 1028 999 .udc_start = goku_udc_start, 1029 1000 .udc_stop = goku_udc_stop, 1001 + .match_ep = goku_match_ep, 1030 1002 // no remote wakeup 1031 1003 // not selfpowered 1032 1004 };