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

usb: gadget: net2280: add net2280_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
3e8b2318 b0aea003

+29 -22
+1 -22
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_net2280(gadget)) { 90 - char name[8]; 91 - 92 - if (type == USB_ENDPOINT_XFER_INT) { 93 - /* ep-e, ep-f are PIO with only 64 byte fifos */ 94 - ep = gadget_find_ep_by_name(gadget, "ep-e"); 95 - if (ep && usb_gadget_ep_match_desc(gadget, 96 - ep, desc, ep_comp)) 97 - goto found_ep; 98 - ep = gadget_find_ep_by_name(gadget, "ep-f"); 99 - if (ep && usb_gadget_ep_match_desc(gadget, 100 - ep, desc, ep_comp)) 101 - goto found_ep; 102 - } 103 - 104 - /* USB3380: use same address for usb and hardware endpoints */ 105 - snprintf(name, sizeof(name), "ep%d%s", usb_endpoint_num(desc), 106 - usb_endpoint_dir_in(desc) ? "in" : "out"); 107 - ep = gadget_find_ep_by_name(gadget, name); 108 - if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) 109 - goto found_ep; 110 - } else if (gadget_is_goku (gadget)) { 89 + if (gadget_is_goku(gadget)) { 111 90 if (USB_ENDPOINT_XFER_INT == type) { 112 91 /* single buffering is enough */ 113 92 ep = gadget_find_ep_by_name(gadget, "ep3-bulk");
+28
drivers/usb/gadget/udc/net2280.c
··· 1550 1550 return 0; 1551 1551 } 1552 1552 1553 + static struct usb_ep *net2280_match_ep(struct usb_gadget *_gadget, 1554 + struct usb_endpoint_descriptor *desc, 1555 + struct usb_ss_ep_comp_descriptor *ep_comp) 1556 + { 1557 + char name[8]; 1558 + struct usb_ep *ep; 1559 + 1560 + if (usb_endpoint_type(desc) == USB_ENDPOINT_XFER_INT) { 1561 + /* ep-e, ep-f are PIO with only 64 byte fifos */ 1562 + ep = gadget_find_ep_by_name(_gadget, "ep-e"); 1563 + if (ep && usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp)) 1564 + return ep; 1565 + ep = gadget_find_ep_by_name(_gadget, "ep-f"); 1566 + if (ep && usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp)) 1567 + return ep; 1568 + } 1569 + 1570 + /* USB3380: use same address for usb and hardware endpoints */ 1571 + snprintf(name, sizeof(name), "ep%d%s", usb_endpoint_num(desc), 1572 + usb_endpoint_dir_in(desc) ? "in" : "out"); 1573 + ep = gadget_find_ep_by_name(_gadget, name); 1574 + if (ep && usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp)) 1575 + return ep; 1576 + 1577 + return NULL; 1578 + } 1579 + 1553 1580 static int net2280_start(struct usb_gadget *_gadget, 1554 1581 struct usb_gadget_driver *driver); 1555 1582 static int net2280_stop(struct usb_gadget *_gadget); ··· 1588 1561 .pullup = net2280_pullup, 1589 1562 .udc_start = net2280_start, 1590 1563 .udc_stop = net2280_stop, 1564 + .match_ep = net2280_match_ep, 1591 1565 }; 1592 1566 1593 1567 /*-------------------------------------------------------------------------*/