summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorMichael Buesch <mbuesch@freenet.de>2006-03-11 13:39:14 +0100
committerJohn W. Linville <linville@tuxdriver.com>2006-03-27 11:19:35 -0500
commitefccb647f486ff8174b4db0ab8145df8dd42ce6d (patch)
tree099f947a1a99f5699c99011175dd8d6bf27fc0d4 /drivers/net
parent4d5a9e0eeb7ec928c6bd55db410f09ed3779bc2a (diff)
downloadop-kernel-dev-efccb647f486ff8174b4db0ab8145df8dd42ce6d.zip
op-kernel-dev-efccb647f486ff8174b4db0ab8145df8dd42ce6d.tar.gz
[PATCH] bcm43xx: Abstract the locking mechanism.
This is the starting point to make the driver out-of-order-MMIO-stores safe. There are more mmiowb() needed. Signed-off-by: Michael Buesch <mbuesch@freenet.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-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 fd9754b..5f8c63f 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -619,7 +619,9 @@ struct bcm43xx_private {
void __iomem *mmio_addr;
unsigned int mmio_len;
- spinlock_t lock;
+ /* Do not use the lock directly. Use the bcm43xx_lock* helper
+ * functions, to be MMIO-safe. */
+ spinlock_t _lock;
/* Driver status flags. */
u32 initialized:1, /* init_board() succeed */
@@ -721,6 +723,22 @@ struct bcm43xx_private {
#endif
};
+/* bcm43xx_(un)lock() protect struct bcm43xx_private.
+ * Note that _NO_ MMIO writes are allowed. If you want to
+ * write to the device through MMIO in the critical section, use
+ * the *_mmio lock functions.
+ * MMIO read-access is allowed, though.
+ */
+#define bcm43xx_lock(bcm, flags) spin_lock_irqsave(&(bcm)->_lock, flags)
+#define bcm43xx_unlock(bcm, flags) spin_unlock_irqrestore(&(bcm)->_lock, flags)
+/* bcm43xx_(un)lock_mmio() protect struct bcm43xx_private and MMIO.
+ * MMIO write-access to the device is allowed.
+ * All MMIO writes are flushed on unlock, so it is guaranteed to not
+ * interfere with other threads writing MMIO registers.
+ */
+#define bcm43xx_lock_mmio(bcm, flags) bcm43xx_lock(bcm, flags)
+#define bcm43xx_unlock_mmio(bcm, flags) do { mmiowb(); bcm43xx_unlock(bcm, flags); } while (0)
+
static inline
struct bcm43xx_private * bcm43xx_priv(struct net_device *dev)
{
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
index 0bae0be..bcfcebe 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,
down(&big_buffer_sem);
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
if (!bcm->initialized) {
fappend("Board not initialized.\n");
goto out;
@@ -124,7 +124,7 @@ static ssize_t devinfo_read_file(struct file *file, char __user *userbuf,
fappend("\n");
out:
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
up(&big_buffer_sem);
return res;
@@ -162,7 +162,7 @@ static ssize_t spromdump_read_file(struct file *file, char __user *userbuf,
unsigned long flags;
down(&big_buffer_sem);
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
if (!bcm->initialized) {
fappend("Board not initialized.\n");
goto out;
@@ -172,7 +172,7 @@ static ssize_t spromdump_read_file(struct file *file, char __user *userbuf,
fappend("boardflags: 0x%04x\n", bcm->sprom.boardflags);
out:
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
up(&big_buffer_sem);
return res;
@@ -191,7 +191,7 @@ static ssize_t tsf_read_file(struct file *file, char __user *userbuf,
u64 tsf;
down(&big_buffer_sem);
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
if (!bcm->initialized) {
fappend("Board not initialized.\n");
goto out;
@@ -202,7 +202,7 @@ static ssize_t tsf_read_file(struct file *file, char __user *userbuf,
(unsigned int)(tsf & 0xFFFFFFFFULL));
out:
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
up(&big_buffer_sem);
return res;
@@ -224,7 +224,7 @@ static ssize_t tsf_write_file(struct file *file, const char __user *user_buf,
res = -EFAULT;
goto out_up;
}
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
if (!bcm->initialized) {
printk(KERN_INFO PFX "debugfs: Board not initialized.\n");
res = -EFAULT;
@@ -239,7 +239,7 @@ static ssize_t tsf_write_file(struct file *file, const char __user *user_buf,
res = buf_size;
out_unlock:
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
out_up:
up(&big_buffer_sem);
return res;
@@ -260,7 +260,7 @@ static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
int i, cnt, j = 0;
down(&big_buffer_sem);
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
fappend("Last %d logged xmitstatus blobs (Latest first):\n\n",
BCM43xx_NR_LOGGED_XMITSTATUS);
@@ -296,14 +296,14 @@ static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
i = BCM43xx_NR_LOGGED_XMITSTATUS - 1;
}
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
if (*ppos == pos) {
/* Done. Drop the copied data. */
e->xmitstatus_printing = 0;
}
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
up(&big_buffer_sem);
return res;
}
@@ -419,7 +419,7 @@ void bcm43xx_debugfs_log_txstat(struct bcm43xx_private *bcm,
struct bcm43xx_dfsentry *e;
struct bcm43xx_xmitstatus *savedstatus;
- /* This is protected by bcm->lock */
+ /* This is protected by bcm->_lock */
e = bcm->dfsentry;
assert(e);
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 8f550c1..949555d 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)
struct bcm43xx_private *bcm = led->bcm;
unsigned long flags;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
if (led->blink_interval) {
bcm43xx_led_changestate(led);
mod_timer(&led->blink_timer, jiffies + led->blink_interval);
}
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
}
static 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 6da0beb..b719255 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
u32 old;
unsigned long flags;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
if (bcm43xx_is_initializing(bcm) || bcm->shutting_down) {
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
return -EBUSY;
}
old = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
tasklet_disable(&bcm->isr_tasklet);
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
if (oldstate)
*oldstate = old;
@@ -746,6 +746,7 @@ int bcm43xx_sprom_write(struct bcm43xx_private *bcm, const u16 *sprom)
else if (i % 2)
printk(".");
bcm43xx_write16(bcm, BCM43xx_SPROM_BASE + (i * 2), sprom[i]);
+ mmiowb();
mdelay(20);
}
spromctl &= ~0x10; /* SPROM WRITE enable. */
@@ -1676,7 +1677,7 @@ static void bcm43xx_interrupt_tasklet(struct bcm43xx_private *bcm)
# define bcmirq_handled(irq) do { /* nothing */ } while (0)
#endif /* CONFIG_BCM43XX_DEBUG*/
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
reason = bcm->irq_reason;
dma_reason[0] = bcm->dma_reason[0];
dma_reason[1] = bcm->dma_reason[1];
@@ -1776,7 +1777,7 @@ static void bcm43xx_interrupt_tasklet(struct bcm43xx_private *bcm)
if (!modparam_noleds)
bcm43xx_leds_update(bcm, activity);
bcm43xx_interrupt_enable(bcm, bcm->irq_savedstate);
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
}
#undef bcmirq_print_reasons
@@ -1830,25 +1831,24 @@ static void bcm43xx_interrupt_ack(struct bcm43xx_private *bcm,
/* Interrupt handler top-half */
static irqreturn_t bcm43xx_interrupt_handler(int irq, void *dev_id, struct pt_regs *regs)
{
+ irqreturn_t ret = IRQ_HANDLED;
struct bcm43xx_private *bcm = dev_id;
u32 reason, mask;
if (!bcm)
return IRQ_NONE;
- spin_lock(&bcm->lock);
+ spin_lock(&bcm->_lock);
reason = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON);
if (reason == 0xffffffff) {
/* irq not for us (shared irq) */
- spin_unlock(&bcm->lock);
- return IRQ_NONE;
+ ret = IRQ_NONE;
+ goto out;
}
mask = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_MASK);
- if (!(reason & mask)) {
- spin_unlock(&bcm->lock);
- return IRQ_HANDLED;
- }
+ if (!(reason & mask))
+ goto out;
bcm43xx_interrupt_ack(bcm, reason, mask);
@@ -1866,9 +1866,11 @@ static irqreturn_t bcm43xx_interrupt_handler(int irq, void *dev_id, struct pt_re
tasklet_schedule(&bcm->isr_tasklet);
}
- spin_unlock(&bcm->lock);
+out:
+ mmiowb();
+ spin_unlock(&bcm->_lock);
- return IRQ_HANDLED;
+ return ret;
}
static void bcm43xx_release_firmware(struct bcm43xx_private *bcm, int force)
@@ -3112,7 +3114,7 @@ static void bcm43xx_periodic_task_handler(unsigned long d)
unsigned long flags;
unsigned int state;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
assert(bcm->initialized);
state = bcm->periodic_state;
@@ -3127,7 +3129,7 @@ static void bcm43xx_periodic_task_handler(unsigned long d)
mod_timer(&bcm->periodic_tasks, jiffies + (HZ * 15));
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
}
static void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm)
@@ -3164,10 +3166,10 @@ static void bcm43xx_free_board(struct bcm43xx_private *bcm)
bcm43xx_periodic_tasks_delete(bcm);
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
bcm->initialized = 0;
bcm->shutting_down = 1;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) {
if (!(bcm->core_80211[i].flags & BCM43xx_COREFLAG_AVAILABLE))
@@ -3182,9 +3184,9 @@ static void bcm43xx_free_board(struct bcm43xx_private *bcm)
bcm43xx_pctl_set_crystal(bcm, 0);
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
bcm->shutting_down = 0;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
}
static int bcm43xx_init_board(struct bcm43xx_private *bcm)
@@ -3196,10 +3198,10 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
might_sleep();
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
bcm->initialized = 0;
bcm->shutting_down = 0;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
err = bcm43xx_pctl_set_crystal(bcm, 1);
if (err)
@@ -3267,9 +3269,9 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
}
/* Initialization of the board is done. Flag it as such. */
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
bcm->initialized = 1;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
bcm43xx_periodic_tasks_setup(bcm);
bcm43xx_sysfs_register(bcm);
@@ -3570,11 +3572,11 @@ static void bcm43xx_ieee80211_set_chan(struct net_device *net_dev,
struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
unsigned long flags;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
bcm43xx_mac_suspend(bcm);
bcm43xx_radio_selectchannel(bcm, channel, 0);
bcm43xx_mac_enable(bcm);
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
}
/* set_security() callback in struct ieee80211_device */
@@ -3587,9 +3589,9 @@ static void bcm43xx_ieee80211_set_security(struct net_device *net_dev,
int keyidx;
dprintk(KERN_INFO PFX "set security called\n");
-
- spin_lock_irqsave(&bcm->lock, flags);
-
+
+ bcm43xx_lock_mmio(bcm, flags);
+
for (keyidx = 0; keyidx<WEP_KEYS; keyidx++)
if (sec->flags & (1<<keyidx)) {
secinfo->encode_alg[keyidx] = sec->encode_alg[keyidx];
@@ -3651,7 +3653,7 @@ static void bcm43xx_ieee80211_set_security(struct net_device *net_dev,
} else
bcm43xx_clear_keys(bcm);
}
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
}
/* hard_start_xmit() callback in struct ieee80211_device */
@@ -3663,10 +3665,10 @@ static int bcm43xx_ieee80211_hard_start_xmit(struct ieee80211_txb *txb,
int err = -ENODEV;
unsigned long flags;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
if (likely(bcm->initialized))
err = bcm43xx_tx(bcm, txb);
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
return err;
}
@@ -3679,8 +3681,11 @@ static struct net_device_stats * bcm43xx_net_get_stats(struct net_device *net_de
static void bcm43xx_net_tx_timeout(struct net_device *net_dev)
{
struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
+ unsigned long flags;
+ bcm43xx_lock_mmio(bcm, flags);
bcm43xx_controller_restart(bcm, "TX timeout");
+ bcm43xx_unlock_mmio(bcm, flags);
}
#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -3738,7 +3743,7 @@ static int bcm43xx_init_private(struct bcm43xx_private *bcm,
bcm->pci_dev = pci_dev;
bcm->net_dev = net_dev;
bcm->bad_frames_preempt = modparam_bad_frames_preempt;
- spin_lock_init(&bcm->lock);
+ spin_lock_init(&bcm->_lock);
tasklet_init(&bcm->isr_tasklet,
(void (*)(unsigned long))bcm43xx_interrupt_tasklet,
(unsigned long)bcm);
@@ -3921,11 +3926,11 @@ static int bcm43xx_suspend(struct pci_dev *pdev, pm_message_t state)
dprintk(KERN_INFO PFX "Suspending...\n");
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
bcm->was_initialized = bcm->initialized;
if (bcm->initialized)
try_to_shutdown = 1;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
netif_device_detach(net_dev);
if (try_to_shutdown) {
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_pio.c b/drivers/net/wireless/bcm43xx/bcm43xx_pio.c
index 7b45fa1..26dc604 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)
struct bcm43xx_pio_txpacket *packet, *tmp_packet;
int err;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
list_for_each_entry_safe(packet, tmp_packet, &queue->txqueue, list) {
assert(packet->xmitted_frags < packet->txb->nr_frags);
if (packet->xmitted_frags == 0) {
@@ -288,7 +288,7 @@ static void tx_tasklet(unsigned long d)
next_packet:
continue;
}
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
}
static 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 2d31737..713ec60 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,
GFP_KERNEL);
if (!sprom)
return -ENOMEM;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
assert(bcm->initialized);
err = bcm43xx_sprom_read(bcm, sprom);
if (!err) {
@@ -97,7 +97,7 @@ static ssize_t bcm43xx_attr_sprom_show(struct device *dev,
buf[i * 2 + 1] = (sprom[i] & 0xFF00) >> 8;
}
}
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
kfree(sprom);
return err ? err : BCM43xx_SPROM_SIZE * sizeof(u16);
@@ -125,10 +125,10 @@ static ssize_t bcm43xx_attr_sprom_store(struct device *dev,
sprom[i] = buf[i * 2] & 0xFF;
sprom[i] |= ((u16)(buf[i * 2 + 1] & 0xFF)) << 8;
}
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
assert(bcm->initialized);
err = bcm43xx_sprom_write(bcm, sprom);
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
kfree(sprom);
return err ? err : count;
@@ -147,7 +147,7 @@ static ssize_t bcm43xx_attr_interfmode_show(struct device *dev,
if (!capable(CAP_NET_ADMIN))
return -EPERM;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
assert(bcm->initialized);
switch (bcm->current_core->radio->interfmode) {
@@ -165,7 +165,8 @@ static ssize_t bcm43xx_attr_interfmode_show(struct device *dev,
}
err = 0;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
+
return err ? err : count;
}
@@ -200,7 +201,7 @@ static ssize_t bcm43xx_attr_interfmode_store(struct device *dev,
return -EINVAL;
}
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
assert(bcm->initialized);
err = bcm43xx_radio_set_interference_mitigation(bcm, mode);
@@ -209,7 +210,7 @@ static ssize_t bcm43xx_attr_interfmode_store(struct device *dev,
"supported by device\n");
}
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
return err ? err : count;
}
@@ -226,7 +227,7 @@ static ssize_t bcm43xx_attr_preamble_show(struct device *dev,
if (!capable(CAP_NET_ADMIN))
return -EPERM;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
assert(bcm->initialized);
if (bcm->short_preamble)
@@ -235,7 +236,7 @@ static ssize_t bcm43xx_attr_preamble_show(struct device *dev,
count = snprintf(buf, PAGE_SIZE, "0 (Short Preamble disabled)\n");
err = 0;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return err ? err : count;
}
@@ -255,13 +256,13 @@ static ssize_t bcm43xx_attr_preamble_store(struct device *dev,
value = get_boolean(buf, count);
if (value < 0)
return value;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
assert(bcm->initialized);
bcm->short_preamble = !!value;
err = 0;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return err ? err : count;
}
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
index aa2d993..2081938 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,
char suffix[7] = { 0 };
int have_a = 0, have_b = 0, have_g = 0;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
nr_80211 = bcm43xx_num_80211_cores(bcm);
for (i = 0; i < nr_80211; i++) {
phy = bcm->phy + i;
@@ -78,7 +78,7 @@ static int bcm43xx_wx_get_name(struct net_device *net_dev,
assert(0);
}
}
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
i = 0;
if (have_a) {
@@ -113,7 +113,7 @@ static int bcm43xx_wx_set_channelfreq(struct net_device *net_dev,
int freq;
int err = -EINVAL;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
if ((data->freq.m >= 0) && (data->freq.m <= 1000)) {
channel = data->freq.m;
freq = bcm43xx_channel_to_freq(bcm, channel);
@@ -133,7 +133,7 @@ static int bcm43xx_wx_set_channelfreq(struct net_device *net_dev,
err = 0;
}
out_unlock:
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
return err;
}
@@ -148,7 +148,7 @@ static int bcm43xx_wx_get_channelfreq(struct net_device *net_dev,
int err = -ENODEV;
u16 channel;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
channel = bcm->current_core->radio->channel;
if (channel == 0xFF) {
assert(!bcm->initialized);
@@ -163,7 +163,7 @@ static int bcm43xx_wx_get_channelfreq(struct net_device *net_dev,
err = 0;
out_unlock:
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return err;
}
@@ -181,10 +181,10 @@ static int bcm43xx_wx_set_mode(struct net_device *net_dev,
if (mode == IW_MODE_AUTO)
mode = BCM43xx_INITIAL_IWMODE;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
if (bcm->ieee->iw_mode != mode)
bcm43xx_set_iwmode(bcm, mode);
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
return 0;
}
@@ -197,9 +197,9 @@ static int bcm43xx_wx_get_mode(struct net_device *net_dev,
struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
unsigned long flags;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
data->mode = bcm->ieee->iw_mode;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return 0;
}
@@ -269,7 +269,7 @@ static int bcm43xx_wx_get_rangeparams(struct net_device *net_dev,
IW_ENC_CAPA_CIPHER_TKIP |
IW_ENC_CAPA_CIPHER_CCMP;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
range->num_bitrates = 0;
i = 0;
@@ -315,7 +315,7 @@ static int bcm43xx_wx_get_rangeparams(struct net_device *net_dev,
}
range->num_frequency = j;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return 0;
}
@@ -329,11 +329,11 @@ static int bcm43xx_wx_set_nick(struct net_device *net_dev,
unsigned long flags;
size_t len;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
len = min((size_t)data->data.length, (size_t)IW_ESSID_MAX_SIZE);
memcpy(bcm->nick, extra, len);
bcm->nick[len] = '\0';
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return 0;
}
@@ -347,12 +347,12 @@ static int bcm43xx_wx_get_nick(struct net_device *net_dev,
unsigned long flags;
size_t len;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
len = strlen(bcm->nick) + 1;
memcpy(extra, bcm->nick, len);
data->data.length = (__u16)len;
data->data.flags = 1;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return 0;
}
@@ -366,7 +366,7 @@ static int bcm43xx_wx_set_rts(struct net_device *net_dev,
unsigned long flags;
int err = -EINVAL;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
if (data->rts.disabled) {
bcm->rts_threshold = BCM43xx_MAX_RTS_THRESHOLD;
err = 0;
@@ -377,7 +377,7 @@ static int bcm43xx_wx_set_rts(struct net_device *net_dev,
err = 0;
}
}
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return err;
}
@@ -390,11 +390,11 @@ static int bcm43xx_wx_get_rts(struct net_device *net_dev,
struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
unsigned long flags;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
data->rts.value = bcm->rts_threshold;
data->rts.fixed = 0;
data->rts.disabled = (bcm->rts_threshold == BCM43xx_MAX_RTS_THRESHOLD);
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return 0;
}
@@ -408,7 +408,7 @@ static int bcm43xx_wx_set_frag(struct net_device *net_dev,
unsigned long flags;
int err = -EINVAL;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
if (data->frag.disabled) {
bcm->ieee->fts = MAX_FRAG_THRESHOLD;
err = 0;
@@ -419,7 +419,7 @@ static int bcm43xx_wx_set_frag(struct net_device *net_dev,
err = 0;
}
}
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return err;
}
@@ -432,11 +432,11 @@ static int bcm43xx_wx_get_frag(struct net_device *net_dev,
struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
unsigned long flags;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
data->frag.value = bcm->ieee->fts;
data->frag.fixed = 0;
data->frag.disabled = (bcm->ieee->fts == MAX_FRAG_THRESHOLD);
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return 0;
}
@@ -458,7 +458,7 @@ static int bcm43xx_wx_set_xmitpower(struct net_device *net_dev,
return -EOPNOTSUPP;
}
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
if (!bcm->initialized)
goto out_unlock;
radio = bcm->current_core->radio;
@@ -482,7 +482,7 @@ static int bcm43xx_wx_set_xmitpower(struct net_device *net_dev,
err = 0;
out_unlock:
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
return err;
}
@@ -497,7 +497,7 @@ static int bcm43xx_wx_get_xmitpower(struct net_device *net_dev,
unsigned long flags;
int err = -ENODEV;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
if (!bcm->initialized)
goto out_unlock;
radio = bcm->current_core->radio;
@@ -509,7 +509,7 @@ static int bcm43xx_wx_get_xmitpower(struct net_device *net_dev,
err = 0;
out_unlock:
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return err;
}
@@ -632,7 +632,7 @@ static int bcm43xx_wx_set_interfmode(struct net_device *net_dev,
return -EINVAL;
}
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
if (bcm->initialized) {
err = bcm43xx_radio_set_interference_mitigation(bcm, mode);
if (err) {
@@ -647,7 +647,7 @@ static int bcm43xx_wx_set_interfmode(struct net_device *net_dev,
} else
bcm->current_core->radio->interfmode = mode;
}
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock_mmio(bcm, flags);
return err;
}
@@ -661,9 +661,9 @@ static int bcm43xx_wx_get_interfmode(struct net_device *net_dev,
unsigned long flags;
int mode;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
mode = bcm->current_core->radio->interfmode;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
switch (mode) {
case BCM43xx_RADIO_INTERFMODE_NONE:
@@ -693,9 +693,9 @@ static int bcm43xx_wx_set_shortpreamble(struct net_device *net_dev,
int on;
on = *((int *)extra);
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
bcm->short_preamble = !!on;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
return 0;
}
@@ -709,9 +709,9 @@ static int bcm43xx_wx_get_shortpreamble(struct net_device *net_dev,
unsigned long flags;
int on;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock(bcm, flags);
on = bcm->short_preamble;
- spin_unlock_irqrestore(&bcm->lock, flags);
+ bcm43xx_unlock(bcm, flags);
if (on)
strncpy(extra, "1 (Short Preamble enabled)", MAX_WX_STRING);
@@ -732,13 +732,13 @@ static int bcm43xx_wx_set_swencryption(struct net_device *net_dev,
int on;
on = *((int *)extra);
- spin_lock_irqsave(&bcm->lock, flags);
+
+ bcm43xx_lock(bcm, flags);
bcm->ieee->host_encrypt = !!on;
bcm->ieee->host_decrypt = !!on;
bcm->ieee->host_build_iv = !on;
-
- spin_unlock_irqrestore(&bcm->lock, flags);
-
+ bcm43xx_unlock(bcm, flags);
+
return 0;
}
@@ -750,17 +750,17 @@ static int bcm43xx_wx_get_swencryption(struct net_device *net_dev,
struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
unsigned long flags;
int on;
-
- spin_lock_irqsave(&bcm->lock, flags);
+
+ bcm43xx_lock(bcm, flags);
on = bcm->ieee->host_encrypt;
- spin_unlock_irqrestore(&bcm->lock, flags);
-
+ bcm43xx_unlock(bcm, flags);
+
if (on)
strncpy(extra, "1 (SW encryption enabled) ", MAX_WX_STRING);
else
strncpy(extra, "0 (SW encryption disabled) ", MAX_WX_STRING);
data->data.length = strlen(extra + 1);
-
+
return 0;
}
@@ -816,17 +816,13 @@ static int bcm43xx_wx_sprom_read(struct net_device *net_dev,
if (!sprom)
goto out;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
err = -ENODEV;
- if (!bcm->initialized) {
- spin_unlock_irqrestore(&bcm->lock, flags);
- goto out_kfree;
- }
- err = bcm43xx_sprom_read(bcm, sprom);
- spin_unlock_irqrestore(&bcm->lock, flags);
+ if (bcm->initialized)
+ err = bcm43xx_sprom_read(bcm, sprom);
+ bcm43xx_unlock_mmio(bcm, flags);
if (!err)
data->data.length = sprom2hex(sprom, extra);
-out_kfree:
kfree(sprom);
out:
return err;
@@ -865,13 +861,11 @@ static int bcm43xx_wx_sprom_write(struct net_device *net_dev,
if (err)
goto out_kfree;
- spin_lock_irqsave(&bcm->lock, flags);
+ bcm43xx_lock_mmio(bcm, flags);
err = -ENODEV;
- if (!bcm->initialized)
- goto out_unlock;
- err = bcm43xx_sprom_write(bcm, sprom);
-out_unlock:
- spin_unlock_irqrestore(&bcm->lock, flags);
+ if (bcm->initialized)
+ err = bcm43xx_sprom_write(bcm, sprom);
+ bcm43xx_unlock_mmio(bcm, flags);
out_kfree:
kfree(sprom);
out:
OpenPOWER on IntegriCloud