aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb
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 /include/linux/usb
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 'include/linux/usb')
-rw-r--r--include/linux/usb/hcd.h22
1 files changed, 17 insertions, 5 deletions
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 */