summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/ether.c
AgeCommit message (Collapse)Author
2010-10-27Coding Style cleanupWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de>
2010-10-13USB-CDC: Prevent rx_req being enqueued twiceVitaly Kuzmichev
After gadget reinitializaton (after tftp has been done once) packet_received may become equal to 1 due to nuking OUT_EP while disabling it in eth_reset_config. rx_submit called from usb_eth_init queues rx_req first time. But the first call of usb_eth_recv from NetLoop queues rx_req again due to packet_received = 1. The following flow shows the path of functions calls when this happens: net/net.c:NetLoop | +-net/eth.c:eth_init | ether.c:usb_eth_init | | | +-udc_driver:usb_gadget_handle_interrupts | | udc_driver:... | | ether.c:eth_setup | | ether.c:eth_set_config | | ether.c:eth_reset_config | | udc_driver:usb_ep_disable | | udc_driver:nuke | | ether.c:rx_complete | | ether.c: packet_received = 1; | | | +-ether.c:rx_submit | udc_driver:usb_ep_queue --- The first time when rx_req is queued | +-net/eth.c:eth_rx ether.c:usb_eth_recv | +-udc_driver:usb_gadget_handle_interrupts | udc_driver:... --- no interrupts, returning +-ether.c: if (packet_received) { ... ether.c:rx_submit udc_driver:usb_ep_queue --- The second time! Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
2010-10-13USB-CDC: Fix tx/rx_req memory leaksVitaly Kuzmichev
Remove and fix needless and destructive operations with tx/rx_req. 1) 'req' in rx_complete is always not NULL and always equals to rx_req 2) Free allocated tx_req if rx_req allocation has failed 3) Do not zero out tx/rx_req in usb_eth_init, leave this for eth_reset_config which will be called at the next use of usb0 4) Additional check in usb_eth_recv is not required Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
2010-09-20USB-CDC: Fix coding style issuesVitaly Kuzmichev
Fixes most of checkpatch warnings and errors in USB gadget stack. The most frequently encountered problems are: 1) "(foo*)", "foo * bar", "foo* bar" 2) C99 // comments 3) No spaces before/after/around '?', ':', '=', '==', ',', '&', '(' 4) Spaces before '[' 5) Spaces between function names and '(' 6) Block braces in wrong places 7) Spaces before tabs 8) Macros with complex values not enclosed in parenthesis 9) Multiline comments start just after /* Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
2010-09-20USB-CDC: called handle_interrupts inside usb_eth_sendStefano Babic
The patch removes an endless loop in the usb_eth_send if the tx_complete is not called before going in the loop. The driver interrupt routine is called allowing the driver to check if the TX is completed. Signed-off-by: Stefano Babic <sbabic@denx.de>
2010-09-20USB-CDC: correct wrong alignment in ether.cStefano Babic
The buffer for the status request must be word aligned because it is accessed with 32 bit pointer in the eth_status_complete function. Signed-off-by: Stefano Babic <sbabic@denx.de>
2010-09-20USB-CDC: ethernet error path potential oops fixVitaly Kuzmichev
Fix potential oops on rare error path. The patch is based on commit e7b13ec9235b9fded90f826ceeb8c34548631351 (done by David Brownell <david-b@pacbell.net>) from linux-2.6.git. Description of the issue taken from linux kernel bugzilla: (https://bugzilla.kernel.org/show_bug.cgi?id=9594) The potential error can be tracked down as follows: (1) line 807: let the second conjunct on the "if" statment be false meaning "dev->status_ep" is null. This means the "if" evaluates to false. follow thru the code until... (2) line 808: usb_ep_disable(dev->status_ep) passes in a null argument, however "usb_ep_disable" cannot handle that: (from include/linux/usb/gadget.h) 191 static inline int 192 usb_ep_disable (struct usb_ep *ep) 193 { 194 return ep->ops->disable (ep); 195 } -- Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
2010-09-20USB-CDC: Correct stat_req initializationVitaly Kuzmichev
Fix possible oops on stat_req->buf initialization and fix ep0 and status_ep confusion (last one is just intended for stat_req keeping). Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com> Signed-off-by: Stefano Babic <sbabic@denx.de>
2010-09-20USB-CDC: Replace 'strcpy' by 'strlcpy'Vitaly Kuzmichev
Replace 'strcpy' by more safe 'strlcpy' that is implemented in ether.c Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
2010-09-20USB-CDC: Correct freeing usb requestsVitaly Kuzmichev
Fix in_ep and out_ep confusion (rx_req was allocated from out_ep, not from in_ep) and add lost dev->req freeing. Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
2010-09-20USB-CDC: Use native debug printout macrosVitaly Kuzmichev
Replace Linux-like debug printout macros by native ones. Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com> Applied after removing dead code like '#define DEBUG/#undef DEBUG'
2010-09-20USB-CDC: Add lost 'qmult' definitionVitaly Kuzmichev
Add lost 'qmult' definition for High Speed devices and make it configurable through CONFIG_USB_ETH_QMULT. Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
2010-09-20Integrate USB gadget layer and USB CDC driver layerRemy Bohmer
Derived from Linux kernel 2.6.27 Signed-off-by: Thomas Smits <ts.smits@gmail.com> Signed-off-by: Remy Bohmer <linux@bohmer.net>