提交 73ef635a 编写于 作者: K Kuninori Morimoto 提交者: Greg Kroah-Hartman

usb: gadget: renesas_usbhs: bugfix: care pipe direction

renesas_usbhs is caring pipe type and its direction.
but current usbhs_endpoint_alloc() didn't check direction.
this patch modify it.
Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 4703d2e9
......@@ -355,6 +355,7 @@ static void usbhsh_device_free(struct usbhsh_hpriv *hpriv,
struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv,
struct usbhsh_device *udev,
struct usb_host_endpoint *ep,
int dir_in_req,
gfp_t mem_flags)
{
struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv);
......@@ -364,27 +365,38 @@ struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv,
struct usbhs_pipe *pipe, *best_pipe;
struct device *dev = usbhsh_hcd_to_dev(hcd);
struct usb_endpoint_descriptor *desc = &ep->desc;
int type, i;
int type, i, dir_in;
unsigned int min_usr;
dir_in_req = !!dir_in_req;
uep = kzalloc(sizeof(struct usbhsh_ep), mem_flags);
if (!uep) {
dev_err(dev, "usbhsh_ep alloc fail\n");
return NULL;
}
type = usb_endpoint_type(desc);
if (usb_endpoint_xfer_control(desc)) {
best_pipe = usbhsh_hpriv_to_dcp(hpriv);
goto usbhsh_endpoint_alloc_find_pipe;
}
/*
* find best pipe for endpoint
* see
* HARDWARE LIMITATION
*/
type = usb_endpoint_type(desc);
min_usr = ~0;
best_pipe = NULL;
usbhs_for_each_pipe_with_dcp(pipe, priv, i) {
usbhs_for_each_pipe(pipe, priv, i) {
if (!usbhs_pipe_type_is(pipe, type))
continue;
dir_in = !!usbhs_pipe_is_dir_in(pipe);
if (0 != (dir_in - dir_in_req))
continue;
info = usbhsh_pipe_info(pipe);
if (min_usr > info->usr_cnt) {
......@@ -398,7 +410,7 @@ struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv,
kfree(uep);
return NULL;
}
usbhsh_endpoint_alloc_find_pipe:
/*
* init uep
*/
......@@ -430,7 +442,7 @@ struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv,
dev_dbg(dev, "%s [%d-%s](%p)\n", __func__,
usbhsh_device_number(hpriv, udev),
usbhs_pipe_name(pipe), uep);
usbhs_pipe_name(uep->pipe), uep);
return uep;
}
......@@ -722,11 +734,11 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd,
struct usbhsh_device *udev, *new_udev = NULL;
struct usbhs_pipe *pipe;
struct usbhsh_ep *uep;
int is_dir_in = usb_pipein(urb->pipe);
int ret;
dev_dbg(dev, "%s (%s)\n",
__func__, usb_pipein(urb->pipe) ? "in" : "out");
dev_dbg(dev, "%s (%s)\n", __func__, is_dir_in ? "in" : "out");
ret = usb_hcd_link_urb_to_ep(hcd, urb);
if (ret)
......@@ -749,7 +761,8 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd,
*/
uep = usbhsh_ep_to_uep(ep);
if (!uep) {
uep = usbhsh_endpoint_alloc(hpriv, udev, ep, mem_flags);
uep = usbhsh_endpoint_alloc(hpriv, udev, ep,
is_dir_in, mem_flags);
if (!uep)
goto usbhsh_urb_enqueue_error_free_device;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册