aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/dummy_hcd.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2007-08-08 11:48:02 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-10-12 17:55:10 -0400
commite9df41c5c5899259541dc928872cad4d07b82076 (patch)
tree12bb0917eeecbe62b2b5d3dc576806c7f2728550 /drivers/usb/gadget/dummy_hcd.c
parentb0e396e3097ce4914c643bc3f0c2fe0098f551eb (diff)
USB: make HCDs responsible for managing endpoint queues
This patch (as954) implements a suggestion of David Brownell's. Now the host controller drivers are responsible for linking and unlinking URBs to/from their endpoint queues. This eliminates the possiblity of strange situations where usbcore thinks an URB is linked but the HCD thinks it isn't. It also means HCDs no longer have to check for URBs being dequeued before they were fully enqueued. In addition to the core changes, this requires changing every host controller driver and the root-hub URB handler. For the most part the required changes are fairly small; drivers have to call usb_hcd_link_urb_to_ep() in their urb_enqueue method, usb_hcd_check_unlink_urb() in their urb_dequeue method, and usb_hcd_unlink_urb_from_ep() before giving URBs back. A few HCDs make matters more complicated by the way they split up the flow of control. In addition some method interfaces get changed. The endpoint argument for urb_enqueue is now redundant so it is removed. The unlink status is required by usb_hcd_check_unlink_urb(), so it has been added to urb_dequeue. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> CC: David Brownell <david-b@pacbell.net> CC: Olav Kongas <ok@artecdesign.ee> CC: Tony Olech <tony.olech@elandigitalsystems.com> CC: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/dummy_hcd.c')
-rw-r--r--drivers/usb/gadget/dummy_hcd.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index d008d1360a7a..c441d10c087e 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -962,13 +962,13 @@ static struct platform_driver dummy_udc_driver = {
962 962
963static int dummy_urb_enqueue ( 963static int dummy_urb_enqueue (
964 struct usb_hcd *hcd, 964 struct usb_hcd *hcd,
965 struct usb_host_endpoint *ep,
966 struct urb *urb, 965 struct urb *urb,
967 gfp_t mem_flags 966 gfp_t mem_flags
968) { 967) {
969 struct dummy *dum; 968 struct dummy *dum;
970 struct urbp *urbp; 969 struct urbp *urbp;
971 unsigned long flags; 970 unsigned long flags;
971 int rc;
972 972
973 if (!urb->transfer_buffer && urb->transfer_buffer_length) 973 if (!urb->transfer_buffer && urb->transfer_buffer_length)
974 return -EINVAL; 974 return -EINVAL;
@@ -980,6 +980,11 @@ static int dummy_urb_enqueue (
980 980
981 dum = hcd_to_dummy (hcd); 981 dum = hcd_to_dummy (hcd);
982 spin_lock_irqsave (&dum->lock, flags); 982 spin_lock_irqsave (&dum->lock, flags);
983 rc = usb_hcd_link_urb_to_ep(hcd, urb);
984 if (rc) {
985 kfree(urbp);
986 goto done;
987 }
983 988
984 if (!dum->udev) { 989 if (!dum->udev) {
985 dum->udev = urb->dev; 990 dum->udev = urb->dev;
@@ -997,22 +1002,28 @@ static int dummy_urb_enqueue (
997 mod_timer (&dum->timer, jiffies + 1); 1002 mod_timer (&dum->timer, jiffies + 1);
998 1003
999 spin_unlock_irqrestore (&dum->lock, flags); 1004 spin_unlock_irqrestore (&dum->lock, flags);
1000 return 0; 1005 done:
1006 return rc;
1001} 1007}
1002 1008
1003static int dummy_urb_dequeue (struct usb_hcd *hcd, struct urb *urb) 1009static int dummy_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
1004{ 1010{
1005 struct dummy *dum; 1011 struct dummy *dum;
1006 unsigned long flags; 1012 unsigned long flags;
1013 int rc;
1007 1014
1008 /* giveback happens automatically in timer callback, 1015 /* giveback happens automatically in timer callback,
1009 * so make sure the callback happens */ 1016 * so make sure the callback happens */
1010 dum = hcd_to_dummy (hcd); 1017 dum = hcd_to_dummy (hcd);
1011 spin_lock_irqsave (&dum->lock, flags); 1018 spin_lock_irqsave (&dum->lock, flags);
1012 if (dum->rh_state != DUMMY_RH_RUNNING && !list_empty(&dum->urbp_list)) 1019
1020 rc = usb_hcd_check_unlink_urb(hcd, urb, status);
1021 if (!rc && dum->rh_state != DUMMY_RH_RUNNING &&
1022 !list_empty(&dum->urbp_list))
1013 mod_timer (&dum->timer, jiffies); 1023 mod_timer (&dum->timer, jiffies);
1024
1014 spin_unlock_irqrestore (&dum->lock, flags); 1025 spin_unlock_irqrestore (&dum->lock, flags);
1015 return 0; 1026 return rc;
1016} 1027}
1017 1028
1018static void maybe_set_status (struct urb *urb, int status) 1029static void maybe_set_status (struct urb *urb, int status)
@@ -1511,6 +1522,7 @@ return_urb:
1511 if (ep) 1522 if (ep)
1512 ep->already_seen = ep->setup_stage = 0; 1523 ep->already_seen = ep->setup_stage = 0;
1513 1524
1525 usb_hcd_unlink_urb_from_ep(dummy_to_hcd(dum), urb);
1514 spin_unlock (&dum->lock); 1526 spin_unlock (&dum->lock);
1515 usb_hcd_giveback_urb (dummy_to_hcd(dum), urb); 1527 usb_hcd_giveback_urb (dummy_to_hcd(dum), urb);
1516 spin_lock (&dum->lock); 1528 spin_lock (&dum->lock);