aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/renesas_usbhs/mod_host.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2011-10-31 03:48:59 -0400
committerFelipe Balbi <balbi@ti.com>2011-12-12 04:45:09 -0500
commit4825093e9d0692a2a1f1615ab69246ac07b17f2f (patch)
tree9cc8791cafe6e3d1772d035c48d4969bfacf30ca /drivers/usb/renesas_usbhs/mod_host.c
parent3eddc9e4c828dbbeabb5924266bfded42a1ac042 (diff)
usb: gadget: renesas_usbhs: parameter cleanup for usbhsh_endpoint_xx()
current mod_host used usbhs_endpoint_alloc/free(), but allocated variable was attached to each xx->hcpriv. The intuitively clear name was not xxx_alloc/free() but xxx_attach/detach(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/renesas_usbhs/mod_host.c')
-rw-r--r--drivers/usb/renesas_usbhs/mod_host.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c
index 887cf686bca9..11c615d8d0d2 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -340,13 +340,14 @@ static void usbhsh_device_free(struct usbhsh_hpriv *hpriv,
340/* 340/*
341 * end-point control 341 * end-point control
342 */ 342 */
343static struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv, 343static int usbhsh_endpoint_attach(struct usbhsh_hpriv *hpriv,
344 struct usbhsh_device *udev, 344 struct urb *urb,
345 struct usb_host_endpoint *ep, 345 gfp_t mem_flags)
346 int dir_in_req,
347 gfp_t mem_flags)
348{ 346{
349 struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); 347 struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv);
348 struct usb_device *usbv = usbhsh_urb_to_usbv(urb);
349 struct usbhsh_device *udev = usbhsh_usbv_to_udev(usbv);
350 struct usb_host_endpoint *ep = urb->ep;
350 struct usbhsh_ep *uep; 351 struct usbhsh_ep *uep;
351 struct usbhsh_pipe_info *info; 352 struct usbhsh_pipe_info *info;
352 struct usbhs_pipe *best_pipe = NULL; 353 struct usbhs_pipe *best_pipe = NULL;
@@ -357,7 +358,7 @@ static struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv,
357 uep = kzalloc(sizeof(struct usbhsh_ep), mem_flags); 358 uep = kzalloc(sizeof(struct usbhsh_ep), mem_flags);
358 if (!uep) { 359 if (!uep) {
359 dev_err(dev, "usbhsh_ep alloc fail\n"); 360 dev_err(dev, "usbhsh_ep alloc fail\n");
360 return NULL; 361 return -ENOMEM;
361 } 362 }
362 363
363 /******************** spin lock ********************/ 364 /******************** spin lock ********************/
@@ -374,10 +375,9 @@ static struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv,
374 } else { 375 } else {
375 struct usbhs_pipe *pipe; 376 struct usbhs_pipe *pipe;
376 unsigned int min_usr = ~0; 377 unsigned int min_usr = ~0;
378 int dir_in_req = !!usb_pipein(urb->pipe);
377 int i, dir_in; 379 int i, dir_in;
378 380
379 dir_in_req = !!dir_in_req;
380
381 usbhs_for_each_pipe(pipe, priv, i) { 381 usbhs_for_each_pipe(pipe, priv, i) {
382 if (!usbhs_pipe_type_is(pipe, usb_endpoint_type(desc))) 382 if (!usbhs_pipe_type_is(pipe, usb_endpoint_type(desc)))
383 continue; 383 continue;
@@ -410,7 +410,7 @@ static struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv,
410 if (unlikely(!best_pipe)) { 410 if (unlikely(!best_pipe)) {
411 dev_err(dev, "couldn't find best pipe\n"); 411 dev_err(dev, "couldn't find best pipe\n");
412 kfree(uep); 412 kfree(uep);
413 return NULL; 413 return -EIO;
414 } 414 }
415 415
416 /* 416 /*
@@ -437,11 +437,11 @@ static struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv,
437 usbhsh_device_number(hpriv, udev), 437 usbhsh_device_number(hpriv, udev),
438 usbhs_pipe_name(uep->pipe), uep); 438 usbhs_pipe_name(uep->pipe), uep);
439 439
440 return uep; 440 return 0;
441} 441}
442 442
443static void usbhsh_endpoint_free(struct usbhsh_hpriv *hpriv, 443static void usbhsh_endpoint_detach(struct usbhsh_hpriv *hpriv,
444 struct usb_host_endpoint *ep) 444 struct usb_host_endpoint *ep)
445{ 445{
446 struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); 446 struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv);
447 struct device *dev = usbhs_priv_to_dev(priv); 447 struct device *dev = usbhs_priv_to_dev(priv);
@@ -745,7 +745,6 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd,
745 struct usb_device *usbv = usbhsh_urb_to_usbv(urb); 745 struct usb_device *usbv = usbhsh_urb_to_usbv(urb);
746 struct usb_host_endpoint *ep = urb->ep; 746 struct usb_host_endpoint *ep = urb->ep;
747 struct usbhsh_device *udev, *new_udev = NULL; 747 struct usbhsh_device *udev, *new_udev = NULL;
748 struct usbhsh_ep *uep;
749 int is_dir_in = usb_pipein(urb->pipe); 748 int is_dir_in = usb_pipein(urb->pipe);
750 749
751 int ret; 750 int ret;
@@ -769,13 +768,11 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd,
769 } 768 }
770 769
771 /* 770 /*
772 * get uep 771 * attach endpoint if needed
773 */ 772 */
774 uep = usbhsh_ep_to_uep(ep); 773 if (!usbhsh_ep_to_uep(ep)) {
775 if (!uep) { 774 ret = usbhsh_endpoint_attach(hpriv, urb, mem_flags);
776 uep = usbhsh_endpoint_alloc(hpriv, udev, ep, 775 if (ret < 0)
777 is_dir_in, mem_flags);
778 if (!uep)
779 goto usbhsh_urb_enqueue_error_free_device; 776 goto usbhsh_urb_enqueue_error_free_device;
780 } 777 }
781 778
@@ -827,7 +824,7 @@ static void usbhsh_endpoint_disable(struct usb_hcd *hcd,
827 udev = usbhsh_uep_to_udev(uep); 824 udev = usbhsh_uep_to_udev(uep);
828 hpriv = usbhsh_hcd_to_hpriv(hcd); 825 hpriv = usbhsh_hcd_to_hpriv(hcd);
829 826
830 usbhsh_endpoint_free(hpriv, ep); 827 usbhsh_endpoint_detach(hpriv, ep);
831 828
832 /* 829 /*
833 * if there is no endpoint, 830 * if there is no endpoint,