aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2007-06-29 09:33:41 -0400
committerJohn W. Linville <linville@tuxdriver.com>2007-07-10 14:11:29 -0400
commit1138c37b66c16a5c7b49389ae566a4d73d60c2aa (patch)
tree5434975d31386b85220ab0b6767e44f55b41f01a /drivers/net
parent1c2b7db8c8c4212761fcb5190a4122afd5e02d58 (diff)
[PATCH] airo: fix a race causing initialization failures
Matteo Croce reported Aironet initialization failures. They were caused by a race in airo. airo finds a free interface name, then initializes the card and finally registers the interface. Another device may get the same name in the meantime. The reason airo gets its name early is to use it in informative printks and to name the resources it requests. The printks will be just fine without the interface name and the resources can use the driver's name - that's what other network drivers do anyway. One of the talkative functions is setup_card(). It is called once before registration and can be called later again. Let's have an empty dev->name during the first call, so it doesn't print the ugly "airo(eth%d)" message. Signed-off-by: Michal Schmidt <mschmidt@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/airo.c59
1 files changed, 28 insertions, 31 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index d675d984c85d..d96057f4a0de 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -52,6 +52,8 @@
52 52
53#include "airo.h" 53#include "airo.h"
54 54
55#define DRV_NAME "airo"
56
55#ifdef CONFIG_PCI 57#ifdef CONFIG_PCI
56static struct pci_device_id card_ids[] = { 58static struct pci_device_id card_ids[] = {
57 { 0x14b9, 1, PCI_ANY_ID, PCI_ANY_ID, }, 59 { 0x14b9, 1, PCI_ANY_ID, PCI_ANY_ID, },
@@ -71,7 +73,7 @@ static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state);
71static int airo_pci_resume(struct pci_dev *pdev); 73static int airo_pci_resume(struct pci_dev *pdev);
72 74
73static struct pci_driver airo_driver = { 75static struct pci_driver airo_driver = {
74 .name = "airo", 76 .name = DRV_NAME,
75 .id_table = card_ids, 77 .id_table = card_ids,
76 .probe = airo_pci_probe, 78 .probe = airo_pci_probe,
77 .remove = __devexit_p(airo_pci_remove), 79 .remove = __devexit_p(airo_pci_remove),
@@ -1250,7 +1252,7 @@ static int flashputbuf(struct airo_info *ai);
1250static int flashrestart(struct airo_info *ai,struct net_device *dev); 1252static int flashrestart(struct airo_info *ai,struct net_device *dev);
1251 1253
1252#define airo_print(type, name, fmt, args...) \ 1254#define airo_print(type, name, fmt, args...) \
1253 { printk(type "airo(%s): " fmt "\n", name, ##args); } 1255 printk(type DRV_NAME "(%s): " fmt "\n", name, ##args)
1254 1256
1255#define airo_print_info(name, fmt, args...) \ 1257#define airo_print_info(name, fmt, args...) \
1256 airo_print(KERN_INFO, name, fmt, ##args) 1258 airo_print(KERN_INFO, name, fmt, ##args)
@@ -2582,8 +2584,7 @@ static int mpi_init_descriptors (struct airo_info *ai)
2582 * 2) Map PCI memory for issueing commands. 2584 * 2) Map PCI memory for issueing commands.
2583 * 3) Allocate memory (shared) to send and receive ethernet frames. 2585 * 3) Allocate memory (shared) to send and receive ethernet frames.
2584 */ 2586 */
2585static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci, 2587static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci)
2586 const char *name)
2587{ 2588{
2588 unsigned long mem_start, mem_len, aux_start, aux_len; 2589 unsigned long mem_start, mem_len, aux_start, aux_len;
2589 int rc = -1; 2590 int rc = -1;
@@ -2597,35 +2598,35 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci,
2597 aux_start = pci_resource_start(pci, 2); 2598 aux_start = pci_resource_start(pci, 2);
2598 aux_len = AUXMEMSIZE; 2599 aux_len = AUXMEMSIZE;
2599 2600
2600 if (!request_mem_region(mem_start, mem_len, name)) { 2601 if (!request_mem_region(mem_start, mem_len, DRV_NAME)) {
2601 airo_print_err(ai->dev->name, "Couldn't get region %x[%x] for %s", 2602 airo_print_err("", "Couldn't get region %x[%x]",
2602 (int)mem_start, (int)mem_len, name); 2603 (int)mem_start, (int)mem_len);
2603 goto out; 2604 goto out;
2604 } 2605 }
2605 if (!request_mem_region(aux_start, aux_len, name)) { 2606 if (!request_mem_region(aux_start, aux_len, DRV_NAME)) {
2606 airo_print_err(ai->dev->name, "Couldn't get region %x[%x] for %s", 2607 airo_print_err("", "Couldn't get region %x[%x]",
2607 (int)aux_start, (int)aux_len, name); 2608 (int)aux_start, (int)aux_len);
2608 goto free_region1; 2609 goto free_region1;
2609 } 2610 }
2610 2611
2611 ai->pcimem = ioremap(mem_start, mem_len); 2612 ai->pcimem = ioremap(mem_start, mem_len);
2612 if (!ai->pcimem) { 2613 if (!ai->pcimem) {
2613 airo_print_err(ai->dev->name, "Couldn't map region %x[%x] for %s", 2614 airo_print_err("", "Couldn't map region %x[%x]",
2614 (int)mem_start, (int)mem_len, name); 2615 (int)mem_start, (int)mem_len);
2615 goto free_region2; 2616 goto free_region2;
2616 } 2617 }
2617 ai->pciaux = ioremap(aux_start, aux_len); 2618 ai->pciaux = ioremap(aux_start, aux_len);
2618 if (!ai->pciaux) { 2619 if (!ai->pciaux) {
2619 airo_print_err(ai->dev->name, "Couldn't map region %x[%x] for %s", 2620 airo_print_err("", "Couldn't map region %x[%x]",
2620 (int)aux_start, (int)aux_len, name); 2621 (int)aux_start, (int)aux_len);
2621 goto free_memmap; 2622 goto free_memmap;
2622 } 2623 }
2623 2624
2624 /* Reserve PKTSIZE for each fid and 2K for the Rids */ 2625 /* Reserve PKTSIZE for each fid and 2K for the Rids */
2625 ai->shared = pci_alloc_consistent(pci, PCI_SHARED_LEN, &ai->shared_dma); 2626 ai->shared = pci_alloc_consistent(pci, PCI_SHARED_LEN, &ai->shared_dma);
2626 if (!ai->shared) { 2627 if (!ai->shared) {
2627 airo_print_err(ai->dev->name, "Couldn't alloc_consistent %d", 2628 airo_print_err("", "Couldn't alloc_consistent %d",
2628 PCI_SHARED_LEN); 2629 PCI_SHARED_LEN);
2629 goto free_auxmap; 2630 goto free_auxmap;
2630 } 2631 }
2631 2632
@@ -2770,7 +2771,7 @@ static int airo_networks_allocate(struct airo_info *ai)
2770 kzalloc(AIRO_MAX_NETWORK_COUNT * sizeof(BSSListElement), 2771 kzalloc(AIRO_MAX_NETWORK_COUNT * sizeof(BSSListElement),
2771 GFP_KERNEL); 2772 GFP_KERNEL);
2772 if (!ai->networks) { 2773 if (!ai->networks) {
2773 airo_print_warn(ai->dev->name, "Out of memory allocating beacons"); 2774 airo_print_warn("", "Out of memory allocating beacons");
2774 return -ENOMEM; 2775 return -ENOMEM;
2775 } 2776 }
2776 2777
@@ -2798,7 +2799,6 @@ static int airo_test_wpa_capable(struct airo_info *ai)
2798{ 2799{
2799 int status; 2800 int status;
2800 CapabilityRid cap_rid; 2801 CapabilityRid cap_rid;
2801 const char *name = ai->dev->name;
2802 2802
2803 status = readCapabilityRid(ai, &cap_rid, 1); 2803 status = readCapabilityRid(ai, &cap_rid, 1);
2804 if (status != SUCCESS) return 0; 2804 if (status != SUCCESS) return 0;
@@ -2806,12 +2806,12 @@ static int airo_test_wpa_capable(struct airo_info *ai)
2806 /* Only firmware versions 5.30.17 or better can do WPA */ 2806 /* Only firmware versions 5.30.17 or better can do WPA */
2807 if ((cap_rid.softVer > 0x530) 2807 if ((cap_rid.softVer > 0x530)
2808 || ((cap_rid.softVer == 0x530) && (cap_rid.softSubVer >= 17))) { 2808 || ((cap_rid.softVer == 0x530) && (cap_rid.softSubVer >= 17))) {
2809 airo_print_info(name, "WPA is supported."); 2809 airo_print_info("", "WPA is supported.");
2810 return 1; 2810 return 1;
2811 } 2811 }
2812 2812
2813 /* No WPA support */ 2813 /* No WPA support */
2814 airo_print_info(name, "WPA unsupported (only firmware versions 5.30.17" 2814 airo_print_info("", "WPA unsupported (only firmware versions 5.30.17"
2815 " and greater support WPA. Detected %s)", cap_rid.prodVer); 2815 " and greater support WPA. Detected %s)", cap_rid.prodVer);
2816 return 0; 2816 return 0;
2817} 2817}
@@ -2825,14 +2825,10 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2825 int i, rc; 2825 int i, rc;
2826 2826
2827 /* Create the network device object. */ 2827 /* Create the network device object. */
2828 dev = alloc_etherdev(sizeof(*ai)); 2828 dev = alloc_netdev(sizeof(*ai), "", ether_setup);
2829 if (!dev) { 2829 if (!dev) {
2830 airo_print_err("", "Couldn't alloc_etherdev"); 2830 airo_print_err("", "Couldn't alloc_etherdev");
2831 return NULL; 2831 return NULL;
2832 }
2833 if (dev_alloc_name(dev, dev->name) < 0) {
2834 airo_print_err("", "Couldn't get name!");
2835 goto err_out_free;
2836 } 2832 }
2837 2833
2838 ai = dev->priv; 2834 ai = dev->priv;
@@ -2841,7 +2837,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2841 ai->jobs = 0; 2837 ai->jobs = 0;
2842 ai->dev = dev; 2838 ai->dev = dev;
2843 if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) { 2839 if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) {
2844 airo_print_dbg(dev->name, "Found an MPI350 card"); 2840 airo_print_dbg("", "Found an MPI350 card");
2845 set_bit(FLAG_MPI, &ai->flags); 2841 set_bit(FLAG_MPI, &ai->flags);
2846 } 2842 }
2847 spin_lock_init(&ai->aux_lock); 2843 spin_lock_init(&ai->aux_lock);
@@ -2882,7 +2878,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2882 msleep(400); 2878 msleep(400);
2883 2879
2884 if (!is_pcmcia) { 2880 if (!is_pcmcia) {
2885 if (!request_region( dev->base_addr, 64, dev->name )) { 2881 if (!request_region(dev->base_addr, 64, DRV_NAME)) {
2886 rc = -EBUSY; 2882 rc = -EBUSY;
2887 airo_print_err(dev->name, "Couldn't request region"); 2883 airo_print_err(dev->name, "Couldn't request region");
2888 goto err_out_nets; 2884 goto err_out_nets;
@@ -2890,8 +2886,8 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2890 } 2886 }
2891 2887
2892 if (test_bit(FLAG_MPI,&ai->flags)) { 2888 if (test_bit(FLAG_MPI,&ai->flags)) {
2893 if (mpi_map_card(ai, pci, dev->name)) { 2889 if (mpi_map_card(ai, pci)) {
2894 airo_print_err(dev->name, "Could not map memory"); 2890 airo_print_err("", "Could not map memory");
2895 goto err_out_res; 2891 goto err_out_res;
2896 } 2892 }
2897 } 2893 }
@@ -2919,6 +2915,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2919 ai->bssListRidLen = sizeof(BSSListRid) - sizeof(BSSListRidExtra); 2915 ai->bssListRidLen = sizeof(BSSListRid) - sizeof(BSSListRidExtra);
2920 } 2916 }
2921 2917
2918 strcpy(dev->name, "eth%d");
2922 rc = register_netdev(dev); 2919 rc = register_netdev(dev);
2923 if (rc) { 2920 if (rc) {
2924 airo_print_err(dev->name, "Couldn't register_netdev"); 2921 airo_print_err(dev->name, "Couldn't register_netdev");
@@ -4014,7 +4011,7 @@ static int bap_setup(struct airo_info *ai, u16 rid, u16 offset, int whichbap )
4014 } 4011 }
4015 if ( !(max_tries--) ) { 4012 if ( !(max_tries--) ) {
4016 airo_print_err(ai->dev->name, 4013 airo_print_err(ai->dev->name,
4017 "airo: BAP setup error too many retries\n"); 4014 "BAP setup error too many retries\n");
4018 return ERROR; 4015 return ERROR;
4019 } 4016 }
4020 // -- PC4500 missed it, try again 4017 // -- PC4500 missed it, try again