aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2012-02-13 05:23:09 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-02-22 14:51:12 -0500
commit1e0f32a43ae652eaa5b23dc06852938555cb8da1 (patch)
tree374663ec03298f09ad53c1e513e7582da8c508ed
parentb6603036ad87244bd39ed7bc0612009df7694f5e (diff)
iwlegacy: always check if got h/w access before write
Before we write to the device register always check if _il_grap_nic_access() was successful. Change type return type _il_grap_nic_access() to bool, and add likely()/unlikely() statements. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/iwlegacy/4965-mac.c2
-rw-r--r--drivers/net/wireless/iwlegacy/common.c10
-rw-r--r--drivers/net/wireless/iwlegacy/common.h27
3 files changed, 21 insertions, 18 deletions
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
index 235812ac6a0d..90c9bfb089f4 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -3778,7 +3778,7 @@ il4965_perform_ct_kill_task(struct il_priv *il)
3778 _il_rd(il, CSR_UCODE_DRV_GP1); 3778 _il_rd(il, CSR_UCODE_DRV_GP1);
3779 3779
3780 spin_lock_irqsave(&il->reg_lock, flags); 3780 spin_lock_irqsave(&il->reg_lock, flags);
3781 if (!_il_grab_nic_access(il)) 3781 if (likely(_il_grab_nic_access(il)))
3782 _il_release_nic_access(il); 3782 _il_release_nic_access(il);
3783 spin_unlock_irqrestore(&il->reg_lock, flags); 3783 spin_unlock_irqrestore(&il->reg_lock, flags);
3784} 3784}
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
index 3900967a79f6..6dbd11f76f84 100644
--- a/drivers/net/wireless/iwlegacy/common.c
+++ b/drivers/net/wireless/iwlegacy/common.c
@@ -81,7 +81,7 @@ il_clear_bit(struct il_priv *p, u32 r, u32 m)
81} 81}
82EXPORT_SYMBOL(il_clear_bit); 82EXPORT_SYMBOL(il_clear_bit);
83 83
84int 84bool
85_il_grab_nic_access(struct il_priv *il) 85_il_grab_nic_access(struct il_priv *il)
86{ 86{
87 int ret; 87 int ret;
@@ -116,10 +116,10 @@ _il_grab_nic_access(struct il_priv *il)
116 WARN_ONCE(1, "Timeout waiting for ucode processor access " 116 WARN_ONCE(1, "Timeout waiting for ucode processor access "
117 "(CSR_GP_CNTRL 0x%08x)\n", val); 117 "(CSR_GP_CNTRL 0x%08x)\n", val);
118 _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); 118 _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI);
119 return -EIO; 119 return false;
120 } 120 }
121 121
122 return 0; 122 return true;
123} 123}
124EXPORT_SYMBOL_GPL(_il_grab_nic_access); 124EXPORT_SYMBOL_GPL(_il_grab_nic_access);
125 125
@@ -161,7 +161,7 @@ il_wr_prph(struct il_priv *il, u32 addr, u32 val)
161 unsigned long reg_flags; 161 unsigned long reg_flags;
162 162
163 spin_lock_irqsave(&il->reg_lock, reg_flags); 163 spin_lock_irqsave(&il->reg_lock, reg_flags);
164 if (!_il_grab_nic_access(il)) { 164 if (likely(_il_grab_nic_access(il))) {
165 _il_wr_prph(il, addr, val); 165 _il_wr_prph(il, addr, val);
166 _il_release_nic_access(il); 166 _il_release_nic_access(il);
167 } 167 }
@@ -194,7 +194,7 @@ il_write_targ_mem(struct il_priv *il, u32 addr, u32 val)
194 unsigned long reg_flags; 194 unsigned long reg_flags;
195 195
196 spin_lock_irqsave(&il->reg_lock, reg_flags); 196 spin_lock_irqsave(&il->reg_lock, reg_flags);
197 if (!_il_grab_nic_access(il)) { 197 if (likely(_il_grab_nic_access(il))) {
198 _il_wr(il, HBUS_TARG_MEM_WADDR, addr); 198 _il_wr(il, HBUS_TARG_MEM_WADDR, addr);
199 wmb(); 199 wmb();
200 _il_wr(il, HBUS_TARG_MEM_WDAT, val); 200 _il_wr(il, HBUS_TARG_MEM_WDAT, val);
diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h
index 708095644f17..1dfaa58acc45 100644
--- a/drivers/net/wireless/iwlegacy/common.h
+++ b/drivers/net/wireless/iwlegacy/common.h
@@ -2103,7 +2103,7 @@ irqreturn_t il_isr(int irq, void *data);
2103 2103
2104extern void il_set_bit(struct il_priv *p, u32 r, u32 m); 2104extern void il_set_bit(struct il_priv *p, u32 r, u32 m);
2105extern void il_clear_bit(struct il_priv *p, u32 r, u32 m); 2105extern void il_clear_bit(struct il_priv *p, u32 r, u32 m);
2106extern int _il_grab_nic_access(struct il_priv *il); 2106extern bool _il_grab_nic_access(struct il_priv *il);
2107extern int _il_poll_bit(struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout); 2107extern int _il_poll_bit(struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout);
2108extern int il_poll_bit(struct il_priv *il, u32 addr, u32 mask, int timeout); 2108extern int il_poll_bit(struct il_priv *il, u32 addr, u32 mask, int timeout);
2109extern u32 il_rd_prph(struct il_priv *il, u32 reg); 2109extern u32 il_rd_prph(struct il_priv *il, u32 reg);
@@ -2168,7 +2168,7 @@ il_wr(struct il_priv *il, u32 reg, u32 value)
2168 unsigned long reg_flags; 2168 unsigned long reg_flags;
2169 2169
2170 spin_lock_irqsave(&il->reg_lock, reg_flags); 2170 spin_lock_irqsave(&il->reg_lock, reg_flags);
2171 if (!_il_grab_nic_access(il)) { 2171 if (likely(_il_grab_nic_access(il))) {
2172 _il_wr(il, reg, value); 2172 _il_wr(il, reg, value);
2173 _il_release_nic_access(il); 2173 _il_release_nic_access(il);
2174 } 2174 }
@@ -2197,9 +2197,10 @@ il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask)
2197 unsigned long reg_flags; 2197 unsigned long reg_flags;
2198 2198
2199 spin_lock_irqsave(&il->reg_lock, reg_flags); 2199 spin_lock_irqsave(&il->reg_lock, reg_flags);
2200 _il_grab_nic_access(il); 2200 if (likely(_il_grab_nic_access(il))) {
2201 _il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask)); 2201 _il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask));
2202 _il_release_nic_access(il); 2202 _il_release_nic_access(il);
2203 }
2203 spin_unlock_irqrestore(&il->reg_lock, reg_flags); 2204 spin_unlock_irqrestore(&il->reg_lock, reg_flags);
2204} 2205}
2205 2206
@@ -2209,9 +2210,10 @@ il_set_bits_mask_prph(struct il_priv *il, u32 reg, u32 bits, u32 mask)
2209 unsigned long reg_flags; 2210 unsigned long reg_flags;
2210 2211
2211 spin_lock_irqsave(&il->reg_lock, reg_flags); 2212 spin_lock_irqsave(&il->reg_lock, reg_flags);
2212 _il_grab_nic_access(il); 2213 if (likely(_il_grab_nic_access(il))) {
2213 _il_wr_prph(il, reg, ((_il_rd_prph(il, reg) & mask) | bits)); 2214 _il_wr_prph(il, reg, ((_il_rd_prph(il, reg) & mask) | bits));
2214 _il_release_nic_access(il); 2215 _il_release_nic_access(il);
2216 }
2215 spin_unlock_irqrestore(&il->reg_lock, reg_flags); 2217 spin_unlock_irqrestore(&il->reg_lock, reg_flags);
2216} 2218}
2217 2219
@@ -2222,10 +2224,11 @@ il_clear_bits_prph(struct il_priv *il, u32 reg, u32 mask)
2222 u32 val; 2224 u32 val;
2223 2225
2224 spin_lock_irqsave(&il->reg_lock, reg_flags); 2226 spin_lock_irqsave(&il->reg_lock, reg_flags);
2225 _il_grab_nic_access(il); 2227 if (likely(_il_grab_nic_access(il))) {
2226 val = _il_rd_prph(il, reg); 2228 val = _il_rd_prph(il, reg);
2227 _il_wr_prph(il, reg, (val & ~mask)); 2229 _il_wr_prph(il, reg, (val & ~mask));
2228 _il_release_nic_access(il); 2230 _il_release_nic_access(il);
2231 }
2229 spin_unlock_irqrestore(&il->reg_lock, reg_flags); 2232 spin_unlock_irqrestore(&il->reg_lock, reg_flags);
2230} 2233}
2231 2234