Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338640
b: refs/heads/master
c: 7b332e5
h: refs/heads/master
v: v3
  • Loading branch information
Kuninori Morimoto authored and Felipe Balbi committed Nov 6, 2012
1 parent 46e8c2b commit 61e8894
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 24e4c1c30da3926db547aab4ec873afdc60bd3ee
refs/heads/master: 7b332e5fef480ee14d133d9b83af22d03819368e
24 changes: 13 additions & 11 deletions trunk/drivers/usb/renesas_usbhs/mod_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ struct usbhsh_ep {
struct usbhsh_device *udev; /* attached udev */
struct usb_host_endpoint *ep;
struct list_head ep_list; /* list to usbhsh_device */
unsigned int counter; /* pipe attach counter */
};

#define USBHSH_DEVICE_MAX 10 /* see DEVADDn / DCPMAXP / PIPEMAXP */
Expand Down Expand Up @@ -271,8 +272,12 @@ static int usbhsh_pipe_attach(struct usbhsh_hpriv *hpriv,
/******************** spin lock ********************/
usbhs_lock(priv, flags);

if (unlikely(usbhsh_uep_to_pipe(uep))) {
dev_err(dev, "uep already has pipe\n");
/*
* if uep has been attached to pipe,
* reuse it
*/
if (usbhsh_uep_to_pipe(uep)) {
ret = 0;
goto usbhsh_pipe_attach_done;
}

Expand Down Expand Up @@ -320,6 +325,9 @@ static int usbhsh_pipe_attach(struct usbhsh_hpriv *hpriv,
}

usbhsh_pipe_attach_done:
if (0 == ret)
uep->counter++;

usbhs_unlock(priv, flags);
/******************** spin unlock ******************/

Expand All @@ -341,7 +349,7 @@ static void usbhsh_pipe_detach(struct usbhsh_hpriv *hpriv,

if (unlikely(!pipe)) {
dev_err(dev, "uep doens't have pipe\n");
} else {
} else if (1 == uep->counter--) { /* last user */
struct usb_host_endpoint *ep = usbhsh_uep_to_ep(uep);
struct usbhsh_device *udev = usbhsh_uep_to_udev(uep);

Expand Down Expand Up @@ -386,6 +394,7 @@ static int usbhsh_endpoint_attach(struct usbhsh_hpriv *hpriv,
/*
* init endpoint
*/
uep->counter = 0;
INIT_LIST_HEAD(&uep->ep_list);
list_add_tail(&uep->ep_list, &udev->ep_list_head);

Expand Down Expand Up @@ -954,7 +963,6 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd,
struct usb_host_endpoint *ep = urb->ep;
struct usbhsh_device *new_udev = NULL;
int is_dir_in = usb_pipein(urb->pipe);
int i;
int ret;

dev_dbg(dev, "%s (%s)\n", __func__, is_dir_in ? "in" : "out");
Expand Down Expand Up @@ -1000,13 +1008,7 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd,
* attach pipe to endpoint
* see [image of mod_host]
*/
for (i = 0; i < 1024; i++) {
ret = usbhsh_pipe_attach(hpriv, urb);
if (ret < 0)
msleep(100);
else
break;
}
ret = usbhsh_pipe_attach(hpriv, urb);
if (ret < 0) {
dev_err(dev, "pipe attach failed\n");
goto usbhsh_urb_enqueue_error_free_endpoint;
Expand Down

0 comments on commit 61e8894

Please sign in to comment.