diff options
author | Lilach Edelstein <lilach.edelstein@intel.com> | 2013-01-16 04:34:49 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-02-01 05:27:22 -0500 |
commit | e56b04efc1f795da42cf1d9651b52a4a5bebd730 (patch) | |
tree | a9740ffd4d47ffb7b90507691a0a066c20f42a2d /drivers/net/wireless/iwlwifi/iwl-io.c | |
parent | e139dc4aebf52a9c88552963b9794fd1dff036f1 (diff) |
iwlwifi: move register access lock into transport
Move the reg_lock that protects HW register access
into the transport implementation. Locking is no
longer exposed, but handled internally in grab and
release NIC access. This simplifies the users.
Signed-off-by: Lilach Edelstein <lilach.edelstein@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-io.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-io.c | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c index 7ef47389953e..276410d82de4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.c +++ b/drivers/net/wireless/iwlwifi/iwl-io.c | |||
@@ -55,13 +55,10 @@ u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg) | |||
55 | { | 55 | { |
56 | u32 value = 0x5a5a5a5a; | 56 | u32 value = 0x5a5a5a5a; |
57 | unsigned long flags; | 57 | unsigned long flags; |
58 | 58 | if (iwl_trans_grab_nic_access(trans, false, &flags)) { | |
59 | spin_lock_irqsave(&trans->reg_lock, flags); | ||
60 | if (iwl_trans_grab_nic_access(trans, false)) { | ||
61 | value = iwl_read32(trans, reg); | 59 | value = iwl_read32(trans, reg); |
62 | iwl_trans_release_nic_access(trans); | 60 | iwl_trans_release_nic_access(trans, &flags); |
63 | } | 61 | } |
64 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
65 | 62 | ||
66 | return value; | 63 | return value; |
67 | } | 64 | } |
@@ -71,12 +68,10 @@ void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value) | |||
71 | { | 68 | { |
72 | unsigned long flags; | 69 | unsigned long flags; |
73 | 70 | ||
74 | spin_lock_irqsave(&trans->reg_lock, flags); | 71 | if (iwl_trans_grab_nic_access(trans, false, &flags)) { |
75 | if (iwl_trans_grab_nic_access(trans, false)) { | ||
76 | iwl_write32(trans, reg, value); | 72 | iwl_write32(trans, reg, value); |
77 | iwl_trans_release_nic_access(trans); | 73 | iwl_trans_release_nic_access(trans, &flags); |
78 | } | 74 | } |
79 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
80 | } | 75 | } |
81 | EXPORT_SYMBOL_GPL(iwl_write_direct32); | 76 | EXPORT_SYMBOL_GPL(iwl_write_direct32); |
82 | 77 | ||
@@ -114,12 +109,10 @@ u32 iwl_read_prph(struct iwl_trans *trans, u32 ofs) | |||
114 | unsigned long flags; | 109 | unsigned long flags; |
115 | u32 val = 0x5a5a5a5a; | 110 | u32 val = 0x5a5a5a5a; |
116 | 111 | ||
117 | spin_lock_irqsave(&trans->reg_lock, flags); | 112 | if (iwl_trans_grab_nic_access(trans, false, &flags)) { |
118 | if (iwl_trans_grab_nic_access(trans, false)) { | ||
119 | val = __iwl_read_prph(trans, ofs); | 113 | val = __iwl_read_prph(trans, ofs); |
120 | iwl_trans_release_nic_access(trans); | 114 | iwl_trans_release_nic_access(trans, &flags); |
121 | } | 115 | } |
122 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
123 | return val; | 116 | return val; |
124 | } | 117 | } |
125 | EXPORT_SYMBOL_GPL(iwl_read_prph); | 118 | EXPORT_SYMBOL_GPL(iwl_read_prph); |
@@ -128,12 +121,10 @@ void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val) | |||
128 | { | 121 | { |
129 | unsigned long flags; | 122 | unsigned long flags; |
130 | 123 | ||
131 | spin_lock_irqsave(&trans->reg_lock, flags); | 124 | if (iwl_trans_grab_nic_access(trans, false, &flags)) { |
132 | if (iwl_trans_grab_nic_access(trans, false)) { | ||
133 | __iwl_write_prph(trans, ofs, val); | 125 | __iwl_write_prph(trans, ofs, val); |
134 | iwl_trans_release_nic_access(trans); | 126 | iwl_trans_release_nic_access(trans, &flags); |
135 | } | 127 | } |
136 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
137 | } | 128 | } |
138 | EXPORT_SYMBOL_GPL(iwl_write_prph); | 129 | EXPORT_SYMBOL_GPL(iwl_write_prph); |
139 | 130 | ||
@@ -141,13 +132,11 @@ void iwl_set_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask) | |||
141 | { | 132 | { |
142 | unsigned long flags; | 133 | unsigned long flags; |
143 | 134 | ||
144 | spin_lock_irqsave(&trans->reg_lock, flags); | 135 | if (iwl_trans_grab_nic_access(trans, false, &flags)) { |
145 | if (iwl_trans_grab_nic_access(trans, false)) { | ||
146 | __iwl_write_prph(trans, ofs, | 136 | __iwl_write_prph(trans, ofs, |
147 | __iwl_read_prph(trans, ofs) | mask); | 137 | __iwl_read_prph(trans, ofs) | mask); |
148 | iwl_trans_release_nic_access(trans); | 138 | iwl_trans_release_nic_access(trans, &flags); |
149 | } | 139 | } |
150 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
151 | } | 140 | } |
152 | EXPORT_SYMBOL_GPL(iwl_set_bits_prph); | 141 | EXPORT_SYMBOL_GPL(iwl_set_bits_prph); |
153 | 142 | ||
@@ -156,13 +145,11 @@ void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 ofs, | |||
156 | { | 145 | { |
157 | unsigned long flags; | 146 | unsigned long flags; |
158 | 147 | ||
159 | spin_lock_irqsave(&trans->reg_lock, flags); | 148 | if (iwl_trans_grab_nic_access(trans, false, &flags)) { |
160 | if (iwl_trans_grab_nic_access(trans, false)) { | ||
161 | __iwl_write_prph(trans, ofs, | 149 | __iwl_write_prph(trans, ofs, |
162 | (__iwl_read_prph(trans, ofs) & mask) | bits); | 150 | (__iwl_read_prph(trans, ofs) & mask) | bits); |
163 | iwl_trans_release_nic_access(trans); | 151 | iwl_trans_release_nic_access(trans, &flags); |
164 | } | 152 | } |
165 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
166 | } | 153 | } |
167 | EXPORT_SYMBOL_GPL(iwl_set_bits_mask_prph); | 154 | EXPORT_SYMBOL_GPL(iwl_set_bits_mask_prph); |
168 | 155 | ||
@@ -171,12 +158,10 @@ void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask) | |||
171 | unsigned long flags; | 158 | unsigned long flags; |
172 | u32 val; | 159 | u32 val; |
173 | 160 | ||
174 | spin_lock_irqsave(&trans->reg_lock, flags); | 161 | if (iwl_trans_grab_nic_access(trans, false, &flags)) { |
175 | if (iwl_trans_grab_nic_access(trans, false)) { | ||
176 | val = __iwl_read_prph(trans, ofs); | 162 | val = __iwl_read_prph(trans, ofs); |
177 | __iwl_write_prph(trans, ofs, (val & ~mask)); | 163 | __iwl_write_prph(trans, ofs, (val & ~mask)); |
178 | iwl_trans_release_nic_access(trans); | 164 | iwl_trans_release_nic_access(trans, &flags); |
179 | } | 165 | } |
180 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
181 | } | 166 | } |
182 | EXPORT_SYMBOL_GPL(iwl_clear_bits_prph); | 167 | EXPORT_SYMBOL_GPL(iwl_clear_bits_prph); |