Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
541c7d43 89ba85d4

+80 -73
+3 -3
drivers/staging/usbip/vhci_hcd.c
··· 215 215 vhci = hcd_to_vhci(hcd); 216 216 217 217 spin_lock_irqsave(&vhci->lock, flags); 218 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { 218 + if (!HCD_HW_ACCESSIBLE(hcd)) { 219 219 usbip_dbg_vhci_rh("hw accessible flag in on?\n"); 220 220 goto done; 221 221 } ··· 269 269 270 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 273 return -ETIMEDOUT; 274 274 275 275 /* ··· 1041 1041 dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__); 1042 1042 1043 1043 spin_lock_irq(&vhci->lock); 1044 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { 1044 + if (!HCD_HW_ACCESSIBLE(hcd)) { 1045 1045 rc = -ESHUTDOWN; 1046 1046 } else { 1047 1047 /* vhci->rh_state = DUMMY_RH_RUNNING;
+2 -2
drivers/usb/c67x00/c67x00-hcd.c
··· 264 264 if (unlikely(hcd->state == HC_STATE_HALT)) 265 265 return; 266 266 267 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) 267 + if (!HCD_HW_ACCESSIBLE(hcd)) 268 268 return; 269 269 270 270 /* Handle Start of frame events */ ··· 282 282 { 283 283 hcd->uses_new_polling = 1; 284 284 hcd->state = HC_STATE_RUNNING; 285 - hcd->poll_rh = 1; 285 + set_bit(HCD_FLAG_POLL_RH, &hcd->flags); 286 286 287 287 return 0; 288 288 }
+12 -14
drivers/usb/core/hcd.c
··· 679 679 spin_lock_irqsave(&hcd_root_hub_lock, flags); 680 680 urb = hcd->status_urb; 681 681 if (urb) { 682 - hcd->poll_pending = 0; 682 + clear_bit(HCD_FLAG_POLL_PENDING, &hcd->flags); 683 683 hcd->status_urb = NULL; 684 684 urb->actual_length = length; 685 685 memcpy(urb->transfer_buffer, buffer, length); ··· 690 690 spin_lock(&hcd_root_hub_lock); 691 691 } else { 692 692 length = 0; 693 - hcd->poll_pending = 1; 693 + set_bit(HCD_FLAG_POLL_PENDING, &hcd->flags); 694 694 } 695 695 spin_unlock_irqrestore(&hcd_root_hub_lock, flags); 696 696 } ··· 699 699 * exceed that limit if HZ is 100. The math is more clunky than 700 700 * maybe expected, this is to make sure that all timers for USB devices 701 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 703 (length == 0 && hcd->status_urb != NULL)) 704 704 mod_timer (&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); 705 705 } ··· 736 736 mod_timer(&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); 737 737 738 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 740 mod_timer(&hcd->rh_timer, jiffies); 741 741 retval = 0; 742 742 done: ··· 1150 1150 * finish unlinking the initial failed usb_set_address() 1151 1151 * or device descriptor fetch. 1152 1152 */ 1153 - if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags) && 1154 - !is_root_hub(urb->dev)) { 1153 + if (!HCD_SAW_IRQ(hcd) && !is_root_hub(urb->dev)) { 1155 1154 dev_warn(hcd->self.controller, "Unlink after no-IRQ? " 1156 1155 "Controller is probably using the wrong IRQ.\n"); 1157 1156 set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); ··· 2062 2063 */ 2063 2064 local_irq_save(flags); 2064 2065 2065 - if (unlikely(hcd->state == HC_STATE_HALT || 2066 - !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) { 2066 + if (unlikely(hcd->state == HC_STATE_HALT || !HCD_HW_ACCESSIBLE(hcd))) { 2067 2067 rc = IRQ_NONE; 2068 2068 } else if (hcd->driver->irq(hcd) == IRQ_NONE) { 2069 2069 rc = IRQ_NONE; ··· 2096 2098 2097 2099 spin_lock_irqsave (&hcd_root_hub_lock, flags); 2098 2100 if (hcd->rh_registered) { 2099 - hcd->poll_rh = 0; 2101 + clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); 2100 2102 2101 2103 /* make khubd clean up old urbs and devices */ 2102 2104 usb_set_device_state (hcd->self.root_hub, ··· 2299 2301 retval); 2300 2302 goto error_create_attr_group; 2301 2303 } 2302 - if (hcd->uses_new_polling && hcd->poll_rh) 2304 + if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) 2303 2305 usb_hcd_poll_rh_status(hcd); 2304 2306 return retval; 2305 2307 ··· 2318 2320 mutex_unlock(&usb_bus_list_lock); 2319 2321 err_register_root_hub: 2320 2322 hcd->rh_pollable = 0; 2321 - hcd->poll_rh = 0; 2323 + clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); 2322 2324 del_timer_sync(&hcd->rh_timer); 2323 2325 hcd->driver->stop(hcd); 2324 2326 hcd->state = HC_STATE_HALT; 2325 - hcd->poll_rh = 0; 2327 + clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); 2326 2328 del_timer_sync(&hcd->rh_timer); 2327 2329 err_hcd_driver_start: 2328 2330 if (hcd->irq >= 0) ··· 2378 2380 * the hub_status_data() callback. 2379 2381 */ 2380 2382 hcd->rh_pollable = 0; 2381 - hcd->poll_rh = 0; 2383 + clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); 2382 2384 del_timer_sync(&hcd->rh_timer); 2383 2385 2384 2386 hcd->driver->stop(hcd); 2385 2387 hcd->state = HC_STATE_HALT; 2386 2388 2387 2389 /* In case the HCD restarted the timer, stop it again. */ 2388 - hcd->poll_rh = 0; 2390 + clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); 2389 2391 del_timer_sync(&hcd->rh_timer); 2390 2392 2391 2393 if (hcd->irq >= 0)
+3 -3
drivers/usb/gadget/dummy_hcd.c
··· 1542 1542 dum = hcd_to_dummy (hcd); 1543 1543 1544 1544 spin_lock_irqsave (&dum->lock, flags); 1545 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) 1545 + if (!HCD_HW_ACCESSIBLE(hcd)) 1546 1546 goto done; 1547 1547 1548 1548 if (dum->resuming && time_after_eq (jiffies, dum->re_timeout)) { ··· 1588 1588 int retval = 0; 1589 1589 unsigned long flags; 1590 1590 1591 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) 1591 + if (!HCD_HW_ACCESSIBLE(hcd)) 1592 1592 return -ETIMEDOUT; 1593 1593 1594 1594 dum = hcd_to_dummy (hcd); ··· 1739 1739 dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); 1740 1740 1741 1741 spin_lock_irq (&dum->lock); 1742 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { 1742 + if (!HCD_HW_ACCESSIBLE(hcd)) { 1743 1743 rc = -ESHUTDOWN; 1744 1744 } else { 1745 1745 dum->rh_state = DUMMY_RH_RUNNING;
+1 -1
drivers/usb/host/ehci-dbg.c
··· 712 712 713 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 716 size = scnprintf (next, size, 717 717 "bus %s, device %s\n" 718 718 "%s\n"
-1
drivers/usb/host/ehci-hcd.c
··· 642 642 u32 hcc_params; 643 643 644 644 hcd->uses_new_polling = 1; 645 - hcd->poll_rh = 0; 646 645 647 646 /* EHCI spec section 4.1 */ 648 647 if ((retval = ehci_reset(ehci)) != 0) {
+1 -1
drivers/usb/host/ehci-hub.c
··· 316 316 if (time_before (jiffies, ehci->next_statechange)) 317 317 msleep(5); 318 318 spin_lock_irq (&ehci->lock); 319 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { 319 + if (!HCD_HW_ACCESSIBLE(hcd)) { 320 320 spin_unlock_irq(&ehci->lock); 321 321 return -ESHUTDOWN; 322 322 }
+1 -2
drivers/usb/host/ehci-q.c
··· 1126 1126 #endif 1127 1127 1128 1128 spin_lock_irqsave (&ehci->lock, flags); 1129 - if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, 1130 - &ehci_to_hcd(ehci)->flags))) { 1129 + if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { 1131 1130 rc = -ESHUTDOWN; 1132 1131 goto done; 1133 1132 }
+3 -6
drivers/usb/host/ehci-sched.c
··· 880 880 881 881 spin_lock_irqsave (&ehci->lock, flags); 882 882 883 - if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, 884 - &ehci_to_hcd(ehci)->flags))) { 883 + if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { 885 884 status = -ESHUTDOWN; 886 885 goto done_not_linked; 887 886 } ··· 1814 1815 1815 1816 /* schedule ... need to lock */ 1816 1817 spin_lock_irqsave (&ehci->lock, flags); 1817 - if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, 1818 - &ehci_to_hcd(ehci)->flags))) { 1818 + if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { 1819 1819 status = -ESHUTDOWN; 1820 1820 goto done_not_linked; 1821 1821 } ··· 2199 2201 2200 2202 /* schedule ... need to lock */ 2201 2203 spin_lock_irqsave (&ehci->lock, flags); 2202 - if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, 2203 - &ehci_to_hcd(ehci)->flags))) { 2204 + if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { 2204 2205 status = -ESHUTDOWN; 2205 2206 goto done_not_linked; 2206 2207 }
+2 -2
drivers/usb/host/hwa-hc.c
··· 159 159 goto error_set_cluster_id; 160 160 161 161 usb_hcd->uses_new_polling = 1; 162 - usb_hcd->poll_rh = 1; 162 + set_bit(HCD_FLAG_POLL_RH, &usb_hcd->flags); 163 163 usb_hcd->state = HC_STATE_RUNNING; 164 164 result = 0; 165 165 out: ··· 776 776 goto error_alloc; 777 777 } 778 778 usb_hcd->wireless = 1; 779 - usb_hcd->flags |= HCD_FLAG_SAW_IRQ; 779 + set_bit(HCD_FLAG_SAW_IRQ, &usb_hcd->flags); 780 780 wusbhc = usb_hcd_to_wusbhc(usb_hcd); 781 781 hwahc = container_of(wusbhc, struct hwahc, wusbhc); 782 782 hwahc_init(hwahc);
+1 -2
drivers/usb/host/isp1760-hcd.c
··· 482 482 u32 chipid; 483 483 484 484 hcd->uses_new_polling = 1; 485 - hcd->poll_rh = 0; 486 485 487 486 hcd->state = HC_STATE_RUNNING; 488 487 isp1760_enable_interrupts(hcd); ··· 1449 1450 epnum = urb->ep->desc.bEndpointAddress; 1450 1451 1451 1452 spin_lock_irqsave(&priv->lock, flags); 1452 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &priv_to_hcd(priv)->flags)) { 1453 + if (!HCD_HW_ACCESSIBLE(priv_to_hcd(priv))) { 1453 1454 rc = -ESHUTDOWN; 1454 1455 goto done; 1455 1456 }
+2 -2
drivers/usb/host/ohci-dbg.c
··· 645 645 hcd->product_desc, 646 646 hcd_name); 647 647 648 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { 648 + if (!HCD_HW_ACCESSIBLE(hcd)) { 649 649 size -= scnprintf (next, size, 650 650 "SUSPENDED (no register access)\n"); 651 651 goto done; ··· 687 687 next += temp; 688 688 689 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 691 size -= temp; 692 692 next += temp; 693 693
+3 -3
drivers/usb/host/ohci-hcd.c
··· 212 212 spin_lock_irqsave (&ohci->lock, flags); 213 213 214 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 216 retval = -ENODEV; 217 217 goto fail; 218 218 } ··· 685 685 } 686 686 687 687 /* use rhsc irqs after khubd is fully initialized */ 688 - hcd->poll_rh = 1; 688 + set_bit(HCD_FLAG_POLL_RH, &hcd->flags); 689 689 hcd->uses_new_polling = 1; 690 690 691 691 /* start controller operations */ ··· 822 822 else if (ints & OHCI_INTR_RD) { 823 823 ohci_vdbg(ohci, "resume detect\n"); 824 824 ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus); 825 - hcd->poll_rh = 1; 825 + set_bit(HCD_FLAG_POLL_RH, &hcd->flags); 826 826 if (ohci->autostop) { 827 827 spin_lock (&ohci->lock); 828 828 ohci_rh_resume (ohci);
+10 -6
drivers/usb/host/ohci-hub.c
··· 284 284 285 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 288 rc = -ESHUTDOWN; 289 289 else 290 290 rc = ohci_rh_suspend (ohci, 0); ··· 302 302 303 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 306 rc = -ESHUTDOWN; 307 307 else 308 308 rc = ohci_rh_resume (ohci); ··· 489 489 unsigned long flags; 490 490 491 491 spin_lock_irqsave (&ohci->lock, flags); 492 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) 492 + if (!HCD_HW_ACCESSIBLE(hcd)) 493 493 goto done; 494 494 495 495 /* undocumented erratum seen on at least rev D */ ··· 533 533 } 534 534 } 535 535 536 - hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed, 537 - any_connected, rhsc_status); 536 + if (ohci_root_hub_state_changes(ohci, changed, 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 543 done: 540 544 spin_unlock_irqrestore (&ohci->lock, flags); ··· 705 701 u32 temp; 706 702 int retval = 0; 707 703 708 - if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) 704 + if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) 709 705 return -ESHUTDOWN; 710 706 711 707 switch (typeReq) {
+2 -5
drivers/usb/host/oxu210hp-hcd.c
··· 1641 1641 #endif 1642 1642 1643 1643 spin_lock_irqsave(&oxu->lock, flags); 1644 - if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, 1645 - &oxu_to_hcd(oxu)->flags))) { 1644 + if (unlikely(!HCD_HW_ACCESSIBLE(oxu_to_hcd(oxu)))) { 1646 1645 rc = -ESHUTDOWN; 1647 1646 goto done; 1648 1647 } ··· 2208 2209 2209 2210 spin_lock_irqsave(&oxu->lock, flags); 2210 2211 2211 - if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, 2212 - &oxu_to_hcd(oxu)->flags))) { 2212 + if (unlikely(!HCD_HW_ACCESSIBLE(oxu_to_hcd(oxu)))) { 2213 2213 status = -ESHUTDOWN; 2214 2214 goto done; 2215 2215 } ··· 2713 2715 u32 temp, hcc_params; 2714 2716 2715 2717 hcd->uses_new_polling = 1; 2716 - hcd->poll_rh = 0; 2717 2718 2718 2719 /* EHCI spec section 4.1 */ 2719 2720 retval = ehci_reset(oxu);
+12 -9
drivers/usb/host/uhci-hcd.c
··· 140 140 uhci->rh_state = UHCI_RH_RESET; 141 141 uhci->is_stopped = UHCI_IS_STOPPED; 142 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 145 uhci->dead = 0; /* Full reset resurrects the controller */ 146 146 } ··· 344 344 /* If interrupts don't work and remote wakeup is enabled then 345 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 352 uhci_scan_schedule(uhci); 350 353 uhci_fsbr_off(uhci); ··· 366 363 uhci->io_addr + USBINTR); 367 364 mb(); 368 365 uhci->rh_state = UHCI_RH_RUNNING; 369 - uhci_to_hcd(uhci)->poll_rh = 1; 366 + set_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); 370 367 } 371 368 372 369 static void wakeup_rh(struct uhci_hcd *uhci) ··· 736 733 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 737 734 738 735 spin_lock_irq(&uhci->lock); 739 - if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) && !uhci->dead) 736 + if (HCD_HW_ACCESSIBLE(hcd) && !uhci->dead) 740 737 uhci_hc_died(uhci); 741 738 uhci_scan_schedule(uhci); 742 739 spin_unlock_irq(&uhci->lock); ··· 753 750 int rc = 0; 754 751 755 752 spin_lock_irq(&uhci->lock); 756 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) 753 + if (!HCD_HW_ACCESSIBLE(hcd)) 757 754 rc = -ESHUTDOWN; 758 755 else if (uhci->dead) 759 756 ; /* Dead controllers tell no tales */ ··· 780 777 int rc = 0; 781 778 782 779 spin_lock_irq(&uhci->lock); 783 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) 780 + if (!HCD_HW_ACCESSIBLE(hcd)) 784 781 rc = -ESHUTDOWN; 785 782 else if (!uhci->dead) 786 783 wakeup_rh(uhci); ··· 796 793 dev_dbg(uhci_dev(uhci), "%s\n", __func__); 797 794 798 795 spin_lock_irq(&uhci->lock); 799 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) 796 + if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead) 800 797 goto done_okay; /* Already suspended or dead */ 801 798 802 799 if (uhci->rh_state > UHCI_RH_SUSPENDED) { ··· 810 807 */ 811 808 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0); 812 809 mb(); 813 - hcd->poll_rh = 0; 810 + clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); 814 811 815 812 /* FIXME: Enable non-PME# remote wakeup? */ 816 813 ··· 863 860 * the suspended root hub needs to be polled. 864 861 */ 865 862 if (!uhci->RD_enable && hcd->self.root_hub->do_remote_wakeup) { 866 - hcd->poll_rh = 1; 863 + set_bit(HCD_FLAG_POLL_RH, &hcd->flags); 867 864 usb_hcd_poll_rh_status(hcd); 868 865 } 869 866 return 0;
+2 -2
drivers/usb/host/uhci-hub.c
··· 190 190 spin_lock_irqsave(&uhci->lock, flags); 191 191 192 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 194 goto done; 195 195 uhci_check_ports(uhci); 196 196 ··· 246 246 u16 wPortChange, wPortStatus; 247 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 250 return -ETIMEDOUT; 251 251 252 252 spin_lock_irqsave(&uhci->lock, flags);
+1 -1
drivers/usb/host/whci/hcd.c
··· 68 68 whc_write_wusbcmd(whc, WUSBCMD_RUN, WUSBCMD_RUN); 69 69 70 70 usb_hcd->uses_new_polling = 1; 71 - usb_hcd->poll_rh = 1; 71 + set_bit(HCD_FLAG_POLL_RH, &usb_hcd->flags); 72 72 usb_hcd->state = HC_STATE_RUNNING; 73 73 74 74 out:
+1 -2
drivers/usb/host/xhci.c
··· 427 427 void (*doorbell)(struct xhci_hcd *) = NULL; 428 428 429 429 hcd->uses_new_polling = 1; 430 - hcd->poll_rh = 0; 431 430 432 431 xhci_dbg(xhci, "xhci_run\n"); 433 432 #if 0 /* FIXME: MSI not setup yet */ ··· 732 733 ret = -EINVAL; 733 734 goto exit; 734 735 } 735 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { 736 + if (!HCD_HW_ACCESSIBLE(hcd)) { 736 737 if (!in_interrupt()) 737 738 xhci_dbg(xhci, "urb submitted during PCI suspend\n"); 738 739 ret = -ESHUTDOWN;
+1 -1
drivers/usb/musb/musb_virthub.c
··· 244 244 245 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 248 spin_unlock_irqrestore(&musb->lock, flags); 249 249 return -ESHUTDOWN; 250 250 }
+17 -5
include/linux/usb/hcd.h
··· 89 89 */ 90 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 96 unsigned long flags; 94 - #define HCD_FLAG_HW_ACCESSIBLE 0x00000001 95 - #define HCD_FLAG_SAW_IRQ 0x00000002 97 + #define HCD_FLAG_HW_ACCESSIBLE 0 /* at full power */ 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? */ 96 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)) 109 + 110 + /* Flags that get set only during HCD registration or removal. */ 97 111 unsigned rh_registered:1;/* is root hub registered? */ 98 112 unsigned rh_pollable:1; /* may we poll the root hub? */ 99 113 100 114 /* The next flag is a stopgap, to be removed when all the HCDs 101 115 * support the new root-hub polling mechanism. */ 102 116 unsigned uses_new_polling:1; 103 - unsigned poll_rh:1; /* poll for rh status? */ 104 - unsigned poll_pending:1; /* status has changed? */ 105 117 unsigned wireless:1; /* Wireless USB HCD */ 106 118 unsigned authorized_default:1; 107 119 unsigned has_tt:1; /* Integrated TT in root hub */