aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-10-21 14:21:11 -0400
committerJeff Garzik <jeff@garzik.org>2006-10-21 14:21:11 -0400
commitcde49b058474ab3f7ff830283e5b538e8fbeefe5 (patch)
tree28fdc4035af01d19c4f976d020ce98f251298182
parentcfadbd298e8b3e7f2e324696b653bb74094590db (diff)
parent41072a1be57f63bf83afc31c44d72de018d800fa (diff)
Merge branch 'upstream-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6 into upstream-fixes
-rw-r--r--drivers/net/wireless/airo.c105
-rw-r--r--drivers/net/wireless/atmel.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_dma.c28
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_dma.h17
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_leds.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c34
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_wx.c2
-rw-r--r--drivers/net/wireless/orinoco.c16
-rw-r--r--drivers/net/wireless/ray_cs.c1
-rw-r--r--drivers/net/wireless/zd1201.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c2
-rw-r--r--include/net/ieee80211softmac.h35
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_assoc.c56
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_io.c11
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_module.c1
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_wx.c71
16 files changed, 238 insertions, 151 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 0a33c8a56e13..efcdaf1c5f73 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2897,6 +2897,8 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2897 goto err_out_map; 2897 goto err_out_map;
2898 } 2898 }
2899 ai->wifidev = init_wifidev(ai, dev); 2899 ai->wifidev = init_wifidev(ai, dev);
2900 if (!ai->wifidev)
2901 goto err_out_reg;
2900 2902
2901 set_bit(FLAG_REGISTERED,&ai->flags); 2903 set_bit(FLAG_REGISTERED,&ai->flags);
2902 airo_print_info(dev->name, "MAC enabled %x:%x:%x:%x:%x:%x", 2904 airo_print_info(dev->name, "MAC enabled %x:%x:%x:%x:%x:%x",
@@ -2908,11 +2910,18 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2908 for( i = 0; i < MAX_FIDS; i++ ) 2910 for( i = 0; i < MAX_FIDS; i++ )
2909 ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2); 2911 ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2);
2910 2912
2911 setup_proc_entry( dev, dev->priv ); /* XXX check for failure */ 2913 if (setup_proc_entry(dev, dev->priv) < 0)
2914 goto err_out_wifi;
2915
2912 netif_start_queue(dev); 2916 netif_start_queue(dev);
2913 SET_MODULE_OWNER(dev); 2917 SET_MODULE_OWNER(dev);
2914 return dev; 2918 return dev;
2915 2919
2920err_out_wifi:
2921 unregister_netdev(ai->wifidev);
2922 free_netdev(ai->wifidev);
2923err_out_reg:
2924 unregister_netdev(dev);
2916err_out_map: 2925err_out_map:
2917 if (test_bit(FLAG_MPI,&ai->flags) && pci) { 2926 if (test_bit(FLAG_MPI,&ai->flags) && pci) {
2918 pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma); 2927 pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma);
@@ -3089,7 +3098,8 @@ static int airo_thread(void *data) {
3089 set_bit(JOB_AUTOWEP, &ai->jobs); 3098 set_bit(JOB_AUTOWEP, &ai->jobs);
3090 break; 3099 break;
3091 } 3100 }
3092 if (!kthread_should_stop()) { 3101 if (!kthread_should_stop() &&
3102 !freezing(current)) {
3093 unsigned long wake_at; 3103 unsigned long wake_at;
3094 if (!ai->expires || !ai->scan_timeout) { 3104 if (!ai->expires || !ai->scan_timeout) {
3095 wake_at = max(ai->expires, 3105 wake_at = max(ai->expires,
@@ -3101,7 +3111,8 @@ static int airo_thread(void *data) {
3101 schedule_timeout(wake_at - jiffies); 3111 schedule_timeout(wake_at - jiffies);
3102 continue; 3112 continue;
3103 } 3113 }
3104 } else if (!kthread_should_stop()) { 3114 } else if (!kthread_should_stop() &&
3115 !freezing(current)) {
3105 schedule(); 3116 schedule();
3106 continue; 3117 continue;
3107 } 3118 }
@@ -4495,91 +4506,128 @@ static int setup_proc_entry( struct net_device *dev,
4495 apriv->proc_entry = create_proc_entry(apriv->proc_name, 4506 apriv->proc_entry = create_proc_entry(apriv->proc_name,
4496 S_IFDIR|airo_perm, 4507 S_IFDIR|airo_perm,
4497 airo_entry); 4508 airo_entry);
4498 apriv->proc_entry->uid = proc_uid; 4509 if (!apriv->proc_entry)
4499 apriv->proc_entry->gid = proc_gid; 4510 goto fail;
4500 apriv->proc_entry->owner = THIS_MODULE; 4511 apriv->proc_entry->uid = proc_uid;
4512 apriv->proc_entry->gid = proc_gid;
4513 apriv->proc_entry->owner = THIS_MODULE;
4501 4514
4502 /* Setup the StatsDelta */ 4515 /* Setup the StatsDelta */
4503 entry = create_proc_entry("StatsDelta", 4516 entry = create_proc_entry("StatsDelta",
4504 S_IFREG | (S_IRUGO&proc_perm), 4517 S_IFREG | (S_IRUGO&proc_perm),
4505 apriv->proc_entry); 4518 apriv->proc_entry);
4506 entry->uid = proc_uid; 4519 if (!entry)
4507 entry->gid = proc_gid; 4520 goto fail_stats_delta;
4521 entry->uid = proc_uid;
4522 entry->gid = proc_gid;
4508 entry->data = dev; 4523 entry->data = dev;
4509 entry->owner = THIS_MODULE; 4524 entry->owner = THIS_MODULE;
4510 SETPROC_OPS(entry, proc_statsdelta_ops); 4525 SETPROC_OPS(entry, proc_statsdelta_ops);
4511 4526
4512 /* Setup the Stats */ 4527 /* Setup the Stats */
4513 entry = create_proc_entry("Stats", 4528 entry = create_proc_entry("Stats",
4514 S_IFREG | (S_IRUGO&proc_perm), 4529 S_IFREG | (S_IRUGO&proc_perm),
4515 apriv->proc_entry); 4530 apriv->proc_entry);
4516 entry->uid = proc_uid; 4531 if (!entry)
4517 entry->gid = proc_gid; 4532 goto fail_stats;
4533 entry->uid = proc_uid;
4534 entry->gid = proc_gid;
4518 entry->data = dev; 4535 entry->data = dev;
4519 entry->owner = THIS_MODULE; 4536 entry->owner = THIS_MODULE;
4520 SETPROC_OPS(entry, proc_stats_ops); 4537 SETPROC_OPS(entry, proc_stats_ops);
4521 4538
4522 /* Setup the Status */ 4539 /* Setup the Status */
4523 entry = create_proc_entry("Status", 4540 entry = create_proc_entry("Status",
4524 S_IFREG | (S_IRUGO&proc_perm), 4541 S_IFREG | (S_IRUGO&proc_perm),
4525 apriv->proc_entry); 4542 apriv->proc_entry);
4526 entry->uid = proc_uid; 4543 if (!entry)
4527 entry->gid = proc_gid; 4544 goto fail_status;
4545 entry->uid = proc_uid;
4546 entry->gid = proc_gid;
4528 entry->data = dev; 4547 entry->data = dev;
4529 entry->owner = THIS_MODULE; 4548 entry->owner = THIS_MODULE;
4530 SETPROC_OPS(entry, proc_status_ops); 4549 SETPROC_OPS(entry, proc_status_ops);
4531 4550
4532 /* Setup the Config */ 4551 /* Setup the Config */
4533 entry = create_proc_entry("Config", 4552 entry = create_proc_entry("Config",
4534 S_IFREG | proc_perm, 4553 S_IFREG | proc_perm,
4535 apriv->proc_entry); 4554 apriv->proc_entry);
4536 entry->uid = proc_uid; 4555 if (!entry)
4537 entry->gid = proc_gid; 4556 goto fail_config;
4557 entry->uid = proc_uid;
4558 entry->gid = proc_gid;
4538 entry->data = dev; 4559 entry->data = dev;
4539 entry->owner = THIS_MODULE; 4560 entry->owner = THIS_MODULE;
4540 SETPROC_OPS(entry, proc_config_ops); 4561 SETPROC_OPS(entry, proc_config_ops);
4541 4562
4542 /* Setup the SSID */ 4563 /* Setup the SSID */
4543 entry = create_proc_entry("SSID", 4564 entry = create_proc_entry("SSID",
4544 S_IFREG | proc_perm, 4565 S_IFREG | proc_perm,
4545 apriv->proc_entry); 4566 apriv->proc_entry);
4546 entry->uid = proc_uid; 4567 if (!entry)
4547 entry->gid = proc_gid; 4568 goto fail_ssid;
4569 entry->uid = proc_uid;
4570 entry->gid = proc_gid;
4548 entry->data = dev; 4571 entry->data = dev;
4549 entry->owner = THIS_MODULE; 4572 entry->owner = THIS_MODULE;
4550 SETPROC_OPS(entry, proc_SSID_ops); 4573 SETPROC_OPS(entry, proc_SSID_ops);
4551 4574
4552 /* Setup the APList */ 4575 /* Setup the APList */
4553 entry = create_proc_entry("APList", 4576 entry = create_proc_entry("APList",
4554 S_IFREG | proc_perm, 4577 S_IFREG | proc_perm,
4555 apriv->proc_entry); 4578 apriv->proc_entry);
4556 entry->uid = proc_uid; 4579 if (!entry)
4557 entry->gid = proc_gid; 4580 goto fail_aplist;
4581 entry->uid = proc_uid;
4582 entry->gid = proc_gid;
4558 entry->data = dev; 4583 entry->data = dev;
4559 entry->owner = THIS_MODULE; 4584 entry->owner = THIS_MODULE;
4560 SETPROC_OPS(entry, proc_APList_ops); 4585 SETPROC_OPS(entry, proc_APList_ops);
4561 4586
4562 /* Setup the BSSList */ 4587 /* Setup the BSSList */
4563 entry = create_proc_entry("BSSList", 4588 entry = create_proc_entry("BSSList",
4564 S_IFREG | proc_perm, 4589 S_IFREG | proc_perm,
4565 apriv->proc_entry); 4590 apriv->proc_entry);
4591 if (!entry)
4592 goto fail_bsslist;
4566 entry->uid = proc_uid; 4593 entry->uid = proc_uid;
4567 entry->gid = proc_gid; 4594 entry->gid = proc_gid;
4568 entry->data = dev; 4595 entry->data = dev;
4569 entry->owner = THIS_MODULE; 4596 entry->owner = THIS_MODULE;
4570 SETPROC_OPS(entry, proc_BSSList_ops); 4597 SETPROC_OPS(entry, proc_BSSList_ops);
4571 4598
4572 /* Setup the WepKey */ 4599 /* Setup the WepKey */
4573 entry = create_proc_entry("WepKey", 4600 entry = create_proc_entry("WepKey",
4574 S_IFREG | proc_perm, 4601 S_IFREG | proc_perm,
4575 apriv->proc_entry); 4602 apriv->proc_entry);
4576 entry->uid = proc_uid; 4603 if (!entry)
4577 entry->gid = proc_gid; 4604 goto fail_wepkey;
4605 entry->uid = proc_uid;
4606 entry->gid = proc_gid;
4578 entry->data = dev; 4607 entry->data = dev;
4579 entry->owner = THIS_MODULE; 4608 entry->owner = THIS_MODULE;
4580 SETPROC_OPS(entry, proc_wepkey_ops); 4609 SETPROC_OPS(entry, proc_wepkey_ops);
4581 4610
4582 return 0; 4611 return 0;
4612
4613fail_wepkey:
4614 remove_proc_entry("BSSList", apriv->proc_entry);
4615fail_bsslist:
4616 remove_proc_entry("APList", apriv->proc_entry);
4617fail_aplist:
4618 remove_proc_entry("SSID", apriv->proc_entry);
4619fail_ssid:
4620 remove_proc_entry("Config", apriv->proc_entry);
4621fail_config:
4622 remove_proc_entry("Status", apriv->proc_entry);
4623fail_status:
4624 remove_proc_entry("Stats", apriv->proc_entry);
4625fail_stats:
4626 remove_proc_entry("StatsDelta", apriv->proc_entry);
4627fail_stats_delta:
4628 remove_proc_entry(apriv->proc_name, airo_entry);
4629fail:
4630 return -ENOMEM;
4583} 4631}
4584 4632
4585static int takedown_proc_entry( struct net_device *dev, 4633static int takedown_proc_entry( struct net_device *dev,
@@ -5924,7 +5972,6 @@ static int airo_get_essid(struct net_device *dev,
5924 5972
5925 /* Get the current SSID */ 5973 /* Get the current SSID */
5926 memcpy(extra, status_rid.SSID, status_rid.SSIDlen); 5974 memcpy(extra, status_rid.SSID, status_rid.SSIDlen);
5927 extra[status_rid.SSIDlen] = '\0';
5928 /* If none, we may want to get the one that was set */ 5975 /* If none, we may want to get the one that was set */
5929 5976
5930 /* Push it out ! */ 5977 /* Push it out ! */
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 31eed85de60f..0c07b8b7250d 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -1678,11 +1678,9 @@ static int atmel_get_essid(struct net_device *dev,
1678 /* Get the current SSID */ 1678 /* Get the current SSID */
1679 if (priv->new_SSID_size != 0) { 1679 if (priv->new_SSID_size != 0) {
1680 memcpy(extra, priv->new_SSID, priv->new_SSID_size); 1680 memcpy(extra, priv->new_SSID, priv->new_SSID_size);
1681 extra[priv->new_SSID_size] = '\0';
1682 dwrq->length = priv->new_SSID_size; 1681 dwrq->length = priv->new_SSID_size;
1683 } else { 1682 } else {
1684 memcpy(extra, priv->SSID, priv->SSID_size); 1683 memcpy(extra, priv->SSID, priv->SSID_size);
1685 extra[priv->SSID_size] = '\0';
1686 dwrq->length = priv->SSID_size; 1684 dwrq->length = priv->SSID_size;
1687 } 1685 }
1688 1686
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_dma.c b/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
index 76e3aed4b471..978ed099e285 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
@@ -705,11 +705,30 @@ int bcm43xx_dma_init(struct bcm43xx_private *bcm)
705 struct bcm43xx_dmaring *ring; 705 struct bcm43xx_dmaring *ring;
706 int err = -ENOMEM; 706 int err = -ENOMEM;
707 int dma64 = 0; 707 int dma64 = 0;
708 u32 sbtmstatehi; 708 u64 mask = bcm43xx_get_supported_dma_mask(bcm);
709 int nobits;
709 710
710 sbtmstatehi = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATEHIGH); 711 if (mask == DMA_64BIT_MASK) {
711 if (sbtmstatehi & BCM43xx_SBTMSTATEHIGH_DMA64BIT)
712 dma64 = 1; 712 dma64 = 1;
713 nobits = 64;
714 } else if (mask == DMA_32BIT_MASK)
715 nobits = 32;
716 else
717 nobits = 30;
718 err = pci_set_dma_mask(bcm->pci_dev, mask);
719 err |= pci_set_consistent_dma_mask(bcm->pci_dev, mask);
720 if (err) {
721#ifdef CONFIG_BCM43XX_PIO
722 printk(KERN_WARNING PFX "DMA not supported on this device."
723 " Falling back to PIO.\n");
724 bcm->__using_pio = 1;
725 return -ENOSYS;
726#else
727 printk(KERN_ERR PFX "FATAL: DMA not supported and PIO not configured. "
728 "Please recompile the driver with PIO support.\n");
729 return -ENODEV;
730#endif /* CONFIG_BCM43XX_PIO */
731 }
713 732
714 /* setup TX DMA channels. */ 733 /* setup TX DMA channels. */
715 ring = bcm43xx_setup_dmaring(bcm, 0, 1, dma64); 734 ring = bcm43xx_setup_dmaring(bcm, 0, 1, dma64);
@@ -755,8 +774,7 @@ int bcm43xx_dma_init(struct bcm43xx_private *bcm)
755 dma->rx_ring3 = ring; 774 dma->rx_ring3 = ring;
756 } 775 }
757 776
758 dprintk(KERN_INFO PFX "%s DMA initialized\n", 777 dprintk(KERN_INFO PFX "%d-bit DMA initialized\n", nobits);
759 dma64 ? "64-bit" : "32-bit");
760 err = 0; 778 err = 0;
761out: 779out:
762 return err; 780 return err;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_dma.h b/drivers/net/wireless/bcm43xx/bcm43xx_dma.h
index e04bcaddd1d0..ea16078cfe98 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_dma.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_dma.h
@@ -314,6 +314,23 @@ int bcm43xx_dma_tx(struct bcm43xx_private *bcm,
314 struct ieee80211_txb *txb); 314 struct ieee80211_txb *txb);
315void bcm43xx_dma_rx(struct bcm43xx_dmaring *ring); 315void bcm43xx_dma_rx(struct bcm43xx_dmaring *ring);
316 316
317/* Helper function that returns the dma mask for this device. */
318static inline
319u64 bcm43xx_get_supported_dma_mask(struct bcm43xx_private *bcm)
320{
321 int dma64 = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATEHIGH) &
322 BCM43xx_SBTMSTATEHIGH_DMA64BIT;
323 u16 mmio_base = bcm43xx_dmacontroller_base(dma64, 0);
324 u32 mask = BCM43xx_DMA32_TXADDREXT_MASK;
325
326 if (dma64)
327 return DMA_64BIT_MASK;
328 bcm43xx_write32(bcm, mmio_base + BCM43xx_DMA32_TXCTL, mask);
329 if (bcm43xx_read32(bcm, mmio_base + BCM43xx_DMA32_TXCTL) & mask)
330 return DMA_32BIT_MASK;
331 return DMA_30BIT_MASK;
332}
333
317#else /* CONFIG_BCM43XX_DMA */ 334#else /* CONFIG_BCM43XX_DMA */
318 335
319 336
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
index c3f90c8563d9..2ddbec6bf15b 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
@@ -242,7 +242,7 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
242 //TODO 242 //TODO
243 break; 243 break;
244 case BCM43xx_LED_ASSOC: 244 case BCM43xx_LED_ASSOC:
245 if (bcm->softmac->associated) 245 if (bcm->softmac->associnfo.associated)
246 turn_on = 1; 246 turn_on = 1;
247 break; 247 break;
248#ifdef CONFIG_BCM43XX_DEBUG 248#ifdef CONFIG_BCM43XX_DEBUG
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index bad3452ea893..a94c6d8826f8 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -2925,10 +2925,13 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm,
2925 bcm43xx_write16(bcm, 0x043C, 0x000C); 2925 bcm43xx_write16(bcm, 0x043C, 0x000C);
2926 2926
2927 if (active_wlcore) { 2927 if (active_wlcore) {
2928 if (bcm43xx_using_pio(bcm)) 2928 if (bcm43xx_using_pio(bcm)) {
2929 err = bcm43xx_pio_init(bcm); 2929 err = bcm43xx_pio_init(bcm);
2930 else 2930 } else {
2931 err = bcm43xx_dma_init(bcm); 2931 err = bcm43xx_dma_init(bcm);
2932 if (err == -ENOSYS)
2933 err = bcm43xx_pio_init(bcm);
2934 }
2932 if (err) 2935 if (err)
2933 goto err_chip_cleanup; 2936 goto err_chip_cleanup;
2934 } 2937 }
@@ -3164,12 +3167,12 @@ static void bcm43xx_periodic_work_handler(void *d)
3164 u32 savedirqs = 0; 3167 u32 savedirqs = 0;
3165 int badness; 3168 int badness;
3166 3169
3170 mutex_lock(&bcm->mutex);
3167 badness = estimate_periodic_work_badness(bcm->periodic_state); 3171 badness = estimate_periodic_work_badness(bcm->periodic_state);
3168 if (badness > BADNESS_LIMIT) { 3172 if (badness > BADNESS_LIMIT) {
3169 /* Periodic work will take a long time, so we want it to 3173 /* Periodic work will take a long time, so we want it to
3170 * be preemtible. 3174 * be preemtible.
3171 */ 3175 */
3172 mutex_lock(&bcm->mutex);
3173 netif_tx_disable(bcm->net_dev); 3176 netif_tx_disable(bcm->net_dev);
3174 spin_lock_irqsave(&bcm->irq_lock, flags); 3177 spin_lock_irqsave(&bcm->irq_lock, flags);
3175 bcm43xx_mac_suspend(bcm); 3178 bcm43xx_mac_suspend(bcm);
@@ -3182,7 +3185,6 @@ static void bcm43xx_periodic_work_handler(void *d)
3182 /* Periodic work should take short time, so we want low 3185 /* Periodic work should take short time, so we want low
3183 * locking overhead. 3186 * locking overhead.
3184 */ 3187 */
3185 mutex_lock(&bcm->mutex);
3186 spin_lock_irqsave(&bcm->irq_lock, flags); 3188 spin_lock_irqsave(&bcm->irq_lock, flags);
3187 } 3189 }
3188 3190
@@ -3993,8 +3995,6 @@ static int bcm43xx_init_private(struct bcm43xx_private *bcm,
3993 struct net_device *net_dev, 3995 struct net_device *net_dev,
3994 struct pci_dev *pci_dev) 3996 struct pci_dev *pci_dev)
3995{ 3997{
3996 int err;
3997
3998 bcm43xx_set_status(bcm, BCM43xx_STAT_UNINIT); 3998 bcm43xx_set_status(bcm, BCM43xx_STAT_UNINIT);
3999 bcm->ieee = netdev_priv(net_dev); 3999 bcm->ieee = netdev_priv(net_dev);
4000 bcm->softmac = ieee80211_priv(net_dev); 4000 bcm->softmac = ieee80211_priv(net_dev);
@@ -4012,22 +4012,8 @@ static int bcm43xx_init_private(struct bcm43xx_private *bcm,
4012 (void (*)(unsigned long))bcm43xx_interrupt_tasklet, 4012 (void (*)(unsigned long))bcm43xx_interrupt_tasklet,
4013 (unsigned long)bcm); 4013 (unsigned long)bcm);
4014 tasklet_disable_nosync(&bcm->isr_tasklet); 4014 tasklet_disable_nosync(&bcm->isr_tasklet);
4015 if (modparam_pio) { 4015 if (modparam_pio)
4016 bcm->__using_pio = 1; 4016 bcm->__using_pio = 1;
4017 } else {
4018 err = pci_set_dma_mask(pci_dev, DMA_30BIT_MASK);
4019 err |= pci_set_consistent_dma_mask(pci_dev, DMA_30BIT_MASK);
4020 if (err) {
4021#ifdef CONFIG_BCM43XX_PIO
4022 printk(KERN_WARNING PFX "DMA not supported. Falling back to PIO.\n");
4023 bcm->__using_pio = 1;
4024#else
4025 printk(KERN_ERR PFX "FATAL: DMA not supported and PIO not configured. "
4026 "Recompile the driver with PIO support, please.\n");
4027 return -ENODEV;
4028#endif /* CONFIG_BCM43XX_PIO */
4029 }
4030 }
4031 bcm->rts_threshold = BCM43xx_DEFAULT_RTS_THRESHOLD; 4017 bcm->rts_threshold = BCM43xx_DEFAULT_RTS_THRESHOLD;
4032 4018
4033 /* default to sw encryption for now */ 4019 /* default to sw encryption for now */
@@ -4208,7 +4194,11 @@ static int bcm43xx_resume(struct pci_dev *pdev)
4208 dprintk(KERN_INFO PFX "Resuming...\n"); 4194 dprintk(KERN_INFO PFX "Resuming...\n");
4209 4195
4210 pci_set_power_state(pdev, 0); 4196 pci_set_power_state(pdev, 0);
4211 pci_enable_device(pdev); 4197 err = pci_enable_device(pdev);
4198 if (err) {
4199 printk(KERN_ERR PFX "Failure with pci_enable_device!\n");
4200 return err;
4201 }
4212 pci_restore_state(pdev); 4202 pci_restore_state(pdev);
4213 4203
4214 bcm43xx_chipset_attach(bcm); 4204 bcm43xx_chipset_attach(bcm);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
index 9b7b15cf6561..d27016f8c736 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
@@ -847,7 +847,7 @@ static struct iw_statistics *bcm43xx_get_wireless_stats(struct net_device *net_d
847 unsigned long flags; 847 unsigned long flags;
848 848
849 wstats = &bcm->stats.wstats; 849 wstats = &bcm->stats.wstats;
850 if (!mac->associated) { 850 if (!mac->associnfo.associated) {
851 wstats->miss.beacon = 0; 851 wstats->miss.beacon = 0;
852// bcm->ieee->ieee_stats.tx_retry_limit_exceeded = 0; // FIXME: should this be cleared here? 852// bcm->ieee->ieee_stats.tx_retry_limit_exceeded = 0; // FIXME: should this be cleared here?
853 wstats->discard.retries = 0; 853 wstats->discard.retries = 0;
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index b779c7dcc1a8..336cabac13b3 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -2457,6 +2457,7 @@ void free_orinocodev(struct net_device *dev)
2457/* Wireless extensions */ 2457/* Wireless extensions */
2458/********************************************************************/ 2458/********************************************************************/
2459 2459
2460/* Return : < 0 -> error code ; >= 0 -> length */
2460static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active, 2461static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
2461 char buf[IW_ESSID_MAX_SIZE+1]) 2462 char buf[IW_ESSID_MAX_SIZE+1])
2462{ 2463{
@@ -2501,9 +2502,9 @@ static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
2501 len = le16_to_cpu(essidbuf.len); 2502 len = le16_to_cpu(essidbuf.len);
2502 BUG_ON(len > IW_ESSID_MAX_SIZE); 2503 BUG_ON(len > IW_ESSID_MAX_SIZE);
2503 2504
2504 memset(buf, 0, IW_ESSID_MAX_SIZE+1); 2505 memset(buf, 0, IW_ESSID_MAX_SIZE);
2505 memcpy(buf, p, len); 2506 memcpy(buf, p, len);
2506 buf[len] = '\0'; 2507 err = len;
2507 2508
2508 fail_unlock: 2509 fail_unlock:
2509 orinoco_unlock(priv, &flags); 2510 orinoco_unlock(priv, &flags);
@@ -3027,17 +3028,18 @@ static int orinoco_ioctl_getessid(struct net_device *dev,
3027 3028
3028 if (netif_running(dev)) { 3029 if (netif_running(dev)) {
3029 err = orinoco_hw_get_essid(priv, &active, essidbuf); 3030 err = orinoco_hw_get_essid(priv, &active, essidbuf);
3030 if (err) 3031 if (err < 0)
3031 return err; 3032 return err;
3033 erq->length = err;
3032 } else { 3034 } else {
3033 if (orinoco_lock(priv, &flags) != 0) 3035 if (orinoco_lock(priv, &flags) != 0)
3034 return -EBUSY; 3036 return -EBUSY;
3035 memcpy(essidbuf, priv->desired_essid, IW_ESSID_MAX_SIZE + 1); 3037 memcpy(essidbuf, priv->desired_essid, IW_ESSID_MAX_SIZE);
3038 erq->length = strlen(priv->desired_essid);
3036 orinoco_unlock(priv, &flags); 3039 orinoco_unlock(priv, &flags);
3037 } 3040 }
3038 3041
3039 erq->flags = 1; 3042 erq->flags = 1;
3040 erq->length = strlen(essidbuf);
3041 3043
3042 return 0; 3044 return 0;
3043} 3045}
@@ -3075,10 +3077,10 @@ static int orinoco_ioctl_getnick(struct net_device *dev,
3075 if (orinoco_lock(priv, &flags) != 0) 3077 if (orinoco_lock(priv, &flags) != 0)
3076 return -EBUSY; 3078 return -EBUSY;
3077 3079
3078 memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE+1); 3080 memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE);
3079 orinoco_unlock(priv, &flags); 3081 orinoco_unlock(priv, &flags);
3080 3082
3081 nrq->length = strlen(nickbuf); 3083 nrq->length = strlen(priv->nick);
3082 3084
3083 return 0; 3085 return 0;
3084} 3086}
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 0b381d77015c..7fbfc9e41d07 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -1198,7 +1198,6 @@ static int ray_get_essid(struct net_device *dev,
1198 1198
1199 /* Get the essid that was set */ 1199 /* Get the essid that was set */
1200 memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE); 1200 memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE);
1201 extra[IW_ESSID_MAX_SIZE] = '\0';
1202 1201
1203 /* Push it out ! */ 1202 /* Push it out ! */
1204 dwrq->length = strlen(extra); 1203 dwrq->length = strlen(extra);
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index 30057a335a7b..36b29ff05814 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -193,10 +193,8 @@ static void zd1201_usbrx(struct urb *urb)
193 struct sk_buff *skb; 193 struct sk_buff *skb;
194 unsigned char type; 194 unsigned char type;
195 195
196 if (!zd) { 196 if (!zd)
197 free = 1; 197 return;
198 goto exit;
199 }
200 198
201 switch(urb->status) { 199 switch(urb->status) {
202 case -EILSEQ: 200 case -EILSEQ:
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 2d12837052b0..a7d29bddb298 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -1099,7 +1099,7 @@ static void link_led_handler(void *p)
1099 int r; 1099 int r;
1100 1100
1101 spin_lock_irq(&mac->lock); 1101 spin_lock_irq(&mac->lock);
1102 is_associated = sm->associated != 0; 1102 is_associated = sm->associnfo.associated != 0;
1103 spin_unlock_irq(&mac->lock); 1103 spin_unlock_irq(&mac->lock);
1104 1104
1105 r = zd_chip_control_leds(chip, 1105 r = zd_chip_control_leds(chip,
diff --git a/include/net/ieee80211softmac.h b/include/net/ieee80211softmac.h
index 425b3a57ac74..617b672b1132 100644
--- a/include/net/ieee80211softmac.h
+++ b/include/net/ieee80211softmac.h
@@ -63,13 +63,11 @@ struct ieee80211softmac_wpa {
63 63
64/* 64/*
65 * Information about association 65 * Information about association
66 *
67 * Do we need a lock for this?
68 * We only ever use this structure inlined
69 * into our global struct. I've used its lock,
70 * but maybe we need a local one here?
71 */ 66 */
72struct ieee80211softmac_assoc_info { 67struct ieee80211softmac_assoc_info {
68
69 struct mutex mutex;
70
73 /* 71 /*
74 * This is the requested ESSID. It is written 72 * This is the requested ESSID. It is written
75 * only by the WX handlers. 73 * only by the WX handlers.
@@ -99,12 +97,13 @@ struct ieee80211softmac_assoc_info {
99 * 97 *
100 * bssfixed is used for SIOCSIWAP. 98 * bssfixed is used for SIOCSIWAP.
101 */ 99 */
102 u8 static_essid:1, 100 u8 static_essid;
103 short_preamble_available:1, 101 u8 short_preamble_available;
104 associating:1, 102 u8 associating;
105 assoc_wait:1, 103 u8 associated;
106 bssvalid:1, 104 u8 assoc_wait;
107 bssfixed:1; 105 u8 bssvalid;
106 u8 bssfixed;
108 107
109 /* Scan retries remaining */ 108 /* Scan retries remaining */
110 int scan_retry; 109 int scan_retry;
@@ -229,12 +228,10 @@ struct ieee80211softmac_device {
229 /* private stuff follows */ 228 /* private stuff follows */
230 /* this lock protects this structure */ 229 /* this lock protects this structure */
231 spinlock_t lock; 230 spinlock_t lock;
232 231
233 /* couple of flags */ 232 u8 running; /* SoftMAC started? */
234 u8 scanning:1, /* protects scanning from being done multiple times at once */ 233 u8 scanning;
235 associated:1, 234
236 running:1;
237
238 struct ieee80211softmac_scaninfo *scaninfo; 235 struct ieee80211softmac_scaninfo *scaninfo;
239 struct ieee80211softmac_assoc_info associnfo; 236 struct ieee80211softmac_assoc_info associnfo;
240 struct ieee80211softmac_bss_info bssinfo; 237 struct ieee80211softmac_bss_info bssinfo;
@@ -250,7 +247,7 @@ struct ieee80211softmac_device {
250 247
251 /* we need to keep a list of network structs we copied */ 248 /* we need to keep a list of network structs we copied */
252 struct list_head network_list; 249 struct list_head network_list;
253 250
254 /* This must be the last item so that it points to the data 251 /* This must be the last item so that it points to the data
255 * allocated beyond this structure by alloc_ieee80211 */ 252 * allocated beyond this structure by alloc_ieee80211 */
256 u8 priv[0]; 253 u8 priv[0];
@@ -295,7 +292,7 @@ static inline u8 ieee80211softmac_suggest_txrate(struct ieee80211softmac_device
295{ 292{
296 struct ieee80211softmac_txrates *txrates = &mac->txrates; 293 struct ieee80211softmac_txrates *txrates = &mac->txrates;
297 294
298 if (!mac->associated) 295 if (!mac->associnfo.associated)
299 return txrates->mgt_mcast_rate; 296 return txrates->mgt_mcast_rate;
300 297
301 /* We are associated, sending unicast frame */ 298 /* We are associated, sending unicast frame */
diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c
index 589f6d2c548a..cf51c87a971d 100644
--- a/net/ieee80211/softmac/ieee80211softmac_assoc.c
+++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
@@ -48,7 +48,7 @@ ieee80211softmac_assoc(struct ieee80211softmac_device *mac, struct ieee80211soft
48 dprintk(KERN_INFO PFX "sent association request!\n"); 48 dprintk(KERN_INFO PFX "sent association request!\n");
49 49
50 spin_lock_irqsave(&mac->lock, flags); 50 spin_lock_irqsave(&mac->lock, flags);
51 mac->associated = 0; /* just to make sure */ 51 mac->associnfo.associated = 0; /* just to make sure */
52 52
53 /* Set a timer for timeout */ 53 /* Set a timer for timeout */
54 /* FIXME: make timeout configurable */ 54 /* FIXME: make timeout configurable */
@@ -62,24 +62,22 @@ ieee80211softmac_assoc_timeout(void *d)
62{ 62{
63 struct ieee80211softmac_device *mac = (struct ieee80211softmac_device *)d; 63 struct ieee80211softmac_device *mac = (struct ieee80211softmac_device *)d;
64 struct ieee80211softmac_network *n; 64 struct ieee80211softmac_network *n;
65 unsigned long flags;
66 65
67 spin_lock_irqsave(&mac->lock, flags); 66 mutex_lock(&mac->associnfo.mutex);
68 /* we might race against ieee80211softmac_handle_assoc_response, 67 /* we might race against ieee80211softmac_handle_assoc_response,
69 * so make sure only one of us does something */ 68 * so make sure only one of us does something */
70 if (!mac->associnfo.associating) { 69 if (!mac->associnfo.associating)
71 spin_unlock_irqrestore(&mac->lock, flags); 70 goto out;
72 return;
73 }
74 mac->associnfo.associating = 0; 71 mac->associnfo.associating = 0;
75 mac->associnfo.bssvalid = 0; 72 mac->associnfo.bssvalid = 0;
76 mac->associated = 0; 73 mac->associnfo.associated = 0;
77 74
78 n = ieee80211softmac_get_network_by_bssid_locked(mac, mac->associnfo.bssid); 75 n = ieee80211softmac_get_network_by_bssid_locked(mac, mac->associnfo.bssid);
79 spin_unlock_irqrestore(&mac->lock, flags);
80 76
81 dprintk(KERN_INFO PFX "assoc request timed out!\n"); 77 dprintk(KERN_INFO PFX "assoc request timed out!\n");
82 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT, n); 78 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT, n);
79out:
80 mutex_unlock(&mac->associnfo.mutex);
83} 81}
84 82
85void 83void
@@ -93,7 +91,7 @@ ieee80211softmac_disassoc(struct ieee80211softmac_device *mac)
93 91
94 netif_carrier_off(mac->dev); 92 netif_carrier_off(mac->dev);
95 93
96 mac->associated = 0; 94 mac->associnfo.associated = 0;
97 mac->associnfo.bssvalid = 0; 95 mac->associnfo.bssvalid = 0;
98 mac->associnfo.associating = 0; 96 mac->associnfo.associating = 0;
99 ieee80211softmac_init_bss(mac); 97 ieee80211softmac_init_bss(mac);
@@ -107,7 +105,7 @@ ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reas
107{ 105{
108 struct ieee80211softmac_network *found; 106 struct ieee80211softmac_network *found;
109 107
110 if (mac->associnfo.bssvalid && mac->associated) { 108 if (mac->associnfo.bssvalid && mac->associnfo.associated) {
111 found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid); 109 found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid);
112 if (found) 110 if (found)
113 ieee80211softmac_send_mgt_frame(mac, found, IEEE80211_STYPE_DISASSOC, reason); 111 ieee80211softmac_send_mgt_frame(mac, found, IEEE80211_STYPE_DISASSOC, reason);
@@ -196,17 +194,18 @@ ieee80211softmac_assoc_work(void *d)
196 int bssvalid; 194 int bssvalid;
197 unsigned long flags; 195 unsigned long flags;
198 196
197 mutex_lock(&mac->associnfo.mutex);
198
199 if (!mac->associnfo.associating)
200 goto out;
201
199 /* ieee80211_disassoc might clear this */ 202 /* ieee80211_disassoc might clear this */
200 bssvalid = mac->associnfo.bssvalid; 203 bssvalid = mac->associnfo.bssvalid;
201 204
202 /* meh */ 205 /* meh */
203 if (mac->associated) 206 if (mac->associnfo.associated)
204 ieee80211softmac_send_disassoc_req(mac, WLAN_REASON_DISASSOC_STA_HAS_LEFT); 207 ieee80211softmac_send_disassoc_req(mac, WLAN_REASON_DISASSOC_STA_HAS_LEFT);
205 208
206 spin_lock_irqsave(&mac->lock, flags);
207 mac->associnfo.associating = 1;
208 spin_unlock_irqrestore(&mac->lock, flags);
209
210 /* try to find the requested network in our list, if we found one already */ 209 /* try to find the requested network in our list, if we found one already */
211 if (bssvalid || mac->associnfo.bssfixed) 210 if (bssvalid || mac->associnfo.bssfixed)
212 found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid); 211 found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid);
@@ -260,10 +259,8 @@ ieee80211softmac_assoc_work(void *d)
260 259
261 if (!found) { 260 if (!found) {
262 if (mac->associnfo.scan_retry > 0) { 261 if (mac->associnfo.scan_retry > 0) {
263 spin_lock_irqsave(&mac->lock, flags);
264 mac->associnfo.scan_retry--; 262 mac->associnfo.scan_retry--;
265 spin_unlock_irqrestore(&mac->lock, flags); 263
266
267 /* We know of no such network. Let's scan. 264 /* We know of no such network. Let's scan.
268 * NB: this also happens if we had no memory to copy the network info... 265 * NB: this also happens if we had no memory to copy the network info...
269 * Maybe we can hope to have more memory after scanning finishes ;) 266 * Maybe we can hope to have more memory after scanning finishes ;)
@@ -272,19 +269,17 @@ ieee80211softmac_assoc_work(void *d)
272 ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify_scan, NULL); 269 ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify_scan, NULL);
273 if (ieee80211softmac_start_scan(mac)) 270 if (ieee80211softmac_start_scan(mac))
274 dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n"); 271 dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n");
275 return; 272 goto out;
276 } else { 273 } else {
277 spin_lock_irqsave(&mac->lock, flags);
278 mac->associnfo.associating = 0; 274 mac->associnfo.associating = 0;
279 mac->associated = 0; 275 mac->associnfo.associated = 0;
280 spin_unlock_irqrestore(&mac->lock, flags);
281 276
282 dprintk(KERN_INFO PFX "Unable to find matching network after scan!\n"); 277 dprintk(KERN_INFO PFX "Unable to find matching network after scan!\n");
283 /* reset the retry counter for the next user request since we 278 /* reset the retry counter for the next user request since we
284 * break out and don't reschedule ourselves after this point. */ 279 * break out and don't reschedule ourselves after this point. */
285 mac->associnfo.scan_retry = IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT; 280 mac->associnfo.scan_retry = IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT;
286 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND, NULL); 281 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND, NULL);
287 return; 282 goto out;
288 } 283 }
289 } 284 }
290 285
@@ -297,7 +292,7 @@ ieee80211softmac_assoc_work(void *d)
297 /* copy the ESSID for displaying it */ 292 /* copy the ESSID for displaying it */
298 mac->associnfo.associate_essid.len = found->essid.len; 293 mac->associnfo.associate_essid.len = found->essid.len;
299 memcpy(mac->associnfo.associate_essid.data, found->essid.data, IW_ESSID_MAX_SIZE + 1); 294 memcpy(mac->associnfo.associate_essid.data, found->essid.data, IW_ESSID_MAX_SIZE + 1);
300 295
301 /* we found a network! authenticate (if necessary) and associate to it. */ 296 /* we found a network! authenticate (if necessary) and associate to it. */
302 if (found->authenticating) { 297 if (found->authenticating) {
303 dprintk(KERN_INFO PFX "Already requested authentication, waiting...\n"); 298 dprintk(KERN_INFO PFX "Already requested authentication, waiting...\n");
@@ -305,7 +300,7 @@ ieee80211softmac_assoc_work(void *d)
305 mac->associnfo.assoc_wait = 1; 300 mac->associnfo.assoc_wait = 1;
306 ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify_auth, NULL, GFP_KERNEL); 301 ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify_auth, NULL, GFP_KERNEL);
307 } 302 }
308 return; 303 goto out;
309 } 304 }
310 if (!found->authenticated && !found->authenticating) { 305 if (!found->authenticated && !found->authenticating) {
311 /* This relies on the fact that _auth_req only queues the work, 306 /* This relies on the fact that _auth_req only queues the work,
@@ -321,11 +316,14 @@ ieee80211softmac_assoc_work(void *d)
321 mac->associnfo.assoc_wait = 0; 316 mac->associnfo.assoc_wait = 0;
322 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found); 317 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found);
323 } 318 }
324 return; 319 goto out;
325 } 320 }
326 /* finally! now we can start associating */ 321 /* finally! now we can start associating */
327 mac->associnfo.assoc_wait = 0; 322 mac->associnfo.assoc_wait = 0;
328 ieee80211softmac_assoc(mac, found); 323 ieee80211softmac_assoc(mac, found);
324
325out:
326 mutex_unlock(&mac->associnfo.mutex);
329} 327}
330 328
331/* call this to do whatever is necessary when we're associated */ 329/* call this to do whatever is necessary when we're associated */
@@ -341,7 +339,7 @@ ieee80211softmac_associated(struct ieee80211softmac_device *mac,
341 mac->bssinfo.supported_rates = net->supported_rates; 339 mac->bssinfo.supported_rates = net->supported_rates;
342 ieee80211softmac_recalc_txrates(mac); 340 ieee80211softmac_recalc_txrates(mac);
343 341
344 mac->associated = 1; 342 mac->associnfo.associated = 1;
345 343
346 mac->associnfo.short_preamble_available = 344 mac->associnfo.short_preamble_available =
347 (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) != 0; 345 (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) != 0;
@@ -421,7 +419,7 @@ ieee80211softmac_handle_assoc_response(struct net_device * dev,
421 dprintk(KERN_INFO PFX "associating failed (reason: 0x%x)!\n", status); 419 dprintk(KERN_INFO PFX "associating failed (reason: 0x%x)!\n", status);
422 mac->associnfo.associating = 0; 420 mac->associnfo.associating = 0;
423 mac->associnfo.bssvalid = 0; 421 mac->associnfo.bssvalid = 0;
424 mac->associated = 0; 422 mac->associnfo.associated = 0;
425 ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, network); 423 ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, network);
426 } 424 }
427 425
diff --git a/net/ieee80211/softmac/ieee80211softmac_io.c b/net/ieee80211/softmac/ieee80211softmac_io.c
index 82bfddbf33a2..b96931001b43 100644
--- a/net/ieee80211/softmac/ieee80211softmac_io.c
+++ b/net/ieee80211/softmac/ieee80211softmac_io.c
@@ -304,7 +304,7 @@ ieee80211softmac_auth(struct ieee80211_auth **pkt,
304 2 + /* Auth Transaction Seq */ 304 2 + /* Auth Transaction Seq */
305 2 + /* Status Code */ 305 2 + /* Status Code */
306 /* Challenge Text IE */ 306 /* Challenge Text IE */
307 is_shared_response ? 0 : 1 + 1 + net->challenge_len 307 (is_shared_response ? 1 + 1 + net->challenge_len : 0)
308 ); 308 );
309 if (unlikely((*pkt) == NULL)) 309 if (unlikely((*pkt) == NULL))
310 return 0; 310 return 0;
@@ -475,8 +475,13 @@ int ieee80211softmac_handle_beacon(struct net_device *dev,
475{ 475{
476 struct ieee80211softmac_device *mac = ieee80211_priv(dev); 476 struct ieee80211softmac_device *mac = ieee80211_priv(dev);
477 477
478 if (mac->associated && memcmp(network->bssid, mac->associnfo.bssid, ETH_ALEN) == 0) 478 /* This might race, but we don't really care and it's not worth
479 ieee80211softmac_process_erp(mac, network->erp_value); 479 * adding heavyweight locking in this fastpath.
480 */
481 if (mac->associnfo.associated) {
482 if (memcmp(network->bssid, mac->associnfo.bssid, ETH_ALEN) == 0)
483 ieee80211softmac_process_erp(mac, network->erp_value);
484 }
480 485
481 return 0; 486 return 0;
482} 487}
diff --git a/net/ieee80211/softmac/ieee80211softmac_module.c b/net/ieee80211/softmac/ieee80211softmac_module.c
index addea1cf73ae..33aff4f4a471 100644
--- a/net/ieee80211/softmac/ieee80211softmac_module.c
+++ b/net/ieee80211/softmac/ieee80211softmac_module.c
@@ -57,6 +57,7 @@ struct net_device *alloc_ieee80211softmac(int sizeof_priv)
57 INIT_LIST_HEAD(&softmac->network_list); 57 INIT_LIST_HEAD(&softmac->network_list);
58 INIT_LIST_HEAD(&softmac->events); 58 INIT_LIST_HEAD(&softmac->events);
59 59
60 mutex_init(&softmac->associnfo.mutex);
60 INIT_WORK(&softmac->associnfo.work, ieee80211softmac_assoc_work, softmac); 61 INIT_WORK(&softmac->associnfo.work, ieee80211softmac_assoc_work, softmac);
61 INIT_WORK(&softmac->associnfo.timeout, ieee80211softmac_assoc_timeout, softmac); 62 INIT_WORK(&softmac->associnfo.timeout, ieee80211softmac_assoc_timeout, softmac);
62 softmac->start_scan = ieee80211softmac_start_scan_implementation; 63 softmac->start_scan = ieee80211softmac_start_scan_implementation;
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c
index 2aa779d18f38..23068a830f7d 100644
--- a/net/ieee80211/softmac/ieee80211softmac_wx.c
+++ b/net/ieee80211/softmac/ieee80211softmac_wx.c
@@ -73,13 +73,14 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
73 struct ieee80211softmac_network *n; 73 struct ieee80211softmac_network *n;
74 struct ieee80211softmac_auth_queue_item *authptr; 74 struct ieee80211softmac_auth_queue_item *authptr;
75 int length = 0; 75 int length = 0;
76 unsigned long flags; 76
77 mutex_lock(&sm->associnfo.mutex);
77 78
78 /* Check if we're already associating to this or another network 79 /* Check if we're already associating to this or another network
79 * If it's another network, cancel and start over with our new network 80 * If it's another network, cancel and start over with our new network
80 * If it's our network, ignore the change, we're already doing it! 81 * If it's our network, ignore the change, we're already doing it!
81 */ 82 */
82 if((sm->associnfo.associating || sm->associated) && 83 if((sm->associnfo.associating || sm->associnfo.associated) &&
83 (data->essid.flags && data->essid.length)) { 84 (data->essid.flags && data->essid.length)) {
84 /* Get the associating network */ 85 /* Get the associating network */
85 n = ieee80211softmac_get_network_by_bssid(sm, sm->associnfo.bssid); 86 n = ieee80211softmac_get_network_by_bssid(sm, sm->associnfo.bssid);
@@ -87,10 +88,9 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
87 !memcmp(n->essid.data, extra, n->essid.len)) { 88 !memcmp(n->essid.data, extra, n->essid.len)) {
88 dprintk(KERN_INFO PFX "Already associating or associated to "MAC_FMT"\n", 89 dprintk(KERN_INFO PFX "Already associating or associated to "MAC_FMT"\n",
89 MAC_ARG(sm->associnfo.bssid)); 90 MAC_ARG(sm->associnfo.bssid));
90 return 0; 91 goto out;
91 } else { 92 } else {
92 dprintk(KERN_INFO PFX "Canceling existing associate request!\n"); 93 dprintk(KERN_INFO PFX "Canceling existing associate request!\n");
93 spin_lock_irqsave(&sm->lock,flags);
94 /* Cancel assoc work */ 94 /* Cancel assoc work */
95 cancel_delayed_work(&sm->associnfo.work); 95 cancel_delayed_work(&sm->associnfo.work);
96 /* We don't have to do this, but it's a little cleaner */ 96 /* We don't have to do this, but it's a little cleaner */
@@ -98,14 +98,13 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
98 cancel_delayed_work(&authptr->work); 98 cancel_delayed_work(&authptr->work);
99 sm->associnfo.bssvalid = 0; 99 sm->associnfo.bssvalid = 0;
100 sm->associnfo.bssfixed = 0; 100 sm->associnfo.bssfixed = 0;
101 spin_unlock_irqrestore(&sm->lock,flags);
102 flush_scheduled_work(); 101 flush_scheduled_work();
102 sm->associnfo.associating = 0;
103 sm->associnfo.associated = 0;
103 } 104 }
104 } 105 }
105 106
106 107
107 spin_lock_irqsave(&sm->lock, flags);
108
109 sm->associnfo.static_essid = 0; 108 sm->associnfo.static_essid = 0;
110 sm->associnfo.assoc_wait = 0; 109 sm->associnfo.assoc_wait = 0;
111 110
@@ -121,10 +120,12 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
121 * If applicable, we have already copied the data in */ 120 * If applicable, we have already copied the data in */
122 sm->associnfo.req_essid.len = length; 121 sm->associnfo.req_essid.len = length;
123 122
123 sm->associnfo.associating = 1;
124 /* queue lower level code to do work (if necessary) */ 124 /* queue lower level code to do work (if necessary) */
125 schedule_work(&sm->associnfo.work); 125 schedule_work(&sm->associnfo.work);
126out:
127 mutex_unlock(&sm->associnfo.mutex);
126 128
127 spin_unlock_irqrestore(&sm->lock, flags);
128 return 0; 129 return 0;
129} 130}
130EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_essid); 131EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_essid);
@@ -136,10 +137,8 @@ ieee80211softmac_wx_get_essid(struct net_device *net_dev,
136 char *extra) 137 char *extra)
137{ 138{
138 struct ieee80211softmac_device *sm = ieee80211_priv(net_dev); 139 struct ieee80211softmac_device *sm = ieee80211_priv(net_dev);
139 unsigned long flags;
140 140
141 /* avoid getting inconsistent information */ 141 mutex_lock(&sm->associnfo.mutex);
142 spin_lock_irqsave(&sm->lock, flags);
143 /* If all fails, return ANY (empty) */ 142 /* If all fails, return ANY (empty) */
144 data->essid.length = 0; 143 data->essid.length = 0;
145 data->essid.flags = 0; /* active */ 144 data->essid.flags = 0; /* active */
@@ -152,12 +151,13 @@ ieee80211softmac_wx_get_essid(struct net_device *net_dev,
152 } 151 }
153 152
154 /* If we're associating/associated, return that */ 153 /* If we're associating/associated, return that */
155 if (sm->associated || sm->associnfo.associating) { 154 if (sm->associnfo.associated || sm->associnfo.associating) {
156 data->essid.length = sm->associnfo.associate_essid.len; 155 data->essid.length = sm->associnfo.associate_essid.len;
157 data->essid.flags = 1; /* active */ 156 data->essid.flags = 1; /* active */
158 memcpy(extra, sm->associnfo.associate_essid.data, sm->associnfo.associate_essid.len); 157 memcpy(extra, sm->associnfo.associate_essid.data, sm->associnfo.associate_essid.len);
159 } 158 }
160 spin_unlock_irqrestore(&sm->lock, flags); 159 mutex_unlock(&sm->associnfo.mutex);
160
161 return 0; 161 return 0;
162} 162}
163EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_essid); 163EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_essid);
@@ -322,15 +322,15 @@ ieee80211softmac_wx_get_wap(struct net_device *net_dev,
322{ 322{
323 struct ieee80211softmac_device *mac = ieee80211_priv(net_dev); 323 struct ieee80211softmac_device *mac = ieee80211_priv(net_dev);
324 int err = 0; 324 int err = 0;
325 unsigned long flags;
326 325
327 spin_lock_irqsave(&mac->lock, flags); 326 mutex_lock(&mac->associnfo.mutex);
328 if (mac->associnfo.bssvalid) 327 if (mac->associnfo.bssvalid)
329 memcpy(data->ap_addr.sa_data, mac->associnfo.bssid, ETH_ALEN); 328 memcpy(data->ap_addr.sa_data, mac->associnfo.bssid, ETH_ALEN);
330 else 329 else
331 memset(data->ap_addr.sa_data, 0xff, ETH_ALEN); 330 memset(data->ap_addr.sa_data, 0xff, ETH_ALEN);
332 data->ap_addr.sa_family = ARPHRD_ETHER; 331 data->ap_addr.sa_family = ARPHRD_ETHER;
333 spin_unlock_irqrestore(&mac->lock, flags); 332 mutex_unlock(&mac->associnfo.mutex);
333
334 return err; 334 return err;
335} 335}
336EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_wap); 336EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_wap);
@@ -342,28 +342,27 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev,
342 char *extra) 342 char *extra)
343{ 343{
344 struct ieee80211softmac_device *mac = ieee80211_priv(net_dev); 344 struct ieee80211softmac_device *mac = ieee80211_priv(net_dev);
345 unsigned long flags;
346 345
347 /* sanity check */ 346 /* sanity check */
348 if (data->ap_addr.sa_family != ARPHRD_ETHER) { 347 if (data->ap_addr.sa_family != ARPHRD_ETHER) {
349 return -EINVAL; 348 return -EINVAL;
350 } 349 }
351 350
352 spin_lock_irqsave(&mac->lock, flags); 351 mutex_lock(&mac->associnfo.mutex);
353 if (is_broadcast_ether_addr(data->ap_addr.sa_data)) { 352 if (is_broadcast_ether_addr(data->ap_addr.sa_data)) {
354 /* the bssid we have is not to be fixed any longer, 353 /* the bssid we have is not to be fixed any longer,
355 * and we should reassociate to the best AP. */ 354 * and we should reassociate to the best AP. */
356 mac->associnfo.bssfixed = 0; 355 mac->associnfo.bssfixed = 0;
357 /* force reassociation */ 356 /* force reassociation */
358 mac->associnfo.bssvalid = 0; 357 mac->associnfo.bssvalid = 0;
359 if (mac->associated) 358 if (mac->associnfo.associated)
360 schedule_work(&mac->associnfo.work); 359 schedule_work(&mac->associnfo.work);
361 } else if (is_zero_ether_addr(data->ap_addr.sa_data)) { 360 } else if (is_zero_ether_addr(data->ap_addr.sa_data)) {
362 /* the bssid we have is no longer fixed */ 361 /* the bssid we have is no longer fixed */
363 mac->associnfo.bssfixed = 0; 362 mac->associnfo.bssfixed = 0;
364 } else { 363 } else {
365 if (!memcmp(mac->associnfo.bssid, data->ap_addr.sa_data, ETH_ALEN)) { 364 if (!memcmp(mac->associnfo.bssid, data->ap_addr.sa_data, ETH_ALEN)) {
366 if (mac->associnfo.associating || mac->associated) { 365 if (mac->associnfo.associating || mac->associnfo.associated) {
367 /* bssid unchanged and associated or associating - just return */ 366 /* bssid unchanged and associated or associating - just return */
368 goto out; 367 goto out;
369 } 368 }
@@ -378,7 +377,8 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev,
378 } 377 }
379 378
380 out: 379 out:
381 spin_unlock_irqrestore(&mac->lock, flags); 380 mutex_unlock(&mac->associnfo.mutex);
381
382 return 0; 382 return 0;
383} 383}
384EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_wap); 384EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_wap);
@@ -394,7 +394,8 @@ ieee80211softmac_wx_set_genie(struct net_device *dev,
394 int err = 0; 394 int err = 0;
395 char *buf; 395 char *buf;
396 int i; 396 int i;
397 397
398 mutex_lock(&mac->associnfo.mutex);
398 spin_lock_irqsave(&mac->lock, flags); 399 spin_lock_irqsave(&mac->lock, flags);
399 /* bleh. shouldn't be locked for that kmalloc... */ 400 /* bleh. shouldn't be locked for that kmalloc... */
400 401
@@ -432,6 +433,8 @@ ieee80211softmac_wx_set_genie(struct net_device *dev,
432 433
433 out: 434 out:
434 spin_unlock_irqrestore(&mac->lock, flags); 435 spin_unlock_irqrestore(&mac->lock, flags);
436 mutex_unlock(&mac->associnfo.mutex);
437
435 return err; 438 return err;
436} 439}
437EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_genie); 440EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_genie);
@@ -446,7 +449,8 @@ ieee80211softmac_wx_get_genie(struct net_device *dev,
446 unsigned long flags; 449 unsigned long flags;
447 int err = 0; 450 int err = 0;
448 int space = wrqu->data.length; 451 int space = wrqu->data.length;
449 452
453 mutex_lock(&mac->associnfo.mutex);
450 spin_lock_irqsave(&mac->lock, flags); 454 spin_lock_irqsave(&mac->lock, flags);
451 455
452 wrqu->data.length = 0; 456 wrqu->data.length = 0;
@@ -459,6 +463,8 @@ ieee80211softmac_wx_get_genie(struct net_device *dev,
459 err = -E2BIG; 463 err = -E2BIG;
460 } 464 }
461 spin_unlock_irqrestore(&mac->lock, flags); 465 spin_unlock_irqrestore(&mac->lock, flags);
466 mutex_lock(&mac->associnfo.mutex);
467
462 return err; 468 return err;
463} 469}
464EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_genie); 470EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_genie);
@@ -473,10 +479,13 @@ ieee80211softmac_wx_set_mlme(struct net_device *dev,
473 struct iw_mlme *mlme = (struct iw_mlme *)extra; 479 struct iw_mlme *mlme = (struct iw_mlme *)extra;
474 u16 reason = cpu_to_le16(mlme->reason_code); 480 u16 reason = cpu_to_le16(mlme->reason_code);
475 struct ieee80211softmac_network *net; 481 struct ieee80211softmac_network *net;
482 int err = -EINVAL;
483
484 mutex_lock(&mac->associnfo.mutex);
476 485
477 if (memcmp(mac->associnfo.bssid, mlme->addr.sa_data, ETH_ALEN)) { 486 if (memcmp(mac->associnfo.bssid, mlme->addr.sa_data, ETH_ALEN)) {
478 printk(KERN_DEBUG PFX "wx_set_mlme: requested operation on net we don't use\n"); 487 printk(KERN_DEBUG PFX "wx_set_mlme: requested operation on net we don't use\n");
479 return -EINVAL; 488 goto out;
480 } 489 }
481 490
482 switch (mlme->cmd) { 491 switch (mlme->cmd) {
@@ -484,14 +493,22 @@ ieee80211softmac_wx_set_mlme(struct net_device *dev,
484 net = ieee80211softmac_get_network_by_bssid_locked(mac, mlme->addr.sa_data); 493 net = ieee80211softmac_get_network_by_bssid_locked(mac, mlme->addr.sa_data);
485 if (!net) { 494 if (!net) {
486 printk(KERN_DEBUG PFX "wx_set_mlme: we should know the net here...\n"); 495 printk(KERN_DEBUG PFX "wx_set_mlme: we should know the net here...\n");
487 return -EINVAL; 496 goto out;
488 } 497 }
489 return ieee80211softmac_deauth_req(mac, net, reason); 498 return ieee80211softmac_deauth_req(mac, net, reason);
490 case IW_MLME_DISASSOC: 499 case IW_MLME_DISASSOC:
491 ieee80211softmac_send_disassoc_req(mac, reason); 500 ieee80211softmac_send_disassoc_req(mac, reason);
492 return 0; 501 mac->associnfo.associated = 0;
502 mac->associnfo.associating = 0;
503 err = 0;
504 goto out;
493 default: 505 default:
494 return -EOPNOTSUPP; 506 err = -EOPNOTSUPP;
495 } 507 }
508
509out:
510 mutex_unlock(&mac->associnfo.mutex);
511
512 return err;
496} 513}
497EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_mlme); 514EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_mlme);