diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2010-06-22 16:39:10 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 17:35:37 -0400 |
commit | 541c7d432f76771079e7c295d596ea47cc6a3030 (patch) | |
tree | 9e04330713366d21849cecf0f3fd2f2c1834574d | |
parent | 89ba85d4015b7fa738b35bcc228075c117a9a578 (diff) |
USB: convert usb_hcd bitfields into atomic flags
This patch (as1393) converts several of the single-bit fields in
struct usb_hcd to atomic flags. This is for safety's sake; not all
CPUs can update bitfield values atomically, and these flags are used
in multiple contexts.
The flag fields that are set only during registration or removal can
remain as they are, since non-atomic accesses at those times will not
cause any problems.
(Strictly speaking, the authorized_default flag should become atomic
as well. I didn't bother with it because it gets changed only via
sysfs. It can be done later, if anyone wants.)
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/usbip/vhci_hcd.c | 6 | ||||
-rw-r--r-- | drivers/usb/c67x00/c67x00-hcd.c | 4 | ||||
-rw-r--r-- | drivers/usb/core/hcd.c | 26 | ||||
-rw-r--r-- | drivers/usb/gadget/dummy_hcd.c | 6 | ||||
-rw-r--r-- | drivers/usb/host/ehci-dbg.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 1 | ||||
-rw-r--r-- | drivers/usb/host/ehci-hub.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/ehci-q.c | 3 | ||||
-rw-r--r-- | drivers/usb/host/ehci-sched.c | 9 | ||||
-rw-r--r-- | drivers/usb/host/hwa-hc.c | 4 | ||||
-rw-r--r-- | drivers/usb/host/isp1760-hcd.c | 3 | ||||
-rw-r--r-- | drivers/usb/host/ohci-dbg.c | 4 | ||||
-rw-r--r-- | drivers/usb/host/ohci-hcd.c | 6 | ||||
-rw-r--r-- | drivers/usb/host/ohci-hub.c | 16 | ||||
-rw-r--r-- | drivers/usb/host/oxu210hp-hcd.c | 7 | ||||
-rw-r--r-- | drivers/usb/host/uhci-hcd.c | 21 | ||||
-rw-r--r-- | drivers/usb/host/uhci-hub.c | 4 | ||||
-rw-r--r-- | drivers/usb/host/whci/hcd.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/xhci.c | 3 | ||||
-rw-r--r-- | drivers/usb/musb/musb_virthub.c | 2 | ||||
-rw-r--r-- | include/linux/usb/hcd.h | 22 |
21 files changed, 80 insertions, 73 deletions
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index be5d8db98165..0574d848b900 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c | |||
@@ -215,7 +215,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf) | |||
215 | vhci = hcd_to_vhci(hcd); | 215 | vhci = hcd_to_vhci(hcd); |
216 | 216 | ||
217 | spin_lock_irqsave(&vhci->lock, flags); | 217 | spin_lock_irqsave(&vhci->lock, flags); |
218 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 218 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
219 | usbip_dbg_vhci_rh("hw accessible flag in on?\n"); | 219 | usbip_dbg_vhci_rh("hw accessible flag in on?\n"); |
220 | goto done; | 220 | goto done; |
221 | } | 221 | } |
@@ -269,7 +269,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
269 | 269 | ||
270 | u32 prev_port_status[VHCI_NPORTS]; | 270 | u32 prev_port_status[VHCI_NPORTS]; |
271 | 271 | ||
272 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 272 | if (!HCD_HW_ACCESSIBLE(hcd)) |
273 | return -ETIMEDOUT; | 273 | return -ETIMEDOUT; |
274 | 274 | ||
275 | /* | 275 | /* |
@@ -1041,7 +1041,7 @@ static int vhci_bus_resume(struct usb_hcd *hcd) | |||
1041 | dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__); | 1041 | dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__); |
1042 | 1042 | ||
1043 | spin_lock_irq(&vhci->lock); | 1043 | spin_lock_irq(&vhci->lock); |
1044 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 1044 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
1045 | rc = -ESHUTDOWN; | 1045 | rc = -ESHUTDOWN; |
1046 | } else { | 1046 | } else { |
1047 | /* vhci->rh_state = DUMMY_RH_RUNNING; | 1047 | /* vhci->rh_state = DUMMY_RH_RUNNING; |
diff --git a/drivers/usb/c67x00/c67x00-hcd.c b/drivers/usb/c67x00/c67x00-hcd.c index a22b887f4e9e..d3e1356d091e 100644 --- a/drivers/usb/c67x00/c67x00-hcd.c +++ b/drivers/usb/c67x00/c67x00-hcd.c | |||
@@ -264,7 +264,7 @@ static void c67x00_hcd_irq(struct c67x00_sie *sie, u16 int_status, u16 msg) | |||
264 | if (unlikely(hcd->state == HC_STATE_HALT)) | 264 | if (unlikely(hcd->state == HC_STATE_HALT)) |
265 | return; | 265 | return; |
266 | 266 | ||
267 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 267 | if (!HCD_HW_ACCESSIBLE(hcd)) |
268 | return; | 268 | return; |
269 | 269 | ||
270 | /* Handle Start of frame events */ | 270 | /* Handle Start of frame events */ |
@@ -282,7 +282,7 @@ static int c67x00_hcd_start(struct usb_hcd *hcd) | |||
282 | { | 282 | { |
283 | hcd->uses_new_polling = 1; | 283 | hcd->uses_new_polling = 1; |
284 | hcd->state = HC_STATE_RUNNING; | 284 | hcd->state = HC_STATE_RUNNING; |
285 | hcd->poll_rh = 1; | 285 | set_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
286 | 286 | ||
287 | return 0; | 287 | return 0; |
288 | } | 288 | } |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 53f14c82ff2e..f2fe7c8e991d 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -679,7 +679,7 @@ void usb_hcd_poll_rh_status(struct usb_hcd *hcd) | |||
679 | spin_lock_irqsave(&hcd_root_hub_lock, flags); | 679 | spin_lock_irqsave(&hcd_root_hub_lock, flags); |
680 | urb = hcd->status_urb; | 680 | urb = hcd->status_urb; |
681 | if (urb) { | 681 | if (urb) { |
682 | hcd->poll_pending = 0; | 682 | clear_bit(HCD_FLAG_POLL_PENDING, &hcd->flags); |
683 | hcd->status_urb = NULL; | 683 | hcd->status_urb = NULL; |
684 | urb->actual_length = length; | 684 | urb->actual_length = length; |
685 | memcpy(urb->transfer_buffer, buffer, length); | 685 | memcpy(urb->transfer_buffer, buffer, length); |
@@ -690,7 +690,7 @@ void usb_hcd_poll_rh_status(struct usb_hcd *hcd) | |||
690 | spin_lock(&hcd_root_hub_lock); | 690 | spin_lock(&hcd_root_hub_lock); |
691 | } else { | 691 | } else { |
692 | length = 0; | 692 | length = 0; |
693 | hcd->poll_pending = 1; | 693 | set_bit(HCD_FLAG_POLL_PENDING, &hcd->flags); |
694 | } | 694 | } |
695 | spin_unlock_irqrestore(&hcd_root_hub_lock, flags); | 695 | spin_unlock_irqrestore(&hcd_root_hub_lock, flags); |
696 | } | 696 | } |
@@ -699,7 +699,7 @@ void usb_hcd_poll_rh_status(struct usb_hcd *hcd) | |||
699 | * exceed that limit if HZ is 100. The math is more clunky than | 699 | * exceed that limit if HZ is 100. The math is more clunky than |
700 | * maybe expected, this is to make sure that all timers for USB devices | 700 | * maybe expected, this is to make sure that all timers for USB devices |
701 | * fire at the same time to give the CPU a break inbetween */ | 701 | * fire at the same time to give the CPU a break inbetween */ |
702 | if (hcd->uses_new_polling ? hcd->poll_rh : | 702 | if (hcd->uses_new_polling ? HCD_POLL_RH(hcd) : |
703 | (length == 0 && hcd->status_urb != NULL)) | 703 | (length == 0 && hcd->status_urb != NULL)) |
704 | mod_timer (&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); | 704 | mod_timer (&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); |
705 | } | 705 | } |
@@ -736,7 +736,7 @@ static int rh_queue_status (struct usb_hcd *hcd, struct urb *urb) | |||
736 | mod_timer(&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); | 736 | mod_timer(&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); |
737 | 737 | ||
738 | /* If a status change has already occurred, report it ASAP */ | 738 | /* If a status change has already occurred, report it ASAP */ |
739 | else if (hcd->poll_pending) | 739 | else if (HCD_POLL_PENDING(hcd)) |
740 | mod_timer(&hcd->rh_timer, jiffies); | 740 | mod_timer(&hcd->rh_timer, jiffies); |
741 | retval = 0; | 741 | retval = 0; |
742 | done: | 742 | done: |
@@ -1150,8 +1150,7 @@ int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb, | |||
1150 | * finish unlinking the initial failed usb_set_address() | 1150 | * finish unlinking the initial failed usb_set_address() |
1151 | * or device descriptor fetch. | 1151 | * or device descriptor fetch. |
1152 | */ | 1152 | */ |
1153 | if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags) && | 1153 | if (!HCD_SAW_IRQ(hcd) && !is_root_hub(urb->dev)) { |
1154 | !is_root_hub(urb->dev)) { | ||
1155 | dev_warn(hcd->self.controller, "Unlink after no-IRQ? " | 1154 | dev_warn(hcd->self.controller, "Unlink after no-IRQ? " |
1156 | "Controller is probably using the wrong IRQ.\n"); | 1155 | "Controller is probably using the wrong IRQ.\n"); |
1157 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | 1156 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); |
@@ -2063,8 +2062,7 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd) | |||
2063 | */ | 2062 | */ |
2064 | local_irq_save(flags); | 2063 | local_irq_save(flags); |
2065 | 2064 | ||
2066 | if (unlikely(hcd->state == HC_STATE_HALT || | 2065 | if (unlikely(hcd->state == HC_STATE_HALT || !HCD_HW_ACCESSIBLE(hcd))) { |
2067 | !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) { | ||
2068 | rc = IRQ_NONE; | 2066 | rc = IRQ_NONE; |
2069 | } else if (hcd->driver->irq(hcd) == IRQ_NONE) { | 2067 | } else if (hcd->driver->irq(hcd) == IRQ_NONE) { |
2070 | rc = IRQ_NONE; | 2068 | rc = IRQ_NONE; |
@@ -2098,7 +2096,7 @@ void usb_hc_died (struct usb_hcd *hcd) | |||
2098 | 2096 | ||
2099 | spin_lock_irqsave (&hcd_root_hub_lock, flags); | 2097 | spin_lock_irqsave (&hcd_root_hub_lock, flags); |
2100 | if (hcd->rh_registered) { | 2098 | if (hcd->rh_registered) { |
2101 | hcd->poll_rh = 0; | 2099 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
2102 | 2100 | ||
2103 | /* make khubd clean up old urbs and devices */ | 2101 | /* make khubd clean up old urbs and devices */ |
2104 | usb_set_device_state (hcd->self.root_hub, | 2102 | usb_set_device_state (hcd->self.root_hub, |
@@ -2301,7 +2299,7 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
2301 | retval); | 2299 | retval); |
2302 | goto error_create_attr_group; | 2300 | goto error_create_attr_group; |
2303 | } | 2301 | } |
2304 | if (hcd->uses_new_polling && hcd->poll_rh) | 2302 | if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) |
2305 | usb_hcd_poll_rh_status(hcd); | 2303 | usb_hcd_poll_rh_status(hcd); |
2306 | return retval; | 2304 | return retval; |
2307 | 2305 | ||
@@ -2320,11 +2318,11 @@ error_create_attr_group: | |||
2320 | mutex_unlock(&usb_bus_list_lock); | 2318 | mutex_unlock(&usb_bus_list_lock); |
2321 | err_register_root_hub: | 2319 | err_register_root_hub: |
2322 | hcd->rh_pollable = 0; | 2320 | hcd->rh_pollable = 0; |
2323 | hcd->poll_rh = 0; | 2321 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
2324 | del_timer_sync(&hcd->rh_timer); | 2322 | del_timer_sync(&hcd->rh_timer); |
2325 | hcd->driver->stop(hcd); | 2323 | hcd->driver->stop(hcd); |
2326 | hcd->state = HC_STATE_HALT; | 2324 | hcd->state = HC_STATE_HALT; |
2327 | hcd->poll_rh = 0; | 2325 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
2328 | del_timer_sync(&hcd->rh_timer); | 2326 | del_timer_sync(&hcd->rh_timer); |
2329 | err_hcd_driver_start: | 2327 | err_hcd_driver_start: |
2330 | if (hcd->irq >= 0) | 2328 | if (hcd->irq >= 0) |
@@ -2380,14 +2378,14 @@ void usb_remove_hcd(struct usb_hcd *hcd) | |||
2380 | * the hub_status_data() callback. | 2378 | * the hub_status_data() callback. |
2381 | */ | 2379 | */ |
2382 | hcd->rh_pollable = 0; | 2380 | hcd->rh_pollable = 0; |
2383 | hcd->poll_rh = 0; | 2381 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
2384 | del_timer_sync(&hcd->rh_timer); | 2382 | del_timer_sync(&hcd->rh_timer); |
2385 | 2383 | ||
2386 | hcd->driver->stop(hcd); | 2384 | hcd->driver->stop(hcd); |
2387 | hcd->state = HC_STATE_HALT; | 2385 | hcd->state = HC_STATE_HALT; |
2388 | 2386 | ||
2389 | /* In case the HCD restarted the timer, stop it again. */ | 2387 | /* In case the HCD restarted the timer, stop it again. */ |
2390 | hcd->poll_rh = 0; | 2388 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
2391 | del_timer_sync(&hcd->rh_timer); | 2389 | del_timer_sync(&hcd->rh_timer); |
2392 | 2390 | ||
2393 | if (hcd->irq >= 0) | 2391 | if (hcd->irq >= 0) |
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 4f9e578cde9d..dc6546248ed9 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -1542,7 +1542,7 @@ static int dummy_hub_status (struct usb_hcd *hcd, char *buf) | |||
1542 | dum = hcd_to_dummy (hcd); | 1542 | dum = hcd_to_dummy (hcd); |
1543 | 1543 | ||
1544 | spin_lock_irqsave (&dum->lock, flags); | 1544 | spin_lock_irqsave (&dum->lock, flags); |
1545 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 1545 | if (!HCD_HW_ACCESSIBLE(hcd)) |
1546 | goto done; | 1546 | goto done; |
1547 | 1547 | ||
1548 | if (dum->resuming && time_after_eq (jiffies, dum->re_timeout)) { | 1548 | if (dum->resuming && time_after_eq (jiffies, dum->re_timeout)) { |
@@ -1588,7 +1588,7 @@ static int dummy_hub_control ( | |||
1588 | int retval = 0; | 1588 | int retval = 0; |
1589 | unsigned long flags; | 1589 | unsigned long flags; |
1590 | 1590 | ||
1591 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 1591 | if (!HCD_HW_ACCESSIBLE(hcd)) |
1592 | return -ETIMEDOUT; | 1592 | return -ETIMEDOUT; |
1593 | 1593 | ||
1594 | dum = hcd_to_dummy (hcd); | 1594 | dum = hcd_to_dummy (hcd); |
@@ -1739,7 +1739,7 @@ static int dummy_bus_resume (struct usb_hcd *hcd) | |||
1739 | dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); | 1739 | dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); |
1740 | 1740 | ||
1741 | spin_lock_irq (&dum->lock); | 1741 | spin_lock_irq (&dum->lock); |
1742 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 1742 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
1743 | rc = -ESHUTDOWN; | 1743 | rc = -ESHUTDOWN; |
1744 | } else { | 1744 | } else { |
1745 | dum->rh_state = DUMMY_RH_RUNNING; | 1745 | dum->rh_state = DUMMY_RH_RUNNING; |
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index df5546bb8367..4498efb49b95 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c | |||
@@ -712,7 +712,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
712 | 712 | ||
713 | spin_lock_irqsave (&ehci->lock, flags); | 713 | spin_lock_irqsave (&ehci->lock, flags); |
714 | 714 | ||
715 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 715 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
716 | size = scnprintf (next, size, | 716 | size = scnprintf (next, size, |
717 | "bus %s, device %s\n" | 717 | "bus %s, device %s\n" |
718 | "%s\n" | 718 | "%s\n" |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 8697ad19f313..2a19336c9824 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -642,7 +642,6 @@ static int ehci_run (struct usb_hcd *hcd) | |||
642 | u32 hcc_params; | 642 | u32 hcc_params; |
643 | 643 | ||
644 | hcd->uses_new_polling = 1; | 644 | hcd->uses_new_polling = 1; |
645 | hcd->poll_rh = 0; | ||
646 | 645 | ||
647 | /* EHCI spec section 4.1 */ | 646 | /* EHCI spec section 4.1 */ |
648 | if ((retval = ehci_reset(ehci)) != 0) { | 647 | if ((retval = ehci_reset(ehci)) != 0) { |
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 84e792d71c22..0931f5a7dec4 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -316,7 +316,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
316 | if (time_before (jiffies, ehci->next_statechange)) | 316 | if (time_before (jiffies, ehci->next_statechange)) |
317 | msleep(5); | 317 | msleep(5); |
318 | spin_lock_irq (&ehci->lock); | 318 | spin_lock_irq (&ehci->lock); |
319 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 319 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
320 | spin_unlock_irq(&ehci->lock); | 320 | spin_unlock_irq(&ehci->lock); |
321 | return -ESHUTDOWN; | 321 | return -ESHUTDOWN; |
322 | } | 322 | } |
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 11a79c4f4a9d..233c288e3f93 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
@@ -1126,8 +1126,7 @@ submit_async ( | |||
1126 | #endif | 1126 | #endif |
1127 | 1127 | ||
1128 | spin_lock_irqsave (&ehci->lock, flags); | 1128 | spin_lock_irqsave (&ehci->lock, flags); |
1129 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 1129 | if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { |
1130 | &ehci_to_hcd(ehci)->flags))) { | ||
1131 | rc = -ESHUTDOWN; | 1130 | rc = -ESHUTDOWN; |
1132 | goto done; | 1131 | goto done; |
1133 | } | 1132 | } |
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 805ec633a652..d640346f9b56 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -880,8 +880,7 @@ static int intr_submit ( | |||
880 | 880 | ||
881 | spin_lock_irqsave (&ehci->lock, flags); | 881 | spin_lock_irqsave (&ehci->lock, flags); |
882 | 882 | ||
883 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 883 | if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { |
884 | &ehci_to_hcd(ehci)->flags))) { | ||
885 | status = -ESHUTDOWN; | 884 | status = -ESHUTDOWN; |
886 | goto done_not_linked; | 885 | goto done_not_linked; |
887 | } | 886 | } |
@@ -1815,8 +1814,7 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, | |||
1815 | 1814 | ||
1816 | /* schedule ... need to lock */ | 1815 | /* schedule ... need to lock */ |
1817 | spin_lock_irqsave (&ehci->lock, flags); | 1816 | spin_lock_irqsave (&ehci->lock, flags); |
1818 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 1817 | if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { |
1819 | &ehci_to_hcd(ehci)->flags))) { | ||
1820 | status = -ESHUTDOWN; | 1818 | status = -ESHUTDOWN; |
1821 | goto done_not_linked; | 1819 | goto done_not_linked; |
1822 | } | 1820 | } |
@@ -2201,8 +2199,7 @@ static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, | |||
2201 | 2199 | ||
2202 | /* schedule ... need to lock */ | 2200 | /* schedule ... need to lock */ |
2203 | spin_lock_irqsave (&ehci->lock, flags); | 2201 | spin_lock_irqsave (&ehci->lock, flags); |
2204 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 2202 | if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { |
2205 | &ehci_to_hcd(ehci)->flags))) { | ||
2206 | status = -ESHUTDOWN; | 2203 | status = -ESHUTDOWN; |
2207 | goto done_not_linked; | 2204 | goto done_not_linked; |
2208 | } | 2205 | } |
diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c index 35742f8c7cda..9bfac657572e 100644 --- a/drivers/usb/host/hwa-hc.c +++ b/drivers/usb/host/hwa-hc.c | |||
@@ -159,7 +159,7 @@ static int hwahc_op_start(struct usb_hcd *usb_hcd) | |||
159 | goto error_set_cluster_id; | 159 | goto error_set_cluster_id; |
160 | 160 | ||
161 | usb_hcd->uses_new_polling = 1; | 161 | usb_hcd->uses_new_polling = 1; |
162 | usb_hcd->poll_rh = 1; | 162 | set_bit(HCD_FLAG_POLL_RH, &usb_hcd->flags); |
163 | usb_hcd->state = HC_STATE_RUNNING; | 163 | usb_hcd->state = HC_STATE_RUNNING; |
164 | result = 0; | 164 | result = 0; |
165 | out: | 165 | out: |
@@ -776,7 +776,7 @@ static int hwahc_probe(struct usb_interface *usb_iface, | |||
776 | goto error_alloc; | 776 | goto error_alloc; |
777 | } | 777 | } |
778 | usb_hcd->wireless = 1; | 778 | usb_hcd->wireless = 1; |
779 | usb_hcd->flags |= HCD_FLAG_SAW_IRQ; | 779 | set_bit(HCD_FLAG_SAW_IRQ, &usb_hcd->flags); |
780 | wusbhc = usb_hcd_to_wusbhc(usb_hcd); | 780 | wusbhc = usb_hcd_to_wusbhc(usb_hcd); |
781 | hwahc = container_of(wusbhc, struct hwahc, wusbhc); | 781 | hwahc = container_of(wusbhc, struct hwahc, wusbhc); |
782 | hwahc_init(hwahc); | 782 | hwahc_init(hwahc); |
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c index dbcafa29c775..d1a3dfc9a408 100644 --- a/drivers/usb/host/isp1760-hcd.c +++ b/drivers/usb/host/isp1760-hcd.c | |||
@@ -482,7 +482,6 @@ static int isp1760_run(struct usb_hcd *hcd) | |||
482 | u32 chipid; | 482 | u32 chipid; |
483 | 483 | ||
484 | hcd->uses_new_polling = 1; | 484 | hcd->uses_new_polling = 1; |
485 | hcd->poll_rh = 0; | ||
486 | 485 | ||
487 | hcd->state = HC_STATE_RUNNING; | 486 | hcd->state = HC_STATE_RUNNING; |
488 | isp1760_enable_interrupts(hcd); | 487 | isp1760_enable_interrupts(hcd); |
@@ -1450,7 +1449,7 @@ static int isp1760_prepare_enqueue(struct isp1760_hcd *priv, struct urb *urb, | |||
1450 | epnum = urb->ep->desc.bEndpointAddress; | 1449 | epnum = urb->ep->desc.bEndpointAddress; |
1451 | 1450 | ||
1452 | spin_lock_irqsave(&priv->lock, flags); | 1451 | spin_lock_irqsave(&priv->lock, flags); |
1453 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &priv_to_hcd(priv)->flags)) { | 1452 | if (!HCD_HW_ACCESSIBLE(priv_to_hcd(priv))) { |
1454 | rc = -ESHUTDOWN; | 1453 | rc = -ESHUTDOWN; |
1455 | goto done; | 1454 | goto done; |
1456 | } | 1455 | } |
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index 8ad2441b0284..36abd2baa3ea 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c | |||
@@ -645,7 +645,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
645 | hcd->product_desc, | 645 | hcd->product_desc, |
646 | hcd_name); | 646 | hcd_name); |
647 | 647 | ||
648 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 648 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
649 | size -= scnprintf (next, size, | 649 | size -= scnprintf (next, size, |
650 | "SUSPENDED (no register access)\n"); | 650 | "SUSPENDED (no register access)\n"); |
651 | goto done; | 651 | goto done; |
@@ -687,7 +687,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
687 | next += temp; | 687 | next += temp; |
688 | 688 | ||
689 | temp = scnprintf (next, size, "hub poll timer %s\n", | 689 | temp = scnprintf (next, size, "hub poll timer %s\n", |
690 | ohci_to_hcd(ohci)->poll_rh ? "ON" : "off"); | 690 | HCD_POLL_RH(ohci_to_hcd(ohci)) ? "ON" : "off"); |
691 | size -= temp; | 691 | size -= temp; |
692 | next += temp; | 692 | next += temp; |
693 | 693 | ||
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 02864a237a2c..c3b4ccc7337b 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -212,7 +212,7 @@ static int ohci_urb_enqueue ( | |||
212 | spin_lock_irqsave (&ohci->lock, flags); | 212 | spin_lock_irqsave (&ohci->lock, flags); |
213 | 213 | ||
214 | /* don't submit to a dead HC */ | 214 | /* don't submit to a dead HC */ |
215 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 215 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
216 | retval = -ENODEV; | 216 | retval = -ENODEV; |
217 | goto fail; | 217 | goto fail; |
218 | } | 218 | } |
@@ -685,7 +685,7 @@ retry: | |||
685 | } | 685 | } |
686 | 686 | ||
687 | /* use rhsc irqs after khubd is fully initialized */ | 687 | /* use rhsc irqs after khubd is fully initialized */ |
688 | hcd->poll_rh = 1; | 688 | set_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
689 | hcd->uses_new_polling = 1; | 689 | hcd->uses_new_polling = 1; |
690 | 690 | ||
691 | /* start controller operations */ | 691 | /* start controller operations */ |
@@ -822,7 +822,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) | |||
822 | else if (ints & OHCI_INTR_RD) { | 822 | else if (ints & OHCI_INTR_RD) { |
823 | ohci_vdbg(ohci, "resume detect\n"); | 823 | ohci_vdbg(ohci, "resume detect\n"); |
824 | ohci_writel(ohci, OHCI_INTR_RD, ®s->intrstatus); | 824 | ohci_writel(ohci, OHCI_INTR_RD, ®s->intrstatus); |
825 | hcd->poll_rh = 1; | 825 | set_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
826 | if (ohci->autostop) { | 826 | if (ohci->autostop) { |
827 | spin_lock (&ohci->lock); | 827 | spin_lock (&ohci->lock); |
828 | ohci_rh_resume (ohci); | 828 | ohci_rh_resume (ohci); |
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 65cac8cc8921..4dd39022c388 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
@@ -284,7 +284,7 @@ static int ohci_bus_suspend (struct usb_hcd *hcd) | |||
284 | 284 | ||
285 | spin_lock_irq (&ohci->lock); | 285 | spin_lock_irq (&ohci->lock); |
286 | 286 | ||
287 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) | 287 | if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) |
288 | rc = -ESHUTDOWN; | 288 | rc = -ESHUTDOWN; |
289 | else | 289 | else |
290 | rc = ohci_rh_suspend (ohci, 0); | 290 | rc = ohci_rh_suspend (ohci, 0); |
@@ -302,7 +302,7 @@ static int ohci_bus_resume (struct usb_hcd *hcd) | |||
302 | 302 | ||
303 | spin_lock_irq (&ohci->lock); | 303 | spin_lock_irq (&ohci->lock); |
304 | 304 | ||
305 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) | 305 | if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) |
306 | rc = -ESHUTDOWN; | 306 | rc = -ESHUTDOWN; |
307 | else | 307 | else |
308 | rc = ohci_rh_resume (ohci); | 308 | rc = ohci_rh_resume (ohci); |
@@ -489,7 +489,7 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
489 | unsigned long flags; | 489 | unsigned long flags; |
490 | 490 | ||
491 | spin_lock_irqsave (&ohci->lock, flags); | 491 | spin_lock_irqsave (&ohci->lock, flags); |
492 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 492 | if (!HCD_HW_ACCESSIBLE(hcd)) |
493 | goto done; | 493 | goto done; |
494 | 494 | ||
495 | /* undocumented erratum seen on at least rev D */ | 495 | /* undocumented erratum seen on at least rev D */ |
@@ -533,8 +533,12 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
533 | } | 533 | } |
534 | } | 534 | } |
535 | 535 | ||
536 | hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed, | 536 | if (ohci_root_hub_state_changes(ohci, changed, |
537 | any_connected, rhsc_status); | 537 | any_connected, rhsc_status)) |
538 | set_bit(HCD_FLAG_POLL_RH, &hcd->flags); | ||
539 | else | ||
540 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); | ||
541 | |||
538 | 542 | ||
539 | done: | 543 | done: |
540 | spin_unlock_irqrestore (&ohci->lock, flags); | 544 | spin_unlock_irqrestore (&ohci->lock, flags); |
@@ -701,7 +705,7 @@ static int ohci_hub_control ( | |||
701 | u32 temp; | 705 | u32 temp; |
702 | int retval = 0; | 706 | int retval = 0; |
703 | 707 | ||
704 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) | 708 | if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) |
705 | return -ESHUTDOWN; | 709 | return -ESHUTDOWN; |
706 | 710 | ||
707 | switch (typeReq) { | 711 | switch (typeReq) { |
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c index f608dfd09a8a..d9c85a292737 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c | |||
@@ -1641,8 +1641,7 @@ static int submit_async(struct oxu_hcd *oxu, struct urb *urb, | |||
1641 | #endif | 1641 | #endif |
1642 | 1642 | ||
1643 | spin_lock_irqsave(&oxu->lock, flags); | 1643 | spin_lock_irqsave(&oxu->lock, flags); |
1644 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 1644 | if (unlikely(!HCD_HW_ACCESSIBLE(oxu_to_hcd(oxu)))) { |
1645 | &oxu_to_hcd(oxu)->flags))) { | ||
1646 | rc = -ESHUTDOWN; | 1645 | rc = -ESHUTDOWN; |
1647 | goto done; | 1646 | goto done; |
1648 | } | 1647 | } |
@@ -2209,8 +2208,7 @@ static int intr_submit(struct oxu_hcd *oxu, struct urb *urb, | |||
2209 | 2208 | ||
2210 | spin_lock_irqsave(&oxu->lock, flags); | 2209 | spin_lock_irqsave(&oxu->lock, flags); |
2211 | 2210 | ||
2212 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | 2211 | if (unlikely(!HCD_HW_ACCESSIBLE(oxu_to_hcd(oxu)))) { |
2213 | &oxu_to_hcd(oxu)->flags))) { | ||
2214 | status = -ESHUTDOWN; | 2212 | status = -ESHUTDOWN; |
2215 | goto done; | 2213 | goto done; |
2216 | } | 2214 | } |
@@ -2715,7 +2713,6 @@ static int oxu_run(struct usb_hcd *hcd) | |||
2715 | u32 temp, hcc_params; | 2713 | u32 temp, hcc_params; |
2716 | 2714 | ||
2717 | hcd->uses_new_polling = 1; | 2715 | hcd->uses_new_polling = 1; |
2718 | hcd->poll_rh = 0; | ||
2719 | 2716 | ||
2720 | /* EHCI spec section 4.1 */ | 2717 | /* EHCI spec section 4.1 */ |
2721 | retval = ehci_reset(oxu); | 2718 | retval = ehci_reset(oxu); |
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index d1dce2166eff..2743ec770f0c 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -140,7 +140,7 @@ static void finish_reset(struct uhci_hcd *uhci) | |||
140 | uhci->rh_state = UHCI_RH_RESET; | 140 | uhci->rh_state = UHCI_RH_RESET; |
141 | uhci->is_stopped = UHCI_IS_STOPPED; | 141 | uhci->is_stopped = UHCI_IS_STOPPED; |
142 | uhci_to_hcd(uhci)->state = HC_STATE_HALT; | 142 | uhci_to_hcd(uhci)->state = HC_STATE_HALT; |
143 | uhci_to_hcd(uhci)->poll_rh = 0; | 143 | clear_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); |
144 | 144 | ||
145 | uhci->dead = 0; /* Full reset resurrects the controller */ | 145 | uhci->dead = 0; /* Full reset resurrects the controller */ |
146 | } | 146 | } |
@@ -344,7 +344,10 @@ __acquires(uhci->lock) | |||
344 | /* If interrupts don't work and remote wakeup is enabled then | 344 | /* If interrupts don't work and remote wakeup is enabled then |
345 | * the suspended root hub needs to be polled. | 345 | * the suspended root hub needs to be polled. |
346 | */ | 346 | */ |
347 | uhci_to_hcd(uhci)->poll_rh = (!int_enable && wakeup_enable); | 347 | if (!int_enable && wakeup_enable) |
348 | set_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); | ||
349 | else | ||
350 | clear_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); | ||
348 | 351 | ||
349 | uhci_scan_schedule(uhci); | 352 | uhci_scan_schedule(uhci); |
350 | uhci_fsbr_off(uhci); | 353 | uhci_fsbr_off(uhci); |
@@ -363,7 +366,7 @@ static void start_rh(struct uhci_hcd *uhci) | |||
363 | uhci->io_addr + USBINTR); | 366 | uhci->io_addr + USBINTR); |
364 | mb(); | 367 | mb(); |
365 | uhci->rh_state = UHCI_RH_RUNNING; | 368 | uhci->rh_state = UHCI_RH_RUNNING; |
366 | uhci_to_hcd(uhci)->poll_rh = 1; | 369 | set_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); |
367 | } | 370 | } |
368 | 371 | ||
369 | static void wakeup_rh(struct uhci_hcd *uhci) | 372 | static void wakeup_rh(struct uhci_hcd *uhci) |
@@ -733,7 +736,7 @@ static void uhci_stop(struct usb_hcd *hcd) | |||
733 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); | 736 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); |
734 | 737 | ||
735 | spin_lock_irq(&uhci->lock); | 738 | spin_lock_irq(&uhci->lock); |
736 | if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) && !uhci->dead) | 739 | if (HCD_HW_ACCESSIBLE(hcd) && !uhci->dead) |
737 | uhci_hc_died(uhci); | 740 | uhci_hc_died(uhci); |
738 | uhci_scan_schedule(uhci); | 741 | uhci_scan_schedule(uhci); |
739 | spin_unlock_irq(&uhci->lock); | 742 | spin_unlock_irq(&uhci->lock); |
@@ -750,7 +753,7 @@ static int uhci_rh_suspend(struct usb_hcd *hcd) | |||
750 | int rc = 0; | 753 | int rc = 0; |
751 | 754 | ||
752 | spin_lock_irq(&uhci->lock); | 755 | spin_lock_irq(&uhci->lock); |
753 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 756 | if (!HCD_HW_ACCESSIBLE(hcd)) |
754 | rc = -ESHUTDOWN; | 757 | rc = -ESHUTDOWN; |
755 | else if (uhci->dead) | 758 | else if (uhci->dead) |
756 | ; /* Dead controllers tell no tales */ | 759 | ; /* Dead controllers tell no tales */ |
@@ -777,7 +780,7 @@ static int uhci_rh_resume(struct usb_hcd *hcd) | |||
777 | int rc = 0; | 780 | int rc = 0; |
778 | 781 | ||
779 | spin_lock_irq(&uhci->lock); | 782 | spin_lock_irq(&uhci->lock); |
780 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) | 783 | if (!HCD_HW_ACCESSIBLE(hcd)) |
781 | rc = -ESHUTDOWN; | 784 | rc = -ESHUTDOWN; |
782 | else if (!uhci->dead) | 785 | else if (!uhci->dead) |
783 | wakeup_rh(uhci); | 786 | wakeup_rh(uhci); |
@@ -793,7 +796,7 @@ static int uhci_pci_suspend(struct usb_hcd *hcd) | |||
793 | dev_dbg(uhci_dev(uhci), "%s\n", __func__); | 796 | dev_dbg(uhci_dev(uhci), "%s\n", __func__); |
794 | 797 | ||
795 | spin_lock_irq(&uhci->lock); | 798 | spin_lock_irq(&uhci->lock); |
796 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) | 799 | if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead) |
797 | goto done_okay; /* Already suspended or dead */ | 800 | goto done_okay; /* Already suspended or dead */ |
798 | 801 | ||
799 | if (uhci->rh_state > UHCI_RH_SUSPENDED) { | 802 | if (uhci->rh_state > UHCI_RH_SUSPENDED) { |
@@ -807,7 +810,7 @@ static int uhci_pci_suspend(struct usb_hcd *hcd) | |||
807 | */ | 810 | */ |
808 | pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0); | 811 | pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0); |
809 | mb(); | 812 | mb(); |
810 | hcd->poll_rh = 0; | 813 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
811 | 814 | ||
812 | /* FIXME: Enable non-PME# remote wakeup? */ | 815 | /* FIXME: Enable non-PME# remote wakeup? */ |
813 | 816 | ||
@@ -860,7 +863,7 @@ static int uhci_pci_resume(struct usb_hcd *hcd, bool hibernated) | |||
860 | * the suspended root hub needs to be polled. | 863 | * the suspended root hub needs to be polled. |
861 | */ | 864 | */ |
862 | if (!uhci->RD_enable && hcd->self.root_hub->do_remote_wakeup) { | 865 | if (!uhci->RD_enable && hcd->self.root_hub->do_remote_wakeup) { |
863 | hcd->poll_rh = 1; | 866 | set_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
864 | usb_hcd_poll_rh_status(hcd); | 867 | usb_hcd_poll_rh_status(hcd); |
865 | } | 868 | } |
866 | return 0; | 869 | return 0; |
diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c index 8270055848ca..f0c58116c0ad 100644 --- a/drivers/usb/host/uhci-hub.c +++ b/drivers/usb/host/uhci-hub.c | |||
@@ -190,7 +190,7 @@ static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
190 | spin_lock_irqsave(&uhci->lock, flags); | 190 | spin_lock_irqsave(&uhci->lock, flags); |
191 | 191 | ||
192 | uhci_scan_schedule(uhci); | 192 | uhci_scan_schedule(uhci); |
193 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) | 193 | if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead) |
194 | goto done; | 194 | goto done; |
195 | uhci_check_ports(uhci); | 195 | uhci_check_ports(uhci); |
196 | 196 | ||
@@ -246,7 +246,7 @@ static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
246 | u16 wPortChange, wPortStatus; | 246 | u16 wPortChange, wPortStatus; |
247 | unsigned long flags; | 247 | unsigned long flags; |
248 | 248 | ||
249 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) | 249 | if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead) |
250 | return -ETIMEDOUT; | 250 | return -ETIMEDOUT; |
251 | 251 | ||
252 | spin_lock_irqsave(&uhci->lock, flags); | 252 | spin_lock_irqsave(&uhci->lock, flags); |
diff --git a/drivers/usb/host/whci/hcd.c b/drivers/usb/host/whci/hcd.c index e0d3401285c8..72b6892fda67 100644 --- a/drivers/usb/host/whci/hcd.c +++ b/drivers/usb/host/whci/hcd.c | |||
@@ -68,7 +68,7 @@ static int whc_start(struct usb_hcd *usb_hcd) | |||
68 | whc_write_wusbcmd(whc, WUSBCMD_RUN, WUSBCMD_RUN); | 68 | whc_write_wusbcmd(whc, WUSBCMD_RUN, WUSBCMD_RUN); |
69 | 69 | ||
70 | usb_hcd->uses_new_polling = 1; | 70 | usb_hcd->uses_new_polling = 1; |
71 | usb_hcd->poll_rh = 1; | 71 | set_bit(HCD_FLAG_POLL_RH, &usb_hcd->flags); |
72 | usb_hcd->state = HC_STATE_RUNNING; | 72 | usb_hcd->state = HC_STATE_RUNNING; |
73 | 73 | ||
74 | out: | 74 | out: |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 343f1047f5d0..5e73386b3899 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -427,7 +427,6 @@ int xhci_run(struct usb_hcd *hcd) | |||
427 | void (*doorbell)(struct xhci_hcd *) = NULL; | 427 | void (*doorbell)(struct xhci_hcd *) = NULL; |
428 | 428 | ||
429 | hcd->uses_new_polling = 1; | 429 | hcd->uses_new_polling = 1; |
430 | hcd->poll_rh = 0; | ||
431 | 430 | ||
432 | xhci_dbg(xhci, "xhci_run\n"); | 431 | xhci_dbg(xhci, "xhci_run\n"); |
433 | #if 0 /* FIXME: MSI not setup yet */ | 432 | #if 0 /* FIXME: MSI not setup yet */ |
@@ -733,7 +732,7 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) | |||
733 | ret = -EINVAL; | 732 | ret = -EINVAL; |
734 | goto exit; | 733 | goto exit; |
735 | } | 734 | } |
736 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 735 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
737 | if (!in_interrupt()) | 736 | if (!in_interrupt()) |
738 | xhci_dbg(xhci, "urb submitted during PCI suspend\n"); | 737 | xhci_dbg(xhci, "urb submitted during PCI suspend\n"); |
739 | ret = -ESHUTDOWN; | 738 | ret = -ESHUTDOWN; |
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index 92e85e027cfb..43233c397b6e 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c | |||
@@ -244,7 +244,7 @@ int musb_hub_control( | |||
244 | 244 | ||
245 | spin_lock_irqsave(&musb->lock, flags); | 245 | spin_lock_irqsave(&musb->lock, flags); |
246 | 246 | ||
247 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) { | 247 | if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) { |
248 | spin_unlock_irqrestore(&musb->lock, flags); | 248 | spin_unlock_irqrestore(&musb->lock, flags); |
249 | return -ESHUTDOWN; | 249 | return -ESHUTDOWN; |
250 | } | 250 | } |
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 9b867e64a0f4..f8f8fa7a56e8 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h | |||
@@ -89,19 +89,31 @@ struct usb_hcd { | |||
89 | */ | 89 | */ |
90 | const struct hc_driver *driver; /* hw-specific hooks */ | 90 | const struct hc_driver *driver; /* hw-specific hooks */ |
91 | 91 | ||
92 | /* Flags that need to be manipulated atomically */ | 92 | /* Flags that need to be manipulated atomically because they can |
93 | * change while the host controller is running. Always use | ||
94 | * set_bit() or clear_bit() to change their values. | ||
95 | */ | ||
93 | unsigned long flags; | 96 | unsigned long flags; |
94 | #define HCD_FLAG_HW_ACCESSIBLE 0x00000001 | 97 | #define HCD_FLAG_HW_ACCESSIBLE 0 /* at full power */ |
95 | #define HCD_FLAG_SAW_IRQ 0x00000002 | 98 | #define HCD_FLAG_SAW_IRQ 1 |
99 | #define HCD_FLAG_POLL_RH 2 /* poll for rh status? */ | ||
100 | #define HCD_FLAG_POLL_PENDING 3 /* status has changed? */ | ||
101 | |||
102 | /* The flags can be tested using these macros; they are likely to | ||
103 | * be slightly faster than test_bit(). | ||
104 | */ | ||
105 | #define HCD_HW_ACCESSIBLE(hcd) ((hcd)->flags & (1U << HCD_FLAG_HW_ACCESSIBLE)) | ||
106 | #define HCD_SAW_IRQ(hcd) ((hcd)->flags & (1U << HCD_FLAG_SAW_IRQ)) | ||
107 | #define HCD_POLL_RH(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_RH)) | ||
108 | #define HCD_POLL_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_PENDING)) | ||
96 | 109 | ||
110 | /* Flags that get set only during HCD registration or removal. */ | ||
97 | unsigned rh_registered:1;/* is root hub registered? */ | 111 | unsigned rh_registered:1;/* is root hub registered? */ |
98 | unsigned rh_pollable:1; /* may we poll the root hub? */ | 112 | unsigned rh_pollable:1; /* may we poll the root hub? */ |
99 | 113 | ||
100 | /* The next flag is a stopgap, to be removed when all the HCDs | 114 | /* The next flag is a stopgap, to be removed when all the HCDs |
101 | * support the new root-hub polling mechanism. */ | 115 | * support the new root-hub polling mechanism. */ |
102 | unsigned uses_new_polling:1; | 116 | unsigned uses_new_polling:1; |
103 | unsigned poll_rh:1; /* poll for rh status? */ | ||
104 | unsigned poll_pending:1; /* status has changed? */ | ||
105 | unsigned wireless:1; /* Wireless USB HCD */ | 117 | unsigned wireless:1; /* Wireless USB HCD */ |
106 | unsigned authorized_default:1; | 118 | unsigned authorized_default:1; |
107 | unsigned has_tt:1; /* Integrated TT in root hub */ | 119 | unsigned has_tt:1; /* Integrated TT in root hub */ |