Created
June 22, 2012 16:53
-
-
Save ddv2005/2973955 to your computer and use it in GitHub Desktop.
RPi DWC OTG patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c | |
index 2a3b689..16047ca 100644 | |
--- a/drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c | |
+++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c | |
@@ -70,6 +70,7 @@ | |
#include "dwc_otg_hcd_if.h" | |
#include "dwc_otg_dbg.h" | |
#include "dwc_otg_driver.h" | |
+#include "dwc_otg_hcd.h" | |
/** | |
* Gets the endpoint number from a _bEndpointAddress argument. The endpoint is | |
@@ -256,6 +257,7 @@ static void free_bus_bandwidth(struct usb_hcd *hcd, uint32_t bw, | |
static int _complete(dwc_otg_hcd_t * hcd, void *urb_handle, | |
dwc_otg_hcd_urb_t * dwc_otg_urb, int32_t status) | |
{ | |
+ uint64_t flags; | |
struct urb *urb = (struct urb *)urb_handle; | |
#ifdef DEBUG | |
if (CHK_DEBUG_LEVEL(DBG_HCDV | DBG_HCD_URB)) { | |
@@ -340,7 +342,9 @@ static int _complete(dwc_otg_hcd_t * hcd, void *urb_handle, | |
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) | |
usb_hcd_giveback_urb(dwc_otg_hcd_to_hcd(hcd), urb); | |
#else | |
+ DWC_SPINLOCK_IRQSAVE(hcd->lock, &flags); | |
usb_hcd_unlink_urb_from_ep(dwc_otg_hcd_to_hcd(hcd), urb); | |
+ DWC_SPINUNLOCK_IRQRESTORE(hcd->lock, flags); | |
usb_hcd_giveback_urb(dwc_otg_hcd_to_hcd(hcd), urb, status); | |
#endif | |
return 0; | |
@@ -751,6 +755,8 @@ static int urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | |
static int urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |
#endif | |
{ | |
+ int rc; | |
+ uint64_t flags; | |
dwc_otg_hcd_t *dwc_otg_hcd; | |
DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD URB Dequeue\n"); | |
@@ -764,16 +770,25 @@ static int urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |
if(urb->hcpriv != NULL) { | |
dwc_otg_hcd_urb_dequeue(dwc_otg_hcd, (dwc_otg_hcd_urb_t *)urb->hcpriv); | |
- urb->hcpriv = NULL; | |
dwc_free(urb->hcpriv); | |
+ urb->hcpriv = NULL; | |
} | |
/* Higher layer software sets URB status. */ | |
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) | |
usb_hcd_giveback_urb(hcd, urb); | |
#else | |
- usb_hcd_unlink_urb_from_ep(hcd, urb); | |
- usb_hcd_giveback_urb(hcd, urb, status); | |
+ DWC_SPINLOCK_IRQSAVE(dwc_otg_hcd->lock, &flags); | |
+ rc = usb_hcd_check_unlink_urb(hcd, urb, status); | |
+ if(!rc) | |
+ { | |
+ usb_hcd_unlink_urb_from_ep(hcd, urb); | |
+ } | |
+ DWC_SPINUNLOCK_IRQRESTORE(dwc_otg_hcd->lock, flags); | |
+ if (!rc) | |
+ { | |
+ usb_hcd_giveback_urb(hcd, urb, status); | |
+ } | |
#endif | |
if (CHK_DEBUG_LEVEL(DBG_HCDV | DBG_HCD_URB)) { | |
DWC_PRINTF("Called usb_hcd_giveback_urb()\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment