diff options
author | Stanislaw Gruszka <sgruszka@redhat.com> | 2012-02-13 11:23:09 +0100 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-02-22 20:51:12 +0100 |
commit | 1e0f32a43ae652eaa5b23dc06852938555cb8da1 (patch) | |
tree | 374663ec03298f09ad53c1e513e7582da8c508ed /drivers/net/wireless/iwlegacy/common.h | |
parent | iwlegacy: dump stack when fail to gain access to the device (diff) | |
download | linux-1e0f32a43ae652eaa5b23dc06852938555cb8da1.tar.xz linux-1e0f32a43ae652eaa5b23dc06852938555cb8da1.zip |
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>
Diffstat (limited to 'drivers/net/wireless/iwlegacy/common.h')
-rw-r--r-- | drivers/net/wireless/iwlegacy/common.h | 27 |
1 files changed, 15 insertions, 12 deletions
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); extern void il_set_bit(struct il_priv *p, u32 r, u32 m); extern void il_clear_bit(struct il_priv *p, u32 r, u32 m); -extern int _il_grab_nic_access(struct il_priv *il); +extern bool _il_grab_nic_access(struct il_priv *il); extern int _il_poll_bit(struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout); extern int il_poll_bit(struct il_priv *il, u32 addr, u32 mask, int timeout); extern u32 il_rd_prph(struct il_priv *il, u32 reg); @@ -2168,7 +2168,7 @@ il_wr(struct il_priv *il, u32 reg, u32 value) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!_il_grab_nic_access(il)) { + if (likely(_il_grab_nic_access(il))) { _il_wr(il, reg, value); _il_release_nic_access(il); } @@ -2197,9 +2197,10 @@ il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - _il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask)); - _il_release_nic_access(il); + if (likely(_il_grab_nic_access(il))) { + _il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask)); + _il_release_nic_access(il); + } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -2209,9 +2210,10 @@ il_set_bits_mask_prph(struct il_priv *il, u32 reg, u32 bits, u32 mask) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - _il_wr_prph(il, reg, ((_il_rd_prph(il, reg) & mask) | bits)); - _il_release_nic_access(il); + if (likely(_il_grab_nic_access(il))) { + _il_wr_prph(il, reg, ((_il_rd_prph(il, reg) & mask) | bits)); + _il_release_nic_access(il); + } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -2222,10 +2224,11 @@ il_clear_bits_prph(struct il_priv *il, u32 reg, u32 mask) u32 val; spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - val = _il_rd_prph(il, reg); - _il_wr_prph(il, reg, (val & ~mask)); - _il_release_nic_access(il); + if (likely(_il_grab_nic_access(il))) { + val = _il_rd_prph(il, reg); + _il_wr_prph(il, reg, (val & ~mask)); + _il_release_nic_access(il); + } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } |