aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/uhci-hcd.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2010-06-22 16:39:10 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-10 17:35:37 -0400
commit541c7d432f76771079e7c295d596ea47cc6a3030 (patch)
tree9e04330713366d21849cecf0f3fd2f2c1834574d /drivers/usb/host/uhci-hcd.c
parent89ba85d4015b7fa738b35bcc228075c117a9a578 (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>
Diffstat (limited to 'drivers/usb/host/uhci-hcd.c')
-rw-r--r--drivers/usb/host/uhci-hcd.c21
1 files changed, 12 insertions, 9 deletions
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
369static void wakeup_rh(struct uhci_hcd *uhci) 372static 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;