diff options
author | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2012-12-31 06:46:42 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-01-03 09:34:11 -0500 |
commit | abae2386d55aff1d395cdb665f03684c227a6a69 (patch) | |
tree | dfa4d78c306f6a17d7c6b170531b760c17055af4 /drivers/net/wireless/iwlwifi/iwl-io.c | |
parent | c8f9b0feab564e1ecf460b440e838673aced282c (diff) |
iwlwifi: always check that grab_nic_access succeeds
This allows to let sparse check that the NIC access is
always released.
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 | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c index 2bd84adbb5ae..bff3ac96c00b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.c +++ b/drivers/net/wireless/iwlwifi/iwl-io.c | |||
@@ -101,13 +101,14 @@ EXPORT_SYMBOL_GPL(iwl_poll_bit); | |||
101 | 101 | ||
102 | u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg) | 102 | u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg) |
103 | { | 103 | { |
104 | u32 value; | 104 | u32 value = 0x5a5a5a5a; |
105 | unsigned long flags; | 105 | unsigned long flags; |
106 | 106 | ||
107 | spin_lock_irqsave(&trans->reg_lock, flags); | 107 | spin_lock_irqsave(&trans->reg_lock, flags); |
108 | iwl_trans_grab_nic_access(trans, false); | 108 | if (iwl_trans_grab_nic_access(trans, false)) { |
109 | value = iwl_read32(trans, reg); | 109 | value = iwl_read32(trans, reg); |
110 | iwl_trans_release_nic_access(trans); | 110 | iwl_trans_release_nic_access(trans); |
111 | } | ||
111 | spin_unlock_irqrestore(&trans->reg_lock, flags); | 112 | spin_unlock_irqrestore(&trans->reg_lock, flags); |
112 | 113 | ||
113 | return value; | 114 | return value; |
@@ -119,7 +120,7 @@ void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value) | |||
119 | unsigned long flags; | 120 | unsigned long flags; |
120 | 121 | ||
121 | spin_lock_irqsave(&trans->reg_lock, flags); | 122 | spin_lock_irqsave(&trans->reg_lock, flags); |
122 | if (likely(iwl_trans_grab_nic_access(trans, false))) { | 123 | if (iwl_trans_grab_nic_access(trans, false)) { |
123 | iwl_write32(trans, reg, value); | 124 | iwl_write32(trans, reg, value); |
124 | iwl_trans_release_nic_access(trans); | 125 | iwl_trans_release_nic_access(trans); |
125 | } | 126 | } |
@@ -159,12 +160,13 @@ static inline void __iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val) | |||
159 | u32 iwl_read_prph(struct iwl_trans *trans, u32 ofs) | 160 | u32 iwl_read_prph(struct iwl_trans *trans, u32 ofs) |
160 | { | 161 | { |
161 | unsigned long flags; | 162 | unsigned long flags; |
162 | u32 val; | 163 | u32 val = 0x5a5a5a5a; |
163 | 164 | ||
164 | spin_lock_irqsave(&trans->reg_lock, flags); | 165 | spin_lock_irqsave(&trans->reg_lock, flags); |
165 | iwl_trans_grab_nic_access(trans, false); | 166 | if (iwl_trans_grab_nic_access(trans, false)) { |
166 | val = __iwl_read_prph(trans, ofs); | 167 | val = __iwl_read_prph(trans, ofs); |
167 | iwl_trans_release_nic_access(trans); | 168 | iwl_trans_release_nic_access(trans); |
169 | } | ||
168 | spin_unlock_irqrestore(&trans->reg_lock, flags); | 170 | spin_unlock_irqrestore(&trans->reg_lock, flags); |
169 | return val; | 171 | return val; |
170 | } | 172 | } |
@@ -175,7 +177,7 @@ void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val) | |||
175 | unsigned long flags; | 177 | unsigned long flags; |
176 | 178 | ||
177 | spin_lock_irqsave(&trans->reg_lock, flags); | 179 | spin_lock_irqsave(&trans->reg_lock, flags); |
178 | if (likely(iwl_trans_grab_nic_access(trans, false))) { | 180 | if (iwl_trans_grab_nic_access(trans, false)) { |
179 | __iwl_write_prph(trans, ofs, val); | 181 | __iwl_write_prph(trans, ofs, val); |
180 | iwl_trans_release_nic_access(trans); | 182 | iwl_trans_release_nic_access(trans); |
181 | } | 183 | } |
@@ -188,7 +190,7 @@ void iwl_set_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask) | |||
188 | unsigned long flags; | 190 | unsigned long flags; |
189 | 191 | ||
190 | spin_lock_irqsave(&trans->reg_lock, flags); | 192 | spin_lock_irqsave(&trans->reg_lock, flags); |
191 | if (likely(iwl_trans_grab_nic_access(trans, false))) { | 193 | if (iwl_trans_grab_nic_access(trans, false)) { |
192 | __iwl_write_prph(trans, ofs, | 194 | __iwl_write_prph(trans, ofs, |
193 | __iwl_read_prph(trans, ofs) | mask); | 195 | __iwl_read_prph(trans, ofs) | mask); |
194 | iwl_trans_release_nic_access(trans); | 196 | iwl_trans_release_nic_access(trans); |
@@ -203,7 +205,7 @@ void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 ofs, | |||
203 | unsigned long flags; | 205 | unsigned long flags; |
204 | 206 | ||
205 | spin_lock_irqsave(&trans->reg_lock, flags); | 207 | spin_lock_irqsave(&trans->reg_lock, flags); |
206 | if (likely(iwl_trans_grab_nic_access(trans, false))) { | 208 | if (iwl_trans_grab_nic_access(trans, false)) { |
207 | __iwl_write_prph(trans, ofs, | 209 | __iwl_write_prph(trans, ofs, |
208 | (__iwl_read_prph(trans, ofs) & mask) | bits); | 210 | (__iwl_read_prph(trans, ofs) & mask) | bits); |
209 | iwl_trans_release_nic_access(trans); | 211 | iwl_trans_release_nic_access(trans); |
@@ -218,7 +220,7 @@ void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask) | |||
218 | u32 val; | 220 | u32 val; |
219 | 221 | ||
220 | spin_lock_irqsave(&trans->reg_lock, flags); | 222 | spin_lock_irqsave(&trans->reg_lock, flags); |
221 | if (likely(iwl_trans_grab_nic_access(trans, false))) { | 223 | if (iwl_trans_grab_nic_access(trans, false)) { |
222 | val = __iwl_read_prph(trans, ofs); | 224 | val = __iwl_read_prph(trans, ofs); |
223 | __iwl_write_prph(trans, ofs, (val & ~mask)); | 225 | __iwl_write_prph(trans, ofs, (val & ~mask)); |
224 | iwl_trans_release_nic_access(trans); | 226 | iwl_trans_release_nic_access(trans); |