aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx.h20
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c26
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_leds.c4
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c75
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_pio.c4
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c25
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_wx.c112
7 files changed, 142 insertions, 124 deletions
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
index fd9754b52951..5f8c63fab836 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -619,7 +619,9 @@ struct bcm43xx_private {
619 void __iomem *mmio_addr; 619 void __iomem *mmio_addr;
620 unsigned int mmio_len; 620 unsigned int mmio_len;
621 621
622 spinlock_t lock; 622 /* Do not use the lock directly. Use the bcm43xx_lock* helper
623 * functions, to be MMIO-safe. */
624 spinlock_t _lock;
623 625
624 /* Driver status flags. */ 626 /* Driver status flags. */
625 u32 initialized:1, /* init_board() succeed */ 627 u32 initialized:1, /* init_board() succeed */
@@ -721,6 +723,22 @@ struct bcm43xx_private {
721#endif 723#endif
722}; 724};
723 725
726/* bcm43xx_(un)lock() protect struct bcm43xx_private.
727 * Note that _NO_ MMIO writes are allowed. If you want to
728 * write to the device through MMIO in the critical section, use
729 * the *_mmio lock functions.
730 * MMIO read-access is allowed, though.
731 */
732#define bcm43xx_lock(bcm, flags) spin_lock_irqsave(&(bcm)->_lock, flags)
733#define bcm43xx_unlock(bcm, flags) spin_unlock_irqrestore(&(bcm)->_lock, flags)
734/* bcm43xx_(un)lock_mmio() protect struct bcm43xx_private and MMIO.
735 * MMIO write-access to the device is allowed.
736 * All MMIO writes are flushed on unlock, so it is guaranteed to not
737 * interfere with other threads writing MMIO registers.
738 */
739#define bcm43xx_lock_mmio(bcm, flags) bcm43xx_lock(bcm, flags)
740#define bcm43xx_unlock_mmio(bcm, flags) do { mmiowb(); bcm43xx_unlock(bcm, flags); } while (0)
741
724static inline 742static inline
725struct bcm43xx_private * bcm43xx_priv(struct net_device *dev) 743struct bcm43xx_private * bcm43xx_priv(struct net_device *dev)
726{ 744{
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
index 0bae0be4be2e..bcfcebe28261 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
@@ -77,7 +77,7 @@ static ssize_t devinfo_read_file(struct file *file, char __user *userbuf,
77 77
78 down(&big_buffer_sem); 78 down(&big_buffer_sem);
79 79
80 spin_lock_irqsave(&bcm->lock, flags); 80 bcm43xx_lock_mmio(bcm, flags);
81 if (!bcm->initialized) { 81 if (!bcm->initialized) {
82 fappend("Board not initialized.\n"); 82 fappend("Board not initialized.\n");
83 goto out; 83 goto out;
@@ -124,7 +124,7 @@ static ssize_t devinfo_read_file(struct file *file, char __user *userbuf,
124 fappend("\n"); 124 fappend("\n");
125 125
126out: 126out:
127 spin_unlock_irqrestore(&bcm->lock, flags); 127 bcm43xx_unlock_mmio(bcm, flags);
128 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 128 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
129 up(&big_buffer_sem); 129 up(&big_buffer_sem);
130 return res; 130 return res;
@@ -162,7 +162,7 @@ static ssize_t spromdump_read_file(struct file *file, char __user *userbuf,
162 unsigned long flags; 162 unsigned long flags;
163 163
164 down(&big_buffer_sem); 164 down(&big_buffer_sem);
165 spin_lock_irqsave(&bcm->lock, flags); 165 bcm43xx_lock_mmio(bcm, flags);
166 if (!bcm->initialized) { 166 if (!bcm->initialized) {
167 fappend("Board not initialized.\n"); 167 fappend("Board not initialized.\n");
168 goto out; 168 goto out;
@@ -172,7 +172,7 @@ static ssize_t spromdump_read_file(struct file *file, char __user *userbuf,
172 fappend("boardflags: 0x%04x\n", bcm->sprom.boardflags); 172 fappend("boardflags: 0x%04x\n", bcm->sprom.boardflags);
173 173
174out: 174out:
175 spin_unlock_irqrestore(&bcm->lock, flags); 175 bcm43xx_unlock_mmio(bcm, flags);
176 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 176 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
177 up(&big_buffer_sem); 177 up(&big_buffer_sem);
178 return res; 178 return res;
@@ -191,7 +191,7 @@ static ssize_t tsf_read_file(struct file *file, char __user *userbuf,
191 u64 tsf; 191 u64 tsf;
192 192
193 down(&big_buffer_sem); 193 down(&big_buffer_sem);
194 spin_lock_irqsave(&bcm->lock, flags); 194 bcm43xx_lock_mmio(bcm, flags);
195 if (!bcm->initialized) { 195 if (!bcm->initialized) {
196 fappend("Board not initialized.\n"); 196 fappend("Board not initialized.\n");
197 goto out; 197 goto out;
@@ -202,7 +202,7 @@ static ssize_t tsf_read_file(struct file *file, char __user *userbuf,
202 (unsigned int)(tsf & 0xFFFFFFFFULL)); 202 (unsigned int)(tsf & 0xFFFFFFFFULL));
203 203
204out: 204out:
205 spin_unlock_irqrestore(&bcm->lock, flags); 205 bcm43xx_unlock_mmio(bcm, flags);
206 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 206 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
207 up(&big_buffer_sem); 207 up(&big_buffer_sem);
208 return res; 208 return res;
@@ -224,7 +224,7 @@ static ssize_t tsf_write_file(struct file *file, const char __user *user_buf,
224 res = -EFAULT; 224 res = -EFAULT;
225 goto out_up; 225 goto out_up;
226 } 226 }
227 spin_lock_irqsave(&bcm->lock, flags); 227 bcm43xx_lock_mmio(bcm, flags);
228 if (!bcm->initialized) { 228 if (!bcm->initialized) {
229 printk(KERN_INFO PFX "debugfs: Board not initialized.\n"); 229 printk(KERN_INFO PFX "debugfs: Board not initialized.\n");
230 res = -EFAULT; 230 res = -EFAULT;
@@ -239,7 +239,7 @@ static ssize_t tsf_write_file(struct file *file, const char __user *user_buf,
239 res = buf_size; 239 res = buf_size;
240 240
241out_unlock: 241out_unlock:
242 spin_unlock_irqrestore(&bcm->lock, flags); 242 bcm43xx_unlock_mmio(bcm, flags);
243out_up: 243out_up:
244 up(&big_buffer_sem); 244 up(&big_buffer_sem);
245 return res; 245 return res;
@@ -260,7 +260,7 @@ static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
260 int i, cnt, j = 0; 260 int i, cnt, j = 0;
261 261
262 down(&big_buffer_sem); 262 down(&big_buffer_sem);
263 spin_lock_irqsave(&bcm->lock, flags); 263 bcm43xx_lock(bcm, flags);
264 264
265 fappend("Last %d logged xmitstatus blobs (Latest first):\n\n", 265 fappend("Last %d logged xmitstatus blobs (Latest first):\n\n",
266 BCM43xx_NR_LOGGED_XMITSTATUS); 266 BCM43xx_NR_LOGGED_XMITSTATUS);
@@ -296,14 +296,14 @@ static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
296 i = BCM43xx_NR_LOGGED_XMITSTATUS - 1; 296 i = BCM43xx_NR_LOGGED_XMITSTATUS - 1;
297 } 297 }
298 298
299 spin_unlock_irqrestore(&bcm->lock, flags); 299 bcm43xx_unlock(bcm, flags);
300 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 300 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
301 spin_lock_irqsave(&bcm->lock, flags); 301 bcm43xx_lock(bcm, flags);
302 if (*ppos == pos) { 302 if (*ppos == pos) {
303 /* Done. Drop the copied data. */ 303 /* Done. Drop the copied data. */
304 e->xmitstatus_printing = 0; 304 e->xmitstatus_printing = 0;
305 } 305 }
306 spin_unlock_irqrestore(&bcm->lock, flags); 306 bcm43xx_unlock(bcm, flags);
307 up(&big_buffer_sem); 307 up(&big_buffer_sem);
308 return res; 308 return res;
309} 309}
@@ -419,7 +419,7 @@ void bcm43xx_debugfs_log_txstat(struct bcm43xx_private *bcm,
419 struct bcm43xx_dfsentry *e; 419 struct bcm43xx_dfsentry *e;
420 struct bcm43xx_xmitstatus *savedstatus; 420 struct bcm43xx_xmitstatus *savedstatus;
421 421
422 /* This is protected by bcm->lock */ 422 /* This is protected by bcm->_lock */
423 e = bcm->dfsentry; 423 e = bcm->dfsentry;
424 assert(e); 424 assert(e);
425 savedstatus = e->xmitstatus_buffer + e->xmitstatus_ptr; 425 savedstatus = e->xmitstatus_buffer + e->xmitstatus_ptr;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
index 8f550c1a92ed..949555da5aa9 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
@@ -51,12 +51,12 @@ static void bcm43xx_led_blink(unsigned long d)
51 struct bcm43xx_private *bcm = led->bcm; 51 struct bcm43xx_private *bcm = led->bcm;
52 unsigned long flags; 52 unsigned long flags;
53 53
54 spin_lock_irqsave(&bcm->lock, flags); 54 bcm43xx_lock_mmio(bcm, flags);
55 if (led->blink_interval) { 55 if (led->blink_interval) {
56 bcm43xx_led_changestate(led); 56 bcm43xx_led_changestate(led);
57 mod_timer(&led->blink_timer, jiffies + led->blink_interval); 57 mod_timer(&led->blink_timer, jiffies + led->blink_interval);
58 } 58 }
59 spin_unlock_irqrestore(&bcm->lock, flags); 59 bcm43xx_unlock_mmio(bcm, flags);
60} 60}
61 61
62static void bcm43xx_led_blink_start(struct bcm43xx_led *led, 62static void bcm43xx_led_blink_start(struct bcm43xx_led *led,
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index 6da0beb0a933..b7192559833c 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -482,14 +482,14 @@ static int bcm43xx_disable_interrupts_sync(struct bcm43xx_private *bcm, u32 *old
482 u32 old; 482 u32 old;
483 unsigned long flags; 483 unsigned long flags;
484 484
485 spin_lock_irqsave(&bcm->lock, flags); 485 bcm43xx_lock_mmio(bcm, flags);
486 if (bcm43xx_is_initializing(bcm) || bcm->shutting_down) { 486 if (bcm43xx_is_initializing(bcm) || bcm->shutting_down) {
487 spin_unlock_irqrestore(&bcm->lock, flags); 487 bcm43xx_unlock_mmio(bcm, flags);
488 return -EBUSY; 488 return -EBUSY;
489 } 489 }
490 old = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL); 490 old = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
491 tasklet_disable(&bcm->isr_tasklet); 491 tasklet_disable(&bcm->isr_tasklet);
492 spin_unlock_irqrestore(&bcm->lock, flags); 492 bcm43xx_unlock_mmio(bcm, flags);
493 if (oldstate) 493 if (oldstate)
494 *oldstate = old; 494 *oldstate = old;
495 495
@@ -746,6 +746,7 @@ int bcm43xx_sprom_write(struct bcm43xx_private *bcm, const u16 *sprom)
746 else if (i % 2) 746 else if (i % 2)
747 printk("."); 747 printk(".");
748 bcm43xx_write16(bcm, BCM43xx_SPROM_BASE + (i * 2), sprom[i]); 748 bcm43xx_write16(bcm, BCM43xx_SPROM_BASE + (i * 2), sprom[i]);
749 mmiowb();
749 mdelay(20); 750 mdelay(20);
750 } 751 }
751 spromctl &= ~0x10; /* SPROM WRITE enable. */ 752 spromctl &= ~0x10; /* SPROM WRITE enable. */
@@ -1676,7 +1677,7 @@ static void bcm43xx_interrupt_tasklet(struct bcm43xx_private *bcm)
1676# define bcmirq_handled(irq) do { /* nothing */ } while (0) 1677# define bcmirq_handled(irq) do { /* nothing */ } while (0)
1677#endif /* CONFIG_BCM43XX_DEBUG*/ 1678#endif /* CONFIG_BCM43XX_DEBUG*/
1678 1679
1679 spin_lock_irqsave(&bcm->lock, flags); 1680 bcm43xx_lock_mmio(bcm, flags);
1680 reason = bcm->irq_reason; 1681 reason = bcm->irq_reason;
1681 dma_reason[0] = bcm->dma_reason[0]; 1682 dma_reason[0] = bcm->dma_reason[0];
1682 dma_reason[1] = bcm->dma_reason[1]; 1683 dma_reason[1] = bcm->dma_reason[1];
@@ -1776,7 +1777,7 @@ static void bcm43xx_interrupt_tasklet(struct bcm43xx_private *bcm)
1776 if (!modparam_noleds) 1777 if (!modparam_noleds)
1777 bcm43xx_leds_update(bcm, activity); 1778 bcm43xx_leds_update(bcm, activity);
1778 bcm43xx_interrupt_enable(bcm, bcm->irq_savedstate); 1779 bcm43xx_interrupt_enable(bcm, bcm->irq_savedstate);
1779 spin_unlock_irqrestore(&bcm->lock, flags); 1780 bcm43xx_unlock_mmio(bcm, flags);
1780} 1781}
1781 1782
1782#undef bcmirq_print_reasons 1783#undef bcmirq_print_reasons
@@ -1830,25 +1831,24 @@ static void bcm43xx_interrupt_ack(struct bcm43xx_private *bcm,
1830/* Interrupt handler top-half */ 1831/* Interrupt handler top-half */
1831static irqreturn_t bcm43xx_interrupt_handler(int irq, void *dev_id, struct pt_regs *regs) 1832static irqreturn_t bcm43xx_interrupt_handler(int irq, void *dev_id, struct pt_regs *regs)
1832{ 1833{
1834 irqreturn_t ret = IRQ_HANDLED;
1833 struct bcm43xx_private *bcm = dev_id; 1835 struct bcm43xx_private *bcm = dev_id;
1834 u32 reason, mask; 1836 u32 reason, mask;
1835 1837
1836 if (!bcm) 1838 if (!bcm)
1837 return IRQ_NONE; 1839 return IRQ_NONE;
1838 1840
1839 spin_lock(&bcm->lock); 1841 spin_lock(&bcm->_lock);
1840 1842
1841 reason = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON); 1843 reason = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON);
1842 if (reason == 0xffffffff) { 1844 if (reason == 0xffffffff) {
1843 /* irq not for us (shared irq) */ 1845 /* irq not for us (shared irq) */
1844 spin_unlock(&bcm->lock); 1846 ret = IRQ_NONE;
1845 return IRQ_NONE; 1847 goto out;
1846 } 1848 }
1847 mask = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_MASK); 1849 mask = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_MASK);
1848 if (!(reason & mask)) { 1850 if (!(reason & mask))
1849 spin_unlock(&bcm->lock); 1851 goto out;
1850 return IRQ_HANDLED;
1851 }
1852 1852
1853 bcm43xx_interrupt_ack(bcm, reason, mask); 1853 bcm43xx_interrupt_ack(bcm, reason, mask);
1854 1854
@@ -1866,9 +1866,11 @@ static irqreturn_t bcm43xx_interrupt_handler(int irq, void *dev_id, struct pt_re
1866 tasklet_schedule(&bcm->isr_tasklet); 1866 tasklet_schedule(&bcm->isr_tasklet);
1867 } 1867 }
1868 1868
1869 spin_unlock(&bcm->lock); 1869out:
1870 mmiowb();
1871 spin_unlock(&bcm->_lock);
1870 1872
1871 return IRQ_HANDLED; 1873 return ret;
1872} 1874}
1873 1875
1874static void bcm43xx_release_firmware(struct bcm43xx_private *bcm, int force) 1876static void bcm43xx_release_firmware(struct bcm43xx_private *bcm, int force)
@@ -3112,7 +3114,7 @@ static void bcm43xx_periodic_task_handler(unsigned long d)
3112 unsigned long flags; 3114 unsigned long flags;
3113 unsigned int state; 3115 unsigned int state;
3114 3116
3115 spin_lock_irqsave(&bcm->lock, flags); 3117 bcm43xx_lock_mmio(bcm, flags);
3116 3118
3117 assert(bcm->initialized); 3119 assert(bcm->initialized);
3118 state = bcm->periodic_state; 3120 state = bcm->periodic_state;
@@ -3127,7 +3129,7 @@ static void bcm43xx_periodic_task_handler(unsigned long d)
3127 3129
3128 mod_timer(&bcm->periodic_tasks, jiffies + (HZ * 15)); 3130 mod_timer(&bcm->periodic_tasks, jiffies + (HZ * 15));
3129 3131
3130 spin_unlock_irqrestore(&bcm->lock, flags); 3132 bcm43xx_unlock_mmio(bcm, flags);
3131} 3133}
3132 3134
3133static void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm) 3135static void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm)
@@ -3164,10 +3166,10 @@ static void bcm43xx_free_board(struct bcm43xx_private *bcm)
3164 3166
3165 bcm43xx_periodic_tasks_delete(bcm); 3167 bcm43xx_periodic_tasks_delete(bcm);
3166 3168
3167 spin_lock_irqsave(&bcm->lock, flags); 3169 bcm43xx_lock(bcm, flags);
3168 bcm->initialized = 0; 3170 bcm->initialized = 0;
3169 bcm->shutting_down = 1; 3171 bcm->shutting_down = 1;
3170 spin_unlock_irqrestore(&bcm->lock, flags); 3172 bcm43xx_unlock(bcm, flags);
3171 3173
3172 for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) { 3174 for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) {
3173 if (!(bcm->core_80211[i].flags & BCM43xx_COREFLAG_AVAILABLE)) 3175 if (!(bcm->core_80211[i].flags & BCM43xx_COREFLAG_AVAILABLE))
@@ -3182,9 +3184,9 @@ static void bcm43xx_free_board(struct bcm43xx_private *bcm)
3182 3184
3183 bcm43xx_pctl_set_crystal(bcm, 0); 3185 bcm43xx_pctl_set_crystal(bcm, 0);
3184 3186
3185 spin_lock_irqsave(&bcm->lock, flags); 3187 bcm43xx_lock(bcm, flags);
3186 bcm->shutting_down = 0; 3188 bcm->shutting_down = 0;
3187 spin_unlock_irqrestore(&bcm->lock, flags); 3189 bcm43xx_unlock(bcm, flags);
3188} 3190}
3189 3191
3190static int bcm43xx_init_board(struct bcm43xx_private *bcm) 3192static int bcm43xx_init_board(struct bcm43xx_private *bcm)
@@ -3196,10 +3198,10 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
3196 3198
3197 might_sleep(); 3199 might_sleep();
3198 3200
3199 spin_lock_irqsave(&bcm->lock, flags); 3201 bcm43xx_lock(bcm, flags);
3200 bcm->initialized = 0; 3202 bcm->initialized = 0;
3201 bcm->shutting_down = 0; 3203 bcm->shutting_down = 0;
3202 spin_unlock_irqrestore(&bcm->lock, flags); 3204 bcm43xx_unlock(bcm, flags);
3203 3205
3204 err = bcm43xx_pctl_set_crystal(bcm, 1); 3206 err = bcm43xx_pctl_set_crystal(bcm, 1);
3205 if (err) 3207 if (err)
@@ -3267,9 +3269,9 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
3267 } 3269 }
3268 3270
3269 /* Initialization of the board is done. Flag it as such. */ 3271 /* Initialization of the board is done. Flag it as such. */
3270 spin_lock_irqsave(&bcm->lock, flags); 3272 bcm43xx_lock(bcm, flags);
3271 bcm->initialized = 1; 3273 bcm->initialized = 1;
3272 spin_unlock_irqrestore(&bcm->lock, flags); 3274 bcm43xx_unlock(bcm, flags);
3273 3275
3274 bcm43xx_periodic_tasks_setup(bcm); 3276 bcm43xx_periodic_tasks_setup(bcm);
3275 bcm43xx_sysfs_register(bcm); 3277 bcm43xx_sysfs_register(bcm);
@@ -3570,11 +3572,11 @@ static void bcm43xx_ieee80211_set_chan(struct net_device *net_dev,
3570 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); 3572 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
3571 unsigned long flags; 3573 unsigned long flags;
3572 3574
3573 spin_lock_irqsave(&bcm->lock, flags); 3575 bcm43xx_lock_mmio(bcm, flags);
3574 bcm43xx_mac_suspend(bcm); 3576 bcm43xx_mac_suspend(bcm);
3575 bcm43xx_radio_selectchannel(bcm, channel, 0); 3577 bcm43xx_radio_selectchannel(bcm, channel, 0);
3576 bcm43xx_mac_enable(bcm); 3578 bcm43xx_mac_enable(bcm);
3577 spin_unlock_irqrestore(&bcm->lock, flags); 3579 bcm43xx_unlock_mmio(bcm, flags);
3578} 3580}
3579 3581
3580/* set_security() callback in struct ieee80211_device */ 3582/* set_security() callback in struct ieee80211_device */
@@ -3587,9 +3589,9 @@ static void bcm43xx_ieee80211_set_security(struct net_device *net_dev,
3587 int keyidx; 3589 int keyidx;
3588 3590
3589 dprintk(KERN_INFO PFX "set security called\n"); 3591 dprintk(KERN_INFO PFX "set security called\n");
3590 3592
3591 spin_lock_irqsave(&bcm->lock, flags); 3593 bcm43xx_lock_mmio(bcm, flags);
3592 3594
3593 for (keyidx = 0; keyidx<WEP_KEYS; keyidx++) 3595 for (keyidx = 0; keyidx<WEP_KEYS; keyidx++)
3594 if (sec->flags & (1<<keyidx)) { 3596 if (sec->flags & (1<<keyidx)) {
3595 secinfo->encode_alg[keyidx] = sec->encode_alg[keyidx]; 3597 secinfo->encode_alg[keyidx] = sec->encode_alg[keyidx];
@@ -3651,7 +3653,7 @@ static void bcm43xx_ieee80211_set_security(struct net_device *net_dev,
3651 } else 3653 } else
3652 bcm43xx_clear_keys(bcm); 3654 bcm43xx_clear_keys(bcm);
3653 } 3655 }
3654 spin_unlock_irqrestore(&bcm->lock, flags); 3656 bcm43xx_unlock_mmio(bcm, flags);
3655} 3657}
3656 3658
3657/* hard_start_xmit() callback in struct ieee80211_device */ 3659/* hard_start_xmit() callback in struct ieee80211_device */
@@ -3663,10 +3665,10 @@ static int bcm43xx_ieee80211_hard_start_xmit(struct ieee80211_txb *txb,
3663 int err = -ENODEV; 3665 int err = -ENODEV;
3664 unsigned long flags; 3666 unsigned long flags;
3665 3667
3666 spin_lock_irqsave(&bcm->lock, flags); 3668 bcm43xx_lock_mmio(bcm, flags);
3667 if (likely(bcm->initialized)) 3669 if (likely(bcm->initialized))
3668 err = bcm43xx_tx(bcm, txb); 3670 err = bcm43xx_tx(bcm, txb);
3669 spin_unlock_irqrestore(&bcm->lock, flags); 3671 bcm43xx_unlock_mmio(bcm, flags);
3670 3672
3671 return err; 3673 return err;
3672} 3674}
@@ -3679,8 +3681,11 @@ static struct net_device_stats * bcm43xx_net_get_stats(struct net_device *net_de
3679static void bcm43xx_net_tx_timeout(struct net_device *net_dev) 3681static void bcm43xx_net_tx_timeout(struct net_device *net_dev)
3680{ 3682{
3681 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); 3683 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
3684 unsigned long flags;
3682 3685
3686 bcm43xx_lock_mmio(bcm, flags);
3683 bcm43xx_controller_restart(bcm, "TX timeout"); 3687 bcm43xx_controller_restart(bcm, "TX timeout");
3688 bcm43xx_unlock_mmio(bcm, flags);
3684} 3689}
3685 3690
3686#ifdef CONFIG_NET_POLL_CONTROLLER 3691#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -3738,7 +3743,7 @@ static int bcm43xx_init_private(struct bcm43xx_private *bcm,
3738 bcm->pci_dev = pci_dev; 3743 bcm->pci_dev = pci_dev;
3739 bcm->net_dev = net_dev; 3744 bcm->net_dev = net_dev;
3740 bcm->bad_frames_preempt = modparam_bad_frames_preempt; 3745 bcm->bad_frames_preempt = modparam_bad_frames_preempt;
3741 spin_lock_init(&bcm->lock); 3746 spin_lock_init(&bcm->_lock);
3742 tasklet_init(&bcm->isr_tasklet, 3747 tasklet_init(&bcm->isr_tasklet,
3743 (void (*)(unsigned long))bcm43xx_interrupt_tasklet, 3748 (void (*)(unsigned long))bcm43xx_interrupt_tasklet,
3744 (unsigned long)bcm); 3749 (unsigned long)bcm);
@@ -3921,11 +3926,11 @@ static int bcm43xx_suspend(struct pci_dev *pdev, pm_message_t state)
3921 3926
3922 dprintk(KERN_INFO PFX "Suspending...\n"); 3927 dprintk(KERN_INFO PFX "Suspending...\n");
3923 3928
3924 spin_lock_irqsave(&bcm->lock, flags); 3929 bcm43xx_lock(bcm, flags);
3925 bcm->was_initialized = bcm->initialized; 3930 bcm->was_initialized = bcm->initialized;
3926 if (bcm->initialized) 3931 if (bcm->initialized)
3927 try_to_shutdown = 1; 3932 try_to_shutdown = 1;
3928 spin_unlock_irqrestore(&bcm->lock, flags); 3933 bcm43xx_unlock(bcm, flags);
3929 3934
3930 netif_device_detach(net_dev); 3935 netif_device_detach(net_dev);
3931 if (try_to_shutdown) { 3936 if (try_to_shutdown) {
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_pio.c b/drivers/net/wireless/bcm43xx/bcm43xx_pio.c
index 7b45fa1314c1..26dc6047d458 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_pio.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_pio.c
@@ -258,7 +258,7 @@ static void tx_tasklet(unsigned long d)
258 struct bcm43xx_pio_txpacket *packet, *tmp_packet; 258 struct bcm43xx_pio_txpacket *packet, *tmp_packet;
259 int err; 259 int err;
260 260
261 spin_lock_irqsave(&bcm->lock, flags); 261 bcm43xx_lock_mmio(bcm, flags);
262 list_for_each_entry_safe(packet, tmp_packet, &queue->txqueue, list) { 262 list_for_each_entry_safe(packet, tmp_packet, &queue->txqueue, list) {
263 assert(packet->xmitted_frags < packet->txb->nr_frags); 263 assert(packet->xmitted_frags < packet->txb->nr_frags);
264 if (packet->xmitted_frags == 0) { 264 if (packet->xmitted_frags == 0) {
@@ -288,7 +288,7 @@ static void tx_tasklet(unsigned long d)
288 next_packet: 288 next_packet:
289 continue; 289 continue;
290 } 290 }
291 spin_unlock_irqrestore(&bcm->lock, flags); 291 bcm43xx_unlock_mmio(bcm, flags);
292} 292}
293 293
294static void setup_txqueues(struct bcm43xx_pioqueue *queue) 294static void setup_txqueues(struct bcm43xx_pioqueue *queue)
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c b/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c
index 2d31737372fd..713ec601c342 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c
@@ -88,7 +88,7 @@ static ssize_t bcm43xx_attr_sprom_show(struct device *dev,
88 GFP_KERNEL); 88 GFP_KERNEL);
89 if (!sprom) 89 if (!sprom)
90 return -ENOMEM; 90 return -ENOMEM;
91 spin_lock_irqsave(&bcm->lock, flags); 91 bcm43xx_lock_mmio(bcm, flags);
92 assert(bcm->initialized); 92 assert(bcm->initialized);
93 err = bcm43xx_sprom_read(bcm, sprom); 93 err = bcm43xx_sprom_read(bcm, sprom);
94 if (!err) { 94 if (!err) {
@@ -97,7 +97,7 @@ static ssize_t bcm43xx_attr_sprom_show(struct device *dev,
97 buf[i * 2 + 1] = (sprom[i] & 0xFF00) >> 8; 97 buf[i * 2 + 1] = (sprom[i] & 0xFF00) >> 8;
98 } 98 }
99 } 99 }
100 spin_unlock_irqrestore(&bcm->lock, flags); 100 bcm43xx_unlock_mmio(bcm, flags);
101 kfree(sprom); 101 kfree(sprom);
102 102
103 return err ? err : BCM43xx_SPROM_SIZE * sizeof(u16); 103 return err ? err : BCM43xx_SPROM_SIZE * sizeof(u16);
@@ -125,10 +125,10 @@ static ssize_t bcm43xx_attr_sprom_store(struct device *dev,
125 sprom[i] = buf[i * 2] & 0xFF; 125 sprom[i] = buf[i * 2] & 0xFF;
126 sprom[i] |= ((u16)(buf[i * 2 + 1] & 0xFF)) << 8; 126 sprom[i] |= ((u16)(buf[i * 2 + 1] & 0xFF)) << 8;
127 } 127 }
128 spin_lock_irqsave(&bcm->lock, flags); 128 bcm43xx_lock_mmio(bcm, flags);
129 assert(bcm->initialized); 129 assert(bcm->initialized);
130 err = bcm43xx_sprom_write(bcm, sprom); 130 err = bcm43xx_sprom_write(bcm, sprom);
131 spin_unlock_irqrestore(&bcm->lock, flags); 131 bcm43xx_unlock_mmio(bcm, flags);
132 kfree(sprom); 132 kfree(sprom);
133 133
134 return err ? err : count; 134 return err ? err : count;
@@ -147,7 +147,7 @@ static ssize_t bcm43xx_attr_interfmode_show(struct device *dev,
147 if (!capable(CAP_NET_ADMIN)) 147 if (!capable(CAP_NET_ADMIN))
148 return -EPERM; 148 return -EPERM;
149 149
150 spin_lock_irqsave(&bcm->lock, flags); 150 bcm43xx_lock(bcm, flags);
151 assert(bcm->initialized); 151 assert(bcm->initialized);
152 152
153 switch (bcm->current_core->radio->interfmode) { 153 switch (bcm->current_core->radio->interfmode) {
@@ -165,7 +165,8 @@ static ssize_t bcm43xx_attr_interfmode_show(struct device *dev,
165 } 165 }
166 err = 0; 166 err = 0;
167 167
168 spin_unlock_irqrestore(&bcm->lock, flags); 168 bcm43xx_unlock(bcm, flags);
169
169 return err ? err : count; 170 return err ? err : count;
170 171
171} 172}
@@ -200,7 +201,7 @@ static ssize_t bcm43xx_attr_interfmode_store(struct device *dev,
200 return -EINVAL; 201 return -EINVAL;
201 } 202 }
202 203
203 spin_lock_irqsave(&bcm->lock, flags); 204 bcm43xx_lock_mmio(bcm, flags);
204 assert(bcm->initialized); 205 assert(bcm->initialized);
205 206
206 err = bcm43xx_radio_set_interference_mitigation(bcm, mode); 207 err = bcm43xx_radio_set_interference_mitigation(bcm, mode);
@@ -209,7 +210,7 @@ static ssize_t bcm43xx_attr_interfmode_store(struct device *dev,
209 "supported by device\n"); 210 "supported by device\n");
210 } 211 }
211 212
212 spin_unlock_irqrestore(&bcm->lock, flags); 213 bcm43xx_unlock_mmio(bcm, flags);
213 214
214 return err ? err : count; 215 return err ? err : count;
215} 216}
@@ -226,7 +227,7 @@ static ssize_t bcm43xx_attr_preamble_show(struct device *dev,
226 if (!capable(CAP_NET_ADMIN)) 227 if (!capable(CAP_NET_ADMIN))
227 return -EPERM; 228 return -EPERM;
228 229
229 spin_lock_irqsave(&bcm->lock, flags); 230 bcm43xx_lock(bcm, flags);
230 assert(bcm->initialized); 231 assert(bcm->initialized);
231 232
232 if (bcm->short_preamble) 233 if (bcm->short_preamble)
@@ -235,7 +236,7 @@ static ssize_t bcm43xx_attr_preamble_show(struct device *dev,
235 count = snprintf(buf, PAGE_SIZE, "0 (Short Preamble disabled)\n"); 236 count = snprintf(buf, PAGE_SIZE, "0 (Short Preamble disabled)\n");
236 237
237 err = 0; 238 err = 0;
238 spin_unlock_irqrestore(&bcm->lock, flags); 239 bcm43xx_unlock(bcm, flags);
239 240
240 return err ? err : count; 241 return err ? err : count;
241} 242}
@@ -255,13 +256,13 @@ static ssize_t bcm43xx_attr_preamble_store(struct device *dev,
255 value = get_boolean(buf, count); 256 value = get_boolean(buf, count);
256 if (value < 0) 257 if (value < 0)
257 return value; 258 return value;
258 spin_lock_irqsave(&bcm->lock, flags); 259 bcm43xx_lock(bcm, flags);
259 assert(bcm->initialized); 260 assert(bcm->initialized);
260 261
261 bcm->short_preamble = !!value; 262 bcm->short_preamble = !!value;
262 263
263 err = 0; 264 err = 0;
264 spin_unlock_irqrestore(&bcm->lock, flags); 265 bcm43xx_unlock(bcm, flags);
265 266
266 return err ? err : count; 267 return err ? err : count;
267} 268}
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
index aa2d9930c436..208193851e8e 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
@@ -61,7 +61,7 @@ static int bcm43xx_wx_get_name(struct net_device *net_dev,
61 char suffix[7] = { 0 }; 61 char suffix[7] = { 0 };
62 int have_a = 0, have_b = 0, have_g = 0; 62 int have_a = 0, have_b = 0, have_g = 0;
63 63
64 spin_lock_irqsave(&bcm->lock, flags); 64 bcm43xx_lock(bcm, flags);
65 nr_80211 = bcm43xx_num_80211_cores(bcm); 65 nr_80211 = bcm43xx_num_80211_cores(bcm);
66 for (i = 0; i < nr_80211; i++) { 66 for (i = 0; i < nr_80211; i++) {
67 phy = bcm->phy + i; 67 phy = bcm->phy + i;
@@ -78,7 +78,7 @@ static int bcm43xx_wx_get_name(struct net_device *net_dev,
78 assert(0); 78 assert(0);
79 } 79 }
80 } 80 }
81 spin_unlock_irqrestore(&bcm->lock, flags); 81 bcm43xx_unlock(bcm, flags);
82 82
83 i = 0; 83 i = 0;
84 if (have_a) { 84 if (have_a) {
@@ -113,7 +113,7 @@ static int bcm43xx_wx_set_channelfreq(struct net_device *net_dev,
113 int freq; 113 int freq;
114 int err = -EINVAL; 114 int err = -EINVAL;
115 115
116 spin_lock_irqsave(&bcm->lock, flags); 116 bcm43xx_lock_mmio(bcm, flags);
117 if ((data->freq.m >= 0) && (data->freq.m <= 1000)) { 117 if ((data->freq.m >= 0) && (data->freq.m <= 1000)) {
118 channel = data->freq.m; 118 channel = data->freq.m;
119 freq = bcm43xx_channel_to_freq(bcm, channel); 119 freq = bcm43xx_channel_to_freq(bcm, channel);
@@ -133,7 +133,7 @@ static int bcm43xx_wx_set_channelfreq(struct net_device *net_dev,
133 err = 0; 133 err = 0;
134 } 134 }
135out_unlock: 135out_unlock:
136 spin_unlock_irqrestore(&bcm->lock, flags); 136 bcm43xx_unlock_mmio(bcm, flags);
137 137
138 return err; 138 return err;
139} 139}
@@ -148,7 +148,7 @@ static int bcm43xx_wx_get_channelfreq(struct net_device *net_dev,
148 int err = -ENODEV; 148 int err = -ENODEV;
149 u16 channel; 149 u16 channel;
150 150
151 spin_lock_irqsave(&bcm->lock, flags); 151 bcm43xx_lock(bcm, flags);
152 channel = bcm->current_core->radio->channel; 152 channel = bcm->current_core->radio->channel;
153 if (channel == 0xFF) { 153 if (channel == 0xFF) {
154 assert(!bcm->initialized); 154 assert(!bcm->initialized);
@@ -163,7 +163,7 @@ static int bcm43xx_wx_get_channelfreq(struct net_device *net_dev,
163 163
164 err = 0; 164 err = 0;
165out_unlock: 165out_unlock:
166 spin_unlock_irqrestore(&bcm->lock, flags); 166 bcm43xx_unlock(bcm, flags);
167 167
168 return err; 168 return err;
169} 169}
@@ -181,10 +181,10 @@ static int bcm43xx_wx_set_mode(struct net_device *net_dev,
181 if (mode == IW_MODE_AUTO) 181 if (mode == IW_MODE_AUTO)
182 mode = BCM43xx_INITIAL_IWMODE; 182 mode = BCM43xx_INITIAL_IWMODE;
183 183
184 spin_lock_irqsave(&bcm->lock, flags); 184 bcm43xx_lock_mmio(bcm, flags);
185 if (bcm->ieee->iw_mode != mode) 185 if (bcm->ieee->iw_mode != mode)
186 bcm43xx_set_iwmode(bcm, mode); 186 bcm43xx_set_iwmode(bcm, mode);
187 spin_unlock_irqrestore(&bcm->lock, flags); 187 bcm43xx_unlock_mmio(bcm, flags);
188 188
189 return 0; 189 return 0;
190} 190}
@@ -197,9 +197,9 @@ static int bcm43xx_wx_get_mode(struct net_device *net_dev,
197 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); 197 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
198 unsigned long flags; 198 unsigned long flags;
199 199
200 spin_lock_irqsave(&bcm->lock, flags); 200 bcm43xx_lock(bcm, flags);
201 data->mode = bcm->ieee->iw_mode; 201 data->mode = bcm->ieee->iw_mode;
202 spin_unlock_irqrestore(&bcm->lock, flags); 202 bcm43xx_unlock(bcm, flags);
203 203
204 return 0; 204 return 0;
205} 205}
@@ -269,7 +269,7 @@ static int bcm43xx_wx_get_rangeparams(struct net_device *net_dev,
269 IW_ENC_CAPA_CIPHER_TKIP | 269 IW_ENC_CAPA_CIPHER_TKIP |
270 IW_ENC_CAPA_CIPHER_CCMP; 270 IW_ENC_CAPA_CIPHER_CCMP;
271 271
272 spin_lock_irqsave(&bcm->lock, flags); 272 bcm43xx_lock(bcm, flags);
273 273
274 range->num_bitrates = 0; 274 range->num_bitrates = 0;
275 i = 0; 275 i = 0;
@@ -315,7 +315,7 @@ static int bcm43xx_wx_get_rangeparams(struct net_device *net_dev,
315 } 315 }
316 range->num_frequency = j; 316 range->num_frequency = j;
317 317
318 spin_unlock_irqrestore(&bcm->lock, flags); 318 bcm43xx_unlock(bcm, flags);
319 319
320 return 0; 320 return 0;
321} 321}
@@ -329,11 +329,11 @@ static int bcm43xx_wx_set_nick(struct net_device *net_dev,
329 unsigned long flags; 329 unsigned long flags;
330 size_t len; 330 size_t len;
331 331
332 spin_lock_irqsave(&bcm->lock, flags); 332 bcm43xx_lock(bcm, flags);
333 len = min((size_t)data->data.length, (size_t)IW_ESSID_MAX_SIZE); 333 len = min((size_t)data->data.length, (size_t)IW_ESSID_MAX_SIZE);
334 memcpy(bcm->nick, extra, len); 334 memcpy(bcm->nick, extra, len);
335 bcm->nick[len] = '\0'; 335 bcm->nick[len] = '\0';
336 spin_unlock_irqrestore(&bcm->lock, flags); 336 bcm43xx_unlock(bcm, flags);
337 337
338 return 0; 338 return 0;
339} 339}
@@ -347,12 +347,12 @@ static int bcm43xx_wx_get_nick(struct net_device *net_dev,
347 unsigned long flags; 347 unsigned long flags;
348 size_t len; 348 size_t len;
349 349
350 spin_lock_irqsave(&bcm->lock, flags); 350 bcm43xx_lock(bcm, flags);
351 len = strlen(bcm->nick) + 1; 351 len = strlen(bcm->nick) + 1;
352 memcpy(extra, bcm->nick, len); 352 memcpy(extra, bcm->nick, len);
353 data->data.length = (__u16)len; 353 data->data.length = (__u16)len;
354 data->data.flags = 1; 354 data->data.flags = 1;
355 spin_unlock_irqrestore(&bcm->lock, flags); 355 bcm43xx_unlock(bcm, flags);
356 356
357 return 0; 357 return 0;
358} 358}
@@ -366,7 +366,7 @@ static int bcm43xx_wx_set_rts(struct net_device *net_dev,
366 unsigned long flags; 366 unsigned long flags;
367 int err = -EINVAL; 367 int err = -EINVAL;
368 368
369 spin_lock_irqsave(&bcm->lock, flags); 369 bcm43xx_lock(bcm, flags);
370 if (data->rts.disabled) { 370 if (data->rts.disabled) {
371 bcm->rts_threshold = BCM43xx_MAX_RTS_THRESHOLD; 371 bcm->rts_threshold = BCM43xx_MAX_RTS_THRESHOLD;
372 err = 0; 372 err = 0;
@@ -377,7 +377,7 @@ static int bcm43xx_wx_set_rts(struct net_device *net_dev,
377 err = 0; 377 err = 0;
378 } 378 }
379 } 379 }
380 spin_unlock_irqrestore(&bcm->lock, flags); 380 bcm43xx_unlock(bcm, flags);
381 381
382 return err; 382 return err;
383} 383}
@@ -390,11 +390,11 @@ static int bcm43xx_wx_get_rts(struct net_device *net_dev,
390 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); 390 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
391 unsigned long flags; 391 unsigned long flags;
392 392
393 spin_lock_irqsave(&bcm->lock, flags); 393 bcm43xx_lock(bcm, flags);
394 data->rts.value = bcm->rts_threshold; 394 data->rts.value = bcm->rts_threshold;
395 data->rts.fixed = 0; 395 data->rts.fixed = 0;
396 data->rts.disabled = (bcm->rts_threshold == BCM43xx_MAX_RTS_THRESHOLD); 396 data->rts.disabled = (bcm->rts_threshold == BCM43xx_MAX_RTS_THRESHOLD);
397 spin_unlock_irqrestore(&bcm->lock, flags); 397 bcm43xx_unlock(bcm, flags);
398 398
399 return 0; 399 return 0;
400} 400}
@@ -408,7 +408,7 @@ static int bcm43xx_wx_set_frag(struct net_device *net_dev,
408 unsigned long flags; 408 unsigned long flags;
409 int err = -EINVAL; 409 int err = -EINVAL;
410 410
411 spin_lock_irqsave(&bcm->lock, flags); 411 bcm43xx_lock(bcm, flags);
412 if (data->frag.disabled) { 412 if (data->frag.disabled) {
413 bcm->ieee->fts = MAX_FRAG_THRESHOLD; 413 bcm->ieee->fts = MAX_FRAG_THRESHOLD;
414 err = 0; 414 err = 0;
@@ -419,7 +419,7 @@ static int bcm43xx_wx_set_frag(struct net_device *net_dev,
419 err = 0; 419 err = 0;
420 } 420 }
421 } 421 }
422 spin_unlock_irqrestore(&bcm->lock, flags); 422 bcm43xx_unlock(bcm, flags);
423 423
424 return err; 424 return err;
425} 425}
@@ -432,11 +432,11 @@ static int bcm43xx_wx_get_frag(struct net_device *net_dev,
432 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); 432 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
433 unsigned long flags; 433 unsigned long flags;
434 434
435 spin_lock_irqsave(&bcm->lock, flags); 435 bcm43xx_lock(bcm, flags);
436 data->frag.value = bcm->ieee->fts; 436 data->frag.value = bcm->ieee->fts;
437 data->frag.fixed = 0; 437 data->frag.fixed = 0;
438 data->frag.disabled = (bcm->ieee->fts == MAX_FRAG_THRESHOLD); 438 data->frag.disabled = (bcm->ieee->fts == MAX_FRAG_THRESHOLD);
439 spin_unlock_irqrestore(&bcm->lock, flags); 439 bcm43xx_unlock(bcm, flags);
440 440
441 return 0; 441 return 0;
442} 442}
@@ -458,7 +458,7 @@ static int bcm43xx_wx_set_xmitpower(struct net_device *net_dev,
458 return -EOPNOTSUPP; 458 return -EOPNOTSUPP;
459 } 459 }
460 460
461 spin_lock_irqsave(&bcm->lock, flags); 461 bcm43xx_lock_mmio(bcm, flags);
462 if (!bcm->initialized) 462 if (!bcm->initialized)
463 goto out_unlock; 463 goto out_unlock;
464 radio = bcm->current_core->radio; 464 radio = bcm->current_core->radio;
@@ -482,7 +482,7 @@ static int bcm43xx_wx_set_xmitpower(struct net_device *net_dev,
482 err = 0; 482 err = 0;
483 483
484out_unlock: 484out_unlock:
485 spin_unlock_irqrestore(&bcm->lock, flags); 485 bcm43xx_unlock_mmio(bcm, flags);
486 486
487 return err; 487 return err;
488} 488}
@@ -497,7 +497,7 @@ static int bcm43xx_wx_get_xmitpower(struct net_device *net_dev,
497 unsigned long flags; 497 unsigned long flags;
498 int err = -ENODEV; 498 int err = -ENODEV;
499 499
500 spin_lock_irqsave(&bcm->lock, flags); 500 bcm43xx_lock(bcm, flags);
501 if (!bcm->initialized) 501 if (!bcm->initialized)
502 goto out_unlock; 502 goto out_unlock;
503 radio = bcm->current_core->radio; 503 radio = bcm->current_core->radio;
@@ -509,7 +509,7 @@ static int bcm43xx_wx_get_xmitpower(struct net_device *net_dev,
509 509
510 err = 0; 510 err = 0;
511out_unlock: 511out_unlock:
512 spin_unlock_irqrestore(&bcm->lock, flags); 512 bcm43xx_unlock(bcm, flags);
513 513
514 return err; 514 return err;
515} 515}
@@ -632,7 +632,7 @@ static int bcm43xx_wx_set_interfmode(struct net_device *net_dev,
632 return -EINVAL; 632 return -EINVAL;
633 } 633 }
634 634
635 spin_lock_irqsave(&bcm->lock, flags); 635 bcm43xx_lock_mmio(bcm, flags);
636 if (bcm->initialized) { 636 if (bcm->initialized) {
637 err = bcm43xx_radio_set_interference_mitigation(bcm, mode); 637 err = bcm43xx_radio_set_interference_mitigation(bcm, mode);
638 if (err) { 638 if (err) {
@@ -647,7 +647,7 @@ static int bcm43xx_wx_set_interfmode(struct net_device *net_dev,
647 } else 647 } else
648 bcm->current_core->radio->interfmode = mode; 648 bcm->current_core->radio->interfmode = mode;
649 } 649 }
650 spin_unlock_irqrestore(&bcm->lock, flags); 650 bcm43xx_unlock_mmio(bcm, flags);
651 651
652 return err; 652 return err;
653} 653}
@@ -661,9 +661,9 @@ static int bcm43xx_wx_get_interfmode(struct net_device *net_dev,
661 unsigned long flags; 661 unsigned long flags;
662 int mode; 662 int mode;
663 663
664 spin_lock_irqsave(&bcm->lock, flags); 664 bcm43xx_lock(bcm, flags);
665 mode = bcm->current_core->radio->interfmode; 665 mode = bcm->current_core->radio->interfmode;
666 spin_unlock_irqrestore(&bcm->lock, flags); 666 bcm43xx_unlock(bcm, flags);
667 667
668 switch (mode) { 668 switch (mode) {
669 case BCM43xx_RADIO_INTERFMODE_NONE: 669 case BCM43xx_RADIO_INTERFMODE_NONE:
@@ -693,9 +693,9 @@ static int bcm43xx_wx_set_shortpreamble(struct net_device *net_dev,
693 int on; 693 int on;
694 694
695 on = *((int *)extra); 695 on = *((int *)extra);
696 spin_lock_irqsave(&bcm->lock, flags); 696 bcm43xx_lock(bcm, flags);
697 bcm->short_preamble = !!on; 697 bcm->short_preamble = !!on;
698 spin_unlock_irqrestore(&bcm->lock, flags); 698 bcm43xx_unlock(bcm, flags);
699 699
700 return 0; 700 return 0;
701} 701}
@@ -709,9 +709,9 @@ static int bcm43xx_wx_get_shortpreamble(struct net_device *net_dev,
709 unsigned long flags; 709 unsigned long flags;
710 int on; 710 int on;
711 711
712 spin_lock_irqsave(&bcm->lock, flags); 712 bcm43xx_lock(bcm, flags);
713 on = bcm->short_preamble; 713 on = bcm->short_preamble;
714 spin_unlock_irqrestore(&bcm->lock, flags); 714 bcm43xx_unlock(bcm, flags);
715 715
716 if (on) 716 if (on)
717 strncpy(extra, "1 (Short Preamble enabled)", MAX_WX_STRING); 717 strncpy(extra, "1 (Short Preamble enabled)", MAX_WX_STRING);
@@ -732,13 +732,13 @@ static int bcm43xx_wx_set_swencryption(struct net_device *net_dev,
732 int on; 732 int on;
733 733
734 on = *((int *)extra); 734 on = *((int *)extra);
735 spin_lock_irqsave(&bcm->lock, flags); 735
736 bcm43xx_lock(bcm, flags);
736 bcm->ieee->host_encrypt = !!on; 737 bcm->ieee->host_encrypt = !!on;
737 bcm->ieee->host_decrypt = !!on; 738 bcm->ieee->host_decrypt = !!on;
738 bcm->ieee->host_build_iv = !on; 739 bcm->ieee->host_build_iv = !on;
739 740 bcm43xx_unlock(bcm, flags);
740 spin_unlock_irqrestore(&bcm->lock, flags); 741
741
742 return 0; 742 return 0;
743} 743}
744 744
@@ -750,17 +750,17 @@ static int bcm43xx_wx_get_swencryption(struct net_device *net_dev,
750 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); 750 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
751 unsigned long flags; 751 unsigned long flags;
752 int on; 752 int on;
753 753
754 spin_lock_irqsave(&bcm->lock, flags); 754 bcm43xx_lock(bcm, flags);
755 on = bcm->ieee->host_encrypt; 755 on = bcm->ieee->host_encrypt;
756 spin_unlock_irqrestore(&bcm->lock, flags); 756 bcm43xx_unlock(bcm, flags);
757 757
758 if (on) 758 if (on)
759 strncpy(extra, "1 (SW encryption enabled) ", MAX_WX_STRING); 759 strncpy(extra, "1 (SW encryption enabled) ", MAX_WX_STRING);
760 else 760 else
761 strncpy(extra, "0 (SW encryption disabled) ", MAX_WX_STRING); 761 strncpy(extra, "0 (SW encryption disabled) ", MAX_WX_STRING);
762 data->data.length = strlen(extra + 1); 762 data->data.length = strlen(extra + 1);
763 763
764 return 0; 764 return 0;
765} 765}
766 766
@@ -816,17 +816,13 @@ static int bcm43xx_wx_sprom_read(struct net_device *net_dev,
816 if (!sprom) 816 if (!sprom)
817 goto out; 817 goto out;
818 818
819 spin_lock_irqsave(&bcm->lock, flags); 819 bcm43xx_lock_mmio(bcm, flags);
820 err = -ENODEV; 820 err = -ENODEV;
821 if (!bcm->initialized) { 821 if (bcm->initialized)
822 spin_unlock_irqrestore(&bcm->lock, flags); 822 err = bcm43xx_sprom_read(bcm, sprom);
823 goto out_kfree; 823 bcm43xx_unlock_mmio(bcm, flags);
824 }
825 err = bcm43xx_sprom_read(bcm, sprom);
826 spin_unlock_irqrestore(&bcm->lock, flags);
827 if (!err) 824 if (!err)
828 data->data.length = sprom2hex(sprom, extra); 825 data->data.length = sprom2hex(sprom, extra);
829out_kfree:
830 kfree(sprom); 826 kfree(sprom);
831out: 827out:
832 return err; 828 return err;
@@ -865,13 +861,11 @@ static int bcm43xx_wx_sprom_write(struct net_device *net_dev,
865 if (err) 861 if (err)
866 goto out_kfree; 862 goto out_kfree;
867 863
868 spin_lock_irqsave(&bcm->lock, flags); 864 bcm43xx_lock_mmio(bcm, flags);
869 err = -ENODEV; 865 err = -ENODEV;
870 if (!bcm->initialized) 866 if (bcm->initialized)
871 goto out_unlock; 867 err = bcm43xx_sprom_write(bcm, sprom);
872 err = bcm43xx_sprom_write(bcm, sprom); 868 bcm43xx_unlock_mmio(bcm, flags);
873out_unlock:
874 spin_unlock_irqrestore(&bcm->lock, flags);
875out_kfree: 869out_kfree:
876 kfree(sprom); 870 kfree(sprom);
877out: 871out: