diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2007-08-24 15:42:24 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-12 17:55:23 -0400 |
commit | 4a00027dcb088bf90fa8fb14a7e8ba3506d78f22 (patch) | |
tree | 992b3dbda7b950b8906ac4751e43a28fd15e2e5d /drivers/usb/core | |
parent | 9347d51c52afcf1a77d2104f162cf8a085624c83 (diff) |
USB: Eliminate urb->status usage!
This patch (as979) removes the last vestiges of urb->status from the
host controller drivers and the root-hub emulator. Now the field
doesn't get set until just before the URB's completion routine is
called.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: David Brownell <david-b@pacbell.net>
CC: Olav Kongas <ok@artecdesign.ee>
CC: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
CC: Tony Olech <tony.olech@elandigitalsystems.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r-- | drivers/usb/core/hcd.c | 22 | ||||
-rw-r--r-- | drivers/usb/core/hcd.h | 3 |
2 files changed, 13 insertions, 12 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 4ac021e42cd8..1c5e5d35e08d 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -532,7 +532,6 @@ error: | |||
532 | 532 | ||
533 | /* any errors get returned through the urb completion */ | 533 | /* any errors get returned through the urb completion */ |
534 | spin_lock_irq(&hcd_root_hub_lock); | 534 | spin_lock_irq(&hcd_root_hub_lock); |
535 | urb->status = status; | ||
536 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 535 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
537 | 536 | ||
538 | /* This peculiar use of spinlocks echoes what real HC drivers do. | 537 | /* This peculiar use of spinlocks echoes what real HC drivers do. |
@@ -540,7 +539,7 @@ error: | |||
540 | * RT-friendly. | 539 | * RT-friendly. |
541 | */ | 540 | */ |
542 | spin_unlock(&hcd_root_hub_lock); | 541 | spin_unlock(&hcd_root_hub_lock); |
543 | usb_hcd_giveback_urb(hcd, urb); | 542 | usb_hcd_giveback_urb(hcd, urb, status); |
544 | spin_lock(&hcd_root_hub_lock); | 543 | spin_lock(&hcd_root_hub_lock); |
545 | 544 | ||
546 | spin_unlock_irq(&hcd_root_hub_lock); | 545 | spin_unlock_irq(&hcd_root_hub_lock); |
@@ -578,13 +577,12 @@ void usb_hcd_poll_rh_status(struct usb_hcd *hcd) | |||
578 | if (urb) { | 577 | if (urb) { |
579 | hcd->poll_pending = 0; | 578 | hcd->poll_pending = 0; |
580 | hcd->status_urb = NULL; | 579 | hcd->status_urb = NULL; |
581 | urb->status = 0; | ||
582 | urb->actual_length = length; | 580 | urb->actual_length = length; |
583 | memcpy(urb->transfer_buffer, buffer, length); | 581 | memcpy(urb->transfer_buffer, buffer, length); |
584 | 582 | ||
585 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 583 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
586 | spin_unlock(&hcd_root_hub_lock); | 584 | spin_unlock(&hcd_root_hub_lock); |
587 | usb_hcd_giveback_urb(hcd, urb); | 585 | usb_hcd_giveback_urb(hcd, urb, 0); |
588 | spin_lock(&hcd_root_hub_lock); | 586 | spin_lock(&hcd_root_hub_lock); |
589 | } else { | 587 | } else { |
590 | length = 0; | 588 | length = 0; |
@@ -677,7 +675,7 @@ static int usb_rh_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
677 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 675 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
678 | 676 | ||
679 | spin_unlock(&hcd_root_hub_lock); | 677 | spin_unlock(&hcd_root_hub_lock); |
680 | usb_hcd_giveback_urb(hcd, urb); | 678 | usb_hcd_giveback_urb(hcd, urb, status); |
681 | spin_lock(&hcd_root_hub_lock); | 679 | spin_lock(&hcd_root_hub_lock); |
682 | } | 680 | } |
683 | } | 681 | } |
@@ -1252,6 +1250,7 @@ int usb_hcd_unlink_urb (struct urb *urb, int status) | |||
1252 | * usb_hcd_giveback_urb - return URB from HCD to device driver | 1250 | * usb_hcd_giveback_urb - return URB from HCD to device driver |
1253 | * @hcd: host controller returning the URB | 1251 | * @hcd: host controller returning the URB |
1254 | * @urb: urb being returned to the USB device driver. | 1252 | * @urb: urb being returned to the USB device driver. |
1253 | * @status: completion status code for the URB. | ||
1255 | * Context: in_interrupt() | 1254 | * Context: in_interrupt() |
1256 | * | 1255 | * |
1257 | * This hands the URB from HCD to its USB device driver, using its | 1256 | * This hands the URB from HCD to its USB device driver, using its |
@@ -1260,25 +1259,26 @@ int usb_hcd_unlink_urb (struct urb *urb, int status) | |||
1260 | * the device driver won't cause problems if it frees, modifies, | 1259 | * the device driver won't cause problems if it frees, modifies, |
1261 | * or resubmits this URB. | 1260 | * or resubmits this URB. |
1262 | * | 1261 | * |
1263 | * If @urb was unlinked, the value of @urb->status will be overridden by | 1262 | * If @urb was unlinked, the value of @status will be overridden by |
1264 | * @urb->unlinked. Erroneous short transfers are detected in case | 1263 | * @urb->unlinked. Erroneous short transfers are detected in case |
1265 | * the HCD hasn't checked for them. | 1264 | * the HCD hasn't checked for them. |
1266 | */ | 1265 | */ |
1267 | void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb) | 1266 | void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status) |
1268 | { | 1267 | { |
1269 | urb->hcpriv = NULL; | 1268 | urb->hcpriv = NULL; |
1270 | if (unlikely(urb->unlinked)) | 1269 | if (unlikely(urb->unlinked)) |
1271 | urb->status = urb->unlinked; | 1270 | status = urb->unlinked; |
1272 | else if (unlikely((urb->transfer_flags & URB_SHORT_NOT_OK) && | 1271 | else if (unlikely((urb->transfer_flags & URB_SHORT_NOT_OK) && |
1273 | urb->actual_length < urb->transfer_buffer_length && | 1272 | urb->actual_length < urb->transfer_buffer_length && |
1274 | !urb->status)) | 1273 | !status)) |
1275 | urb->status = -EREMOTEIO; | 1274 | status = -EREMOTEIO; |
1276 | 1275 | ||
1277 | unmap_urb_for_dma(hcd, urb); | 1276 | unmap_urb_for_dma(hcd, urb); |
1278 | usbmon_urb_complete(&hcd->self, urb, urb->status); | 1277 | usbmon_urb_complete(&hcd->self, urb, status); |
1279 | usb_unanchor_urb(urb); | 1278 | usb_unanchor_urb(urb); |
1280 | 1279 | ||
1281 | /* pass ownership to the completion handler */ | 1280 | /* pass ownership to the completion handler */ |
1281 | urb->status = status; | ||
1282 | urb->complete (urb); | 1282 | urb->complete (urb); |
1283 | atomic_dec (&urb->use_count); | 1283 | atomic_dec (&urb->use_count); |
1284 | if (unlikely (urb->reject)) | 1284 | if (unlikely (urb->reject)) |
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index 729b7a03acd8..0fc7b95259f5 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h | |||
@@ -217,7 +217,8 @@ extern void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb); | |||
217 | 217 | ||
218 | extern int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags); | 218 | extern int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags); |
219 | extern int usb_hcd_unlink_urb (struct urb *urb, int status); | 219 | extern int usb_hcd_unlink_urb (struct urb *urb, int status); |
220 | extern void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb); | 220 | extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, |
221 | int status); | ||
221 | extern void usb_hcd_endpoint_disable (struct usb_device *udev, | 222 | extern void usb_hcd_endpoint_disable (struct usb_device *udev, |
222 | struct usb_host_endpoint *ep); | 223 | struct usb_host_endpoint *ep); |
223 | extern int usb_hcd_get_frame_number (struct usb_device *udev); | 224 | extern int usb_hcd_get_frame_number (struct usb_device *udev); |