diff options
Diffstat (limited to 'drivers/net/wireless/airo.c')
-rw-r--r-- | drivers/net/wireless/airo.c | 208 |
1 files changed, 105 insertions, 103 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 2d3a180dada0..1c54908fdc4c 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 |
56 | static struct pci_device_id card_ids[] = { | 58 | static 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); | |||
71 | static int airo_pci_resume(struct pci_dev *pdev); | 73 | static int airo_pci_resume(struct pci_dev *pdev); |
72 | 74 | ||
73 | static struct pci_driver airo_driver = { | 75 | static 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), |
@@ -1092,7 +1094,7 @@ static int get_dec_u16( char *buffer, int *start, int limit ); | |||
1092 | static void OUT4500( struct airo_info *, u16 register, u16 value ); | 1094 | static void OUT4500( struct airo_info *, u16 register, u16 value ); |
1093 | static unsigned short IN4500( struct airo_info *, u16 register ); | 1095 | static unsigned short IN4500( struct airo_info *, u16 register ); |
1094 | static u16 setup_card(struct airo_info*, u8 *mac, int lock); | 1096 | static u16 setup_card(struct airo_info*, u8 *mac, int lock); |
1095 | static int enable_MAC( struct airo_info *ai, Resp *rsp, int lock ); | 1097 | static int enable_MAC(struct airo_info *ai, int lock); |
1096 | static void disable_MAC(struct airo_info *ai, int lock); | 1098 | static void disable_MAC(struct airo_info *ai, int lock); |
1097 | static void enable_interrupts(struct airo_info*); | 1099 | static void enable_interrupts(struct airo_info*); |
1098 | static void disable_interrupts(struct airo_info*); | 1100 | static void disable_interrupts(struct airo_info*); |
@@ -1250,7 +1252,7 @@ static int flashputbuf(struct airo_info *ai); | |||
1250 | static int flashrestart(struct airo_info *ai,struct net_device *dev); | 1252 | static 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) |
@@ -1926,28 +1928,54 @@ static int readStatsRid(struct airo_info*ai, StatsRid *sr, int rid, int lock) { | |||
1926 | return rc; | 1928 | return rc; |
1927 | } | 1929 | } |
1928 | 1930 | ||
1931 | static void try_auto_wep(struct airo_info *ai) | ||
1932 | { | ||
1933 | if (auto_wep && !(ai->flags & FLAG_RADIO_DOWN)) { | ||
1934 | ai->expires = RUN_AT(3*HZ); | ||
1935 | wake_up_interruptible(&ai->thr_wait); | ||
1936 | } | ||
1937 | } | ||
1938 | |||
1929 | static int airo_open(struct net_device *dev) { | 1939 | static int airo_open(struct net_device *dev) { |
1930 | struct airo_info *info = dev->priv; | 1940 | struct airo_info *ai = dev->priv; |
1931 | Resp rsp; | 1941 | int rc = 0; |
1932 | 1942 | ||
1933 | if (test_bit(FLAG_FLASHING, &info->flags)) | 1943 | if (test_bit(FLAG_FLASHING, &ai->flags)) |
1934 | return -EIO; | 1944 | return -EIO; |
1935 | 1945 | ||
1936 | /* Make sure the card is configured. | 1946 | /* Make sure the card is configured. |
1937 | * Wireless Extensions may postpone config changes until the card | 1947 | * Wireless Extensions may postpone config changes until the card |
1938 | * is open (to pipeline changes and speed-up card setup). If | 1948 | * is open (to pipeline changes and speed-up card setup). If |
1939 | * those changes are not yet commited, do it now - Jean II */ | 1949 | * those changes are not yet commited, do it now - Jean II */ |
1940 | if (test_bit (FLAG_COMMIT, &info->flags)) { | 1950 | if (test_bit(FLAG_COMMIT, &ai->flags)) { |
1941 | disable_MAC(info, 1); | 1951 | disable_MAC(ai, 1); |
1942 | writeConfigRid(info, 1); | 1952 | writeConfigRid(ai, 1); |
1943 | } | 1953 | } |
1944 | 1954 | ||
1945 | if (info->wifidev != dev) { | 1955 | if (ai->wifidev != dev) { |
1956 | clear_bit(JOB_DIE, &ai->jobs); | ||
1957 | ai->airo_thread_task = kthread_run(airo_thread, dev, dev->name); | ||
1958 | if (IS_ERR(ai->airo_thread_task)) | ||
1959 | return (int)PTR_ERR(ai->airo_thread_task); | ||
1960 | |||
1961 | rc = request_irq(dev->irq, airo_interrupt, IRQF_SHARED, | ||
1962 | dev->name, dev); | ||
1963 | if (rc) { | ||
1964 | airo_print_err(dev->name, | ||
1965 | "register interrupt %d failed, rc %d", | ||
1966 | dev->irq, rc); | ||
1967 | set_bit(JOB_DIE, &ai->jobs); | ||
1968 | kthread_stop(ai->airo_thread_task); | ||
1969 | return rc; | ||
1970 | } | ||
1971 | |||
1946 | /* Power on the MAC controller (which may have been disabled) */ | 1972 | /* Power on the MAC controller (which may have been disabled) */ |
1947 | clear_bit(FLAG_RADIO_DOWN, &info->flags); | 1973 | clear_bit(FLAG_RADIO_DOWN, &ai->flags); |
1948 | enable_interrupts(info); | 1974 | enable_interrupts(ai); |
1975 | |||
1976 | try_auto_wep(ai); | ||
1949 | } | 1977 | } |
1950 | enable_MAC(info, &rsp, 1); | 1978 | enable_MAC(ai, 1); |
1951 | 1979 | ||
1952 | netif_start_queue(dev); | 1980 | netif_start_queue(dev); |
1953 | return 0; | 1981 | return 0; |
@@ -2338,14 +2366,13 @@ static int airo_set_mac_address(struct net_device *dev, void *p) | |||
2338 | { | 2366 | { |
2339 | struct airo_info *ai = dev->priv; | 2367 | struct airo_info *ai = dev->priv; |
2340 | struct sockaddr *addr = p; | 2368 | struct sockaddr *addr = p; |
2341 | Resp rsp; | ||
2342 | 2369 | ||
2343 | readConfigRid(ai, 1); | 2370 | readConfigRid(ai, 1); |
2344 | memcpy (ai->config.macAddr, addr->sa_data, dev->addr_len); | 2371 | memcpy (ai->config.macAddr, addr->sa_data, dev->addr_len); |
2345 | set_bit (FLAG_COMMIT, &ai->flags); | 2372 | set_bit (FLAG_COMMIT, &ai->flags); |
2346 | disable_MAC(ai, 1); | 2373 | disable_MAC(ai, 1); |
2347 | writeConfigRid (ai, 1); | 2374 | writeConfigRid (ai, 1); |
2348 | enable_MAC(ai, &rsp, 1); | 2375 | enable_MAC(ai, 1); |
2349 | memcpy (ai->dev->dev_addr, addr->sa_data, dev->addr_len); | 2376 | memcpy (ai->dev->dev_addr, addr->sa_data, dev->addr_len); |
2350 | if (ai->wifidev) | 2377 | if (ai->wifidev) |
2351 | memcpy (ai->wifidev->dev_addr, addr->sa_data, dev->addr_len); | 2378 | memcpy (ai->wifidev->dev_addr, addr->sa_data, dev->addr_len); |
@@ -2392,6 +2419,11 @@ static int airo_close(struct net_device *dev) { | |||
2392 | disable_MAC(ai, 1); | 2419 | disable_MAC(ai, 1); |
2393 | #endif | 2420 | #endif |
2394 | disable_interrupts( ai ); | 2421 | disable_interrupts( ai ); |
2422 | |||
2423 | free_irq(dev->irq, dev); | ||
2424 | |||
2425 | set_bit(JOB_DIE, &ai->jobs); | ||
2426 | kthread_stop(ai->airo_thread_task); | ||
2395 | } | 2427 | } |
2396 | return 0; | 2428 | return 0; |
2397 | } | 2429 | } |
@@ -2403,7 +2435,6 @@ void stop_airo_card( struct net_device *dev, int freeres ) | |||
2403 | set_bit(FLAG_RADIO_DOWN, &ai->flags); | 2435 | set_bit(FLAG_RADIO_DOWN, &ai->flags); |
2404 | disable_MAC(ai, 1); | 2436 | disable_MAC(ai, 1); |
2405 | disable_interrupts(ai); | 2437 | disable_interrupts(ai); |
2406 | free_irq( dev->irq, dev ); | ||
2407 | takedown_proc_entry( dev, ai ); | 2438 | takedown_proc_entry( dev, ai ); |
2408 | if (test_bit(FLAG_REGISTERED, &ai->flags)) { | 2439 | if (test_bit(FLAG_REGISTERED, &ai->flags)) { |
2409 | unregister_netdev( dev ); | 2440 | unregister_netdev( dev ); |
@@ -2414,9 +2445,6 @@ void stop_airo_card( struct net_device *dev, int freeres ) | |||
2414 | } | 2445 | } |
2415 | clear_bit(FLAG_REGISTERED, &ai->flags); | 2446 | clear_bit(FLAG_REGISTERED, &ai->flags); |
2416 | } | 2447 | } |
2417 | set_bit(JOB_DIE, &ai->jobs); | ||
2418 | kthread_stop(ai->airo_thread_task); | ||
2419 | |||
2420 | /* | 2448 | /* |
2421 | * Clean out tx queue | 2449 | * Clean out tx queue |
2422 | */ | 2450 | */ |
@@ -2554,8 +2582,7 @@ static int mpi_init_descriptors (struct airo_info *ai) | |||
2554 | * 2) Map PCI memory for issueing commands. | 2582 | * 2) Map PCI memory for issueing commands. |
2555 | * 3) Allocate memory (shared) to send and receive ethernet frames. | 2583 | * 3) Allocate memory (shared) to send and receive ethernet frames. |
2556 | */ | 2584 | */ |
2557 | static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci, | 2585 | static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci) |
2558 | const char *name) | ||
2559 | { | 2586 | { |
2560 | unsigned long mem_start, mem_len, aux_start, aux_len; | 2587 | unsigned long mem_start, mem_len, aux_start, aux_len; |
2561 | int rc = -1; | 2588 | int rc = -1; |
@@ -2569,35 +2596,35 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci, | |||
2569 | aux_start = pci_resource_start(pci, 2); | 2596 | aux_start = pci_resource_start(pci, 2); |
2570 | aux_len = AUXMEMSIZE; | 2597 | aux_len = AUXMEMSIZE; |
2571 | 2598 | ||
2572 | if (!request_mem_region(mem_start, mem_len, name)) { | 2599 | if (!request_mem_region(mem_start, mem_len, DRV_NAME)) { |
2573 | airo_print_err(ai->dev->name, "Couldn't get region %x[%x] for %s", | 2600 | airo_print_err("", "Couldn't get region %x[%x]", |
2574 | (int)mem_start, (int)mem_len, name); | 2601 | (int)mem_start, (int)mem_len); |
2575 | goto out; | 2602 | goto out; |
2576 | } | 2603 | } |
2577 | if (!request_mem_region(aux_start, aux_len, name)) { | 2604 | if (!request_mem_region(aux_start, aux_len, DRV_NAME)) { |
2578 | airo_print_err(ai->dev->name, "Couldn't get region %x[%x] for %s", | 2605 | airo_print_err("", "Couldn't get region %x[%x]", |
2579 | (int)aux_start, (int)aux_len, name); | 2606 | (int)aux_start, (int)aux_len); |
2580 | goto free_region1; | 2607 | goto free_region1; |
2581 | } | 2608 | } |
2582 | 2609 | ||
2583 | ai->pcimem = ioremap(mem_start, mem_len); | 2610 | ai->pcimem = ioremap(mem_start, mem_len); |
2584 | if (!ai->pcimem) { | 2611 | if (!ai->pcimem) { |
2585 | airo_print_err(ai->dev->name, "Couldn't map region %x[%x] for %s", | 2612 | airo_print_err("", "Couldn't map region %x[%x]", |
2586 | (int)mem_start, (int)mem_len, name); | 2613 | (int)mem_start, (int)mem_len); |
2587 | goto free_region2; | 2614 | goto free_region2; |
2588 | } | 2615 | } |
2589 | ai->pciaux = ioremap(aux_start, aux_len); | 2616 | ai->pciaux = ioremap(aux_start, aux_len); |
2590 | if (!ai->pciaux) { | 2617 | if (!ai->pciaux) { |
2591 | airo_print_err(ai->dev->name, "Couldn't map region %x[%x] for %s", | 2618 | airo_print_err("", "Couldn't map region %x[%x]", |
2592 | (int)aux_start, (int)aux_len, name); | 2619 | (int)aux_start, (int)aux_len); |
2593 | goto free_memmap; | 2620 | goto free_memmap; |
2594 | } | 2621 | } |
2595 | 2622 | ||
2596 | /* Reserve PKTSIZE for each fid and 2K for the Rids */ | 2623 | /* Reserve PKTSIZE for each fid and 2K for the Rids */ |
2597 | ai->shared = pci_alloc_consistent(pci, PCI_SHARED_LEN, &ai->shared_dma); | 2624 | ai->shared = pci_alloc_consistent(pci, PCI_SHARED_LEN, &ai->shared_dma); |
2598 | if (!ai->shared) { | 2625 | if (!ai->shared) { |
2599 | airo_print_err(ai->dev->name, "Couldn't alloc_consistent %d", | 2626 | airo_print_err("", "Couldn't alloc_consistent %d", |
2600 | PCI_SHARED_LEN); | 2627 | PCI_SHARED_LEN); |
2601 | goto free_auxmap; | 2628 | goto free_auxmap; |
2602 | } | 2629 | } |
2603 | 2630 | ||
@@ -2742,7 +2769,7 @@ static int airo_networks_allocate(struct airo_info *ai) | |||
2742 | kzalloc(AIRO_MAX_NETWORK_COUNT * sizeof(BSSListElement), | 2769 | kzalloc(AIRO_MAX_NETWORK_COUNT * sizeof(BSSListElement), |
2743 | GFP_KERNEL); | 2770 | GFP_KERNEL); |
2744 | if (!ai->networks) { | 2771 | if (!ai->networks) { |
2745 | airo_print_warn(ai->dev->name, "Out of memory allocating beacons"); | 2772 | airo_print_warn("", "Out of memory allocating beacons"); |
2746 | return -ENOMEM; | 2773 | return -ENOMEM; |
2747 | } | 2774 | } |
2748 | 2775 | ||
@@ -2770,7 +2797,6 @@ static int airo_test_wpa_capable(struct airo_info *ai) | |||
2770 | { | 2797 | { |
2771 | int status; | 2798 | int status; |
2772 | CapabilityRid cap_rid; | 2799 | CapabilityRid cap_rid; |
2773 | const char *name = ai->dev->name; | ||
2774 | 2800 | ||
2775 | status = readCapabilityRid(ai, &cap_rid, 1); | 2801 | status = readCapabilityRid(ai, &cap_rid, 1); |
2776 | if (status != SUCCESS) return 0; | 2802 | if (status != SUCCESS) return 0; |
@@ -2778,12 +2804,12 @@ static int airo_test_wpa_capable(struct airo_info *ai) | |||
2778 | /* Only firmware versions 5.30.17 or better can do WPA */ | 2804 | /* Only firmware versions 5.30.17 or better can do WPA */ |
2779 | if ((cap_rid.softVer > 0x530) | 2805 | if ((cap_rid.softVer > 0x530) |
2780 | || ((cap_rid.softVer == 0x530) && (cap_rid.softSubVer >= 17))) { | 2806 | || ((cap_rid.softVer == 0x530) && (cap_rid.softSubVer >= 17))) { |
2781 | airo_print_info(name, "WPA is supported."); | 2807 | airo_print_info("", "WPA is supported."); |
2782 | return 1; | 2808 | return 1; |
2783 | } | 2809 | } |
2784 | 2810 | ||
2785 | /* No WPA support */ | 2811 | /* No WPA support */ |
2786 | airo_print_info(name, "WPA unsupported (only firmware versions 5.30.17" | 2812 | airo_print_info("", "WPA unsupported (only firmware versions 5.30.17" |
2787 | " and greater support WPA. Detected %s)", cap_rid.prodVer); | 2813 | " and greater support WPA. Detected %s)", cap_rid.prodVer); |
2788 | return 0; | 2814 | return 0; |
2789 | } | 2815 | } |
@@ -2797,23 +2823,19 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
2797 | int i, rc; | 2823 | int i, rc; |
2798 | 2824 | ||
2799 | /* Create the network device object. */ | 2825 | /* Create the network device object. */ |
2800 | dev = alloc_etherdev(sizeof(*ai)); | 2826 | dev = alloc_netdev(sizeof(*ai), "", ether_setup); |
2801 | if (!dev) { | 2827 | if (!dev) { |
2802 | airo_print_err("", "Couldn't alloc_etherdev"); | 2828 | airo_print_err("", "Couldn't alloc_etherdev"); |
2803 | return NULL; | 2829 | return NULL; |
2804 | } | ||
2805 | if (dev_alloc_name(dev, dev->name) < 0) { | ||
2806 | airo_print_err("", "Couldn't get name!"); | ||
2807 | goto err_out_free; | ||
2808 | } | 2830 | } |
2809 | 2831 | ||
2810 | ai = dev->priv; | 2832 | ai = dev->priv; |
2811 | ai->wifidev = NULL; | 2833 | ai->wifidev = NULL; |
2812 | ai->flags = 0; | 2834 | ai->flags = 1 << FLAG_RADIO_DOWN; |
2813 | ai->jobs = 0; | 2835 | ai->jobs = 0; |
2814 | ai->dev = dev; | 2836 | ai->dev = dev; |
2815 | if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) { | 2837 | if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) { |
2816 | airo_print_dbg(dev->name, "Found an MPI350 card"); | 2838 | airo_print_dbg("", "Found an MPI350 card"); |
2817 | set_bit(FLAG_MPI, &ai->flags); | 2839 | set_bit(FLAG_MPI, &ai->flags); |
2818 | } | 2840 | } |
2819 | spin_lock_init(&ai->aux_lock); | 2841 | spin_lock_init(&ai->aux_lock); |
@@ -2821,14 +2843,11 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
2821 | ai->config.len = 0; | 2843 | ai->config.len = 0; |
2822 | ai->pci = pci; | 2844 | ai->pci = pci; |
2823 | init_waitqueue_head (&ai->thr_wait); | 2845 | init_waitqueue_head (&ai->thr_wait); |
2824 | ai->airo_thread_task = kthread_run(airo_thread, dev, dev->name); | ||
2825 | if (IS_ERR(ai->airo_thread_task)) | ||
2826 | goto err_out_free; | ||
2827 | ai->tfm = NULL; | 2846 | ai->tfm = NULL; |
2828 | add_airo_dev(ai); | 2847 | add_airo_dev(ai); |
2829 | 2848 | ||
2830 | if (airo_networks_allocate (ai)) | 2849 | if (airo_networks_allocate (ai)) |
2831 | goto err_out_thr; | 2850 | goto err_out_free; |
2832 | airo_networks_initialize (ai); | 2851 | airo_networks_initialize (ai); |
2833 | 2852 | ||
2834 | /* The Airo-specific entries in the device structure. */ | 2853 | /* The Airo-specific entries in the device structure. */ |
@@ -2851,27 +2870,22 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
2851 | dev->base_addr = port; | 2870 | dev->base_addr = port; |
2852 | 2871 | ||
2853 | SET_NETDEV_DEV(dev, dmdev); | 2872 | SET_NETDEV_DEV(dev, dmdev); |
2873 | SET_MODULE_OWNER(dev); | ||
2854 | 2874 | ||
2855 | reset_card (dev, 1); | 2875 | reset_card (dev, 1); |
2856 | msleep(400); | 2876 | msleep(400); |
2857 | 2877 | ||
2858 | rc = request_irq( dev->irq, airo_interrupt, IRQF_SHARED, dev->name, dev ); | ||
2859 | if (rc) { | ||
2860 | airo_print_err(dev->name, "register interrupt %d failed, rc %d", | ||
2861 | irq, rc); | ||
2862 | goto err_out_nets; | ||
2863 | } | ||
2864 | if (!is_pcmcia) { | 2878 | if (!is_pcmcia) { |
2865 | if (!request_region( dev->base_addr, 64, dev->name )) { | 2879 | if (!request_region(dev->base_addr, 64, DRV_NAME)) { |
2866 | rc = -EBUSY; | 2880 | rc = -EBUSY; |
2867 | airo_print_err(dev->name, "Couldn't request region"); | 2881 | airo_print_err(dev->name, "Couldn't request region"); |
2868 | goto err_out_irq; | 2882 | goto err_out_nets; |
2869 | } | 2883 | } |
2870 | } | 2884 | } |
2871 | 2885 | ||
2872 | if (test_bit(FLAG_MPI,&ai->flags)) { | 2886 | if (test_bit(FLAG_MPI,&ai->flags)) { |
2873 | if (mpi_map_card(ai, pci, dev->name)) { | 2887 | if (mpi_map_card(ai, pci)) { |
2874 | airo_print_err(dev->name, "Could not map memory"); | 2888 | airo_print_err("", "Could not map memory"); |
2875 | goto err_out_res; | 2889 | goto err_out_res; |
2876 | } | 2890 | } |
2877 | } | 2891 | } |
@@ -2899,6 +2913,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
2899 | ai->bssListRidLen = sizeof(BSSListRid) - sizeof(BSSListRidExtra); | 2913 | ai->bssListRidLen = sizeof(BSSListRid) - sizeof(BSSListRidExtra); |
2900 | } | 2914 | } |
2901 | 2915 | ||
2916 | strcpy(dev->name, "eth%d"); | ||
2902 | rc = register_netdev(dev); | 2917 | rc = register_netdev(dev); |
2903 | if (rc) { | 2918 | if (rc) { |
2904 | airo_print_err(dev->name, "Couldn't register_netdev"); | 2919 | airo_print_err(dev->name, "Couldn't register_netdev"); |
@@ -2921,8 +2936,6 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
2921 | if (setup_proc_entry(dev, dev->priv) < 0) | 2936 | if (setup_proc_entry(dev, dev->priv) < 0) |
2922 | goto err_out_wifi; | 2937 | goto err_out_wifi; |
2923 | 2938 | ||
2924 | netif_start_queue(dev); | ||
2925 | SET_MODULE_OWNER(dev); | ||
2926 | return dev; | 2939 | return dev; |
2927 | 2940 | ||
2928 | err_out_wifi: | 2941 | err_out_wifi: |
@@ -2940,14 +2953,9 @@ err_out_map: | |||
2940 | err_out_res: | 2953 | err_out_res: |
2941 | if (!is_pcmcia) | 2954 | if (!is_pcmcia) |
2942 | release_region( dev->base_addr, 64 ); | 2955 | release_region( dev->base_addr, 64 ); |
2943 | err_out_irq: | ||
2944 | free_irq(dev->irq, dev); | ||
2945 | err_out_nets: | 2956 | err_out_nets: |
2946 | airo_networks_free(ai); | 2957 | airo_networks_free(ai); |
2947 | err_out_thr: | ||
2948 | del_airo_dev(ai); | 2958 | del_airo_dev(ai); |
2949 | set_bit(JOB_DIE, &ai->jobs); | ||
2950 | kthread_stop(ai->airo_thread_task); | ||
2951 | err_out_free: | 2959 | err_out_free: |
2952 | free_netdev(dev); | 2960 | free_netdev(dev); |
2953 | return NULL; | 2961 | return NULL; |
@@ -3529,9 +3537,11 @@ static u16 IN4500( struct airo_info *ai, u16 reg ) { | |||
3529 | return rc; | 3537 | return rc; |
3530 | } | 3538 | } |
3531 | 3539 | ||
3532 | static int enable_MAC( struct airo_info *ai, Resp *rsp, int lock ) { | 3540 | static int enable_MAC(struct airo_info *ai, int lock) |
3541 | { | ||
3533 | int rc; | 3542 | int rc; |
3534 | Cmd cmd; | 3543 | Cmd cmd; |
3544 | Resp rsp; | ||
3535 | 3545 | ||
3536 | /* FLAG_RADIO_OFF : Radio disabled via /proc or Wireless Extensions | 3546 | /* FLAG_RADIO_OFF : Radio disabled via /proc or Wireless Extensions |
3537 | * FLAG_RADIO_DOWN : Radio disabled via "ifconfig ethX down" | 3547 | * FLAG_RADIO_DOWN : Radio disabled via "ifconfig ethX down" |
@@ -3547,7 +3557,7 @@ static int enable_MAC( struct airo_info *ai, Resp *rsp, int lock ) { | |||
3547 | if (!test_bit(FLAG_ENABLED, &ai->flags)) { | 3557 | if (!test_bit(FLAG_ENABLED, &ai->flags)) { |
3548 | memset(&cmd, 0, sizeof(cmd)); | 3558 | memset(&cmd, 0, sizeof(cmd)); |
3549 | cmd.cmd = MAC_ENABLE; | 3559 | cmd.cmd = MAC_ENABLE; |
3550 | rc = issuecommand(ai, &cmd, rsp); | 3560 | rc = issuecommand(ai, &cmd, &rsp); |
3551 | if (rc == SUCCESS) | 3561 | if (rc == SUCCESS) |
3552 | set_bit(FLAG_ENABLED, &ai->flags); | 3562 | set_bit(FLAG_ENABLED, &ai->flags); |
3553 | } else | 3563 | } else |
@@ -3557,8 +3567,12 @@ static int enable_MAC( struct airo_info *ai, Resp *rsp, int lock ) { | |||
3557 | up(&ai->sem); | 3567 | up(&ai->sem); |
3558 | 3568 | ||
3559 | if (rc) | 3569 | if (rc) |
3560 | airo_print_err(ai->dev->name, "%s: Cannot enable MAC, err=%d", | 3570 | airo_print_err(ai->dev->name, "Cannot enable MAC"); |
3561 | __FUNCTION__, rc); | 3571 | else if ((rsp.status & 0xFF00) != 0) { |
3572 | airo_print_err(ai->dev->name, "Bad MAC enable reason=%x, " | ||
3573 | "rid=%x, offset=%d", rsp.rsp0, rsp.rsp1, rsp.rsp2); | ||
3574 | rc = ERROR; | ||
3575 | } | ||
3562 | return rc; | 3576 | return rc; |
3563 | } | 3577 | } |
3564 | 3578 | ||
@@ -3902,12 +3916,9 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) | |||
3902 | if ( status != SUCCESS ) return ERROR; | 3916 | if ( status != SUCCESS ) return ERROR; |
3903 | } | 3917 | } |
3904 | 3918 | ||
3905 | status = enable_MAC(ai, &rsp, lock); | 3919 | status = enable_MAC(ai, lock); |
3906 | if ( status != SUCCESS || (rsp.status & 0xFF00) != 0) { | 3920 | if (status != SUCCESS) |
3907 | airo_print_err(ai->dev->name, "Bad MAC enable reason = %x, rid = %x," | ||
3908 | " offset = %d", rsp.rsp0, rsp.rsp1, rsp.rsp2 ); | ||
3909 | return ERROR; | 3921 | return ERROR; |
3910 | } | ||
3911 | 3922 | ||
3912 | /* Grab the initial wep key, we gotta save it for auto_wep */ | 3923 | /* Grab the initial wep key, we gotta save it for auto_wep */ |
3913 | rc = readWepKeyRid(ai, &wkr, 1, lock); | 3924 | rc = readWepKeyRid(ai, &wkr, 1, lock); |
@@ -3919,10 +3930,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) | |||
3919 | rc = readWepKeyRid(ai, &wkr, 0, lock); | 3930 | rc = readWepKeyRid(ai, &wkr, 0, lock); |
3920 | } while(lastindex != wkr.kindex); | 3931 | } while(lastindex != wkr.kindex); |
3921 | 3932 | ||
3922 | if (auto_wep) { | 3933 | try_auto_wep(ai); |
3923 | ai->expires = RUN_AT(3*HZ); | ||
3924 | wake_up_interruptible(&ai->thr_wait); | ||
3925 | } | ||
3926 | 3934 | ||
3927 | return SUCCESS; | 3935 | return SUCCESS; |
3928 | } | 3936 | } |
@@ -4004,7 +4012,7 @@ static int bap_setup(struct airo_info *ai, u16 rid, u16 offset, int whichbap ) | |||
4004 | } | 4012 | } |
4005 | if ( !(max_tries--) ) { | 4013 | if ( !(max_tries--) ) { |
4006 | airo_print_err(ai->dev->name, | 4014 | airo_print_err(ai->dev->name, |
4007 | "airo: BAP setup error too many retries\n"); | 4015 | "BAP setup error too many retries\n"); |
4008 | return ERROR; | 4016 | return ERROR; |
4009 | } | 4017 | } |
4010 | // -- PC4500 missed it, try again | 4018 | // -- PC4500 missed it, try again |
@@ -5152,7 +5160,6 @@ static void proc_SSID_on_close( struct inode *inode, struct file *file ) { | |||
5152 | struct net_device *dev = dp->data; | 5160 | struct net_device *dev = dp->data; |
5153 | struct airo_info *ai = dev->priv; | 5161 | struct airo_info *ai = dev->priv; |
5154 | SsidRid SSID_rid; | 5162 | SsidRid SSID_rid; |
5155 | Resp rsp; | ||
5156 | int i; | 5163 | int i; |
5157 | int offset = 0; | 5164 | int offset = 0; |
5158 | 5165 | ||
@@ -5177,7 +5184,7 @@ static void proc_SSID_on_close( struct inode *inode, struct file *file ) { | |||
5177 | SSID_rid.len = sizeof(SSID_rid); | 5184 | SSID_rid.len = sizeof(SSID_rid); |
5178 | disable_MAC(ai, 1); | 5185 | disable_MAC(ai, 1); |
5179 | writeSsidRid(ai, &SSID_rid, 1); | 5186 | writeSsidRid(ai, &SSID_rid, 1); |
5180 | enable_MAC(ai, &rsp, 1); | 5187 | enable_MAC(ai, 1); |
5181 | } | 5188 | } |
5182 | 5189 | ||
5183 | static inline u8 hexVal(char c) { | 5190 | static inline u8 hexVal(char c) { |
@@ -5193,7 +5200,6 @@ static void proc_APList_on_close( struct inode *inode, struct file *file ) { | |||
5193 | struct net_device *dev = dp->data; | 5200 | struct net_device *dev = dp->data; |
5194 | struct airo_info *ai = dev->priv; | 5201 | struct airo_info *ai = dev->priv; |
5195 | APListRid APList_rid; | 5202 | APListRid APList_rid; |
5196 | Resp rsp; | ||
5197 | int i; | 5203 | int i; |
5198 | 5204 | ||
5199 | if ( !data->writelen ) return; | 5205 | if ( !data->writelen ) return; |
@@ -5218,18 +5224,17 @@ static void proc_APList_on_close( struct inode *inode, struct file *file ) { | |||
5218 | } | 5224 | } |
5219 | disable_MAC(ai, 1); | 5225 | disable_MAC(ai, 1); |
5220 | writeAPListRid(ai, &APList_rid, 1); | 5226 | writeAPListRid(ai, &APList_rid, 1); |
5221 | enable_MAC(ai, &rsp, 1); | 5227 | enable_MAC(ai, 1); |
5222 | } | 5228 | } |
5223 | 5229 | ||
5224 | /* This function wraps PC4500_writerid with a MAC disable */ | 5230 | /* This function wraps PC4500_writerid with a MAC disable */ |
5225 | static int do_writerid( struct airo_info *ai, u16 rid, const void *rid_data, | 5231 | static int do_writerid( struct airo_info *ai, u16 rid, const void *rid_data, |
5226 | int len, int dummy ) { | 5232 | int len, int dummy ) { |
5227 | int rc; | 5233 | int rc; |
5228 | Resp rsp; | ||
5229 | 5234 | ||
5230 | disable_MAC(ai, 1); | 5235 | disable_MAC(ai, 1); |
5231 | rc = PC4500_writerid(ai, rid, rid_data, len, 1); | 5236 | rc = PC4500_writerid(ai, rid, rid_data, len, 1); |
5232 | enable_MAC(ai, &rsp, 1); | 5237 | enable_MAC(ai, 1); |
5233 | return rc; | 5238 | return rc; |
5234 | } | 5239 | } |
5235 | 5240 | ||
@@ -5260,7 +5265,6 @@ static int set_wep_key(struct airo_info *ai, u16 index, | |||
5260 | const char *key, u16 keylen, int perm, int lock ) { | 5265 | const char *key, u16 keylen, int perm, int lock ) { |
5261 | static const unsigned char macaddr[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 }; | 5266 | static const unsigned char macaddr[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 }; |
5262 | WepKeyRid wkr; | 5267 | WepKeyRid wkr; |
5263 | Resp rsp; | ||
5264 | 5268 | ||
5265 | memset(&wkr, 0, sizeof(wkr)); | 5269 | memset(&wkr, 0, sizeof(wkr)); |
5266 | if (keylen == 0) { | 5270 | if (keylen == 0) { |
@@ -5280,7 +5284,7 @@ static int set_wep_key(struct airo_info *ai, u16 index, | |||
5280 | 5284 | ||
5281 | if (perm) disable_MAC(ai, lock); | 5285 | if (perm) disable_MAC(ai, lock); |
5282 | writeWepKeyRid(ai, &wkr, perm, lock); | 5286 | writeWepKeyRid(ai, &wkr, perm, lock); |
5283 | if (perm) enable_MAC(ai, &rsp, lock); | 5287 | if (perm) enable_MAC(ai, lock); |
5284 | return 0; | 5288 | return 0; |
5285 | } | 5289 | } |
5286 | 5290 | ||
@@ -5548,7 +5552,6 @@ static int proc_close( struct inode *inode, struct file *file ) | |||
5548 | changed. */ | 5552 | changed. */ |
5549 | static void timer_func( struct net_device *dev ) { | 5553 | static void timer_func( struct net_device *dev ) { |
5550 | struct airo_info *apriv = dev->priv; | 5554 | struct airo_info *apriv = dev->priv; |
5551 | Resp rsp; | ||
5552 | 5555 | ||
5553 | /* We don't have a link so try changing the authtype */ | 5556 | /* We don't have a link so try changing the authtype */ |
5554 | readConfigRid(apriv, 0); | 5557 | readConfigRid(apriv, 0); |
@@ -5575,7 +5578,7 @@ static void timer_func( struct net_device *dev ) { | |||
5575 | } | 5578 | } |
5576 | set_bit (FLAG_COMMIT, &apriv->flags); | 5579 | set_bit (FLAG_COMMIT, &apriv->flags); |
5577 | writeConfigRid(apriv, 0); | 5580 | writeConfigRid(apriv, 0); |
5578 | enable_MAC(apriv, &rsp, 0); | 5581 | enable_MAC(apriv, 0); |
5579 | up(&apriv->sem); | 5582 | up(&apriv->sem); |
5580 | 5583 | ||
5581 | /* Schedule check to see if the change worked */ | 5584 | /* Schedule check to see if the change worked */ |
@@ -5597,8 +5600,10 @@ static int __devinit airo_pci_probe(struct pci_dev *pdev, | |||
5597 | dev = _init_airo_card(pdev->irq, pdev->resource[0].start, 0, pdev, &pdev->dev); | 5600 | dev = _init_airo_card(pdev->irq, pdev->resource[0].start, 0, pdev, &pdev->dev); |
5598 | else | 5601 | else |
5599 | dev = _init_airo_card(pdev->irq, pdev->resource[2].start, 0, pdev, &pdev->dev); | 5602 | dev = _init_airo_card(pdev->irq, pdev->resource[2].start, 0, pdev, &pdev->dev); |
5600 | if (!dev) | 5603 | if (!dev) { |
5604 | pci_disable_device(pdev); | ||
5601 | return -ENODEV; | 5605 | return -ENODEV; |
5606 | } | ||
5602 | 5607 | ||
5603 | pci_set_drvdata(pdev, dev); | 5608 | pci_set_drvdata(pdev, dev); |
5604 | return 0; | 5609 | return 0; |
@@ -5610,6 +5615,8 @@ static void __devexit airo_pci_remove(struct pci_dev *pdev) | |||
5610 | 5615 | ||
5611 | airo_print_info(dev->name, "Unregistering..."); | 5616 | airo_print_info(dev->name, "Unregistering..."); |
5612 | stop_airo_card(dev, 1); | 5617 | stop_airo_card(dev, 1); |
5618 | pci_disable_device(pdev); | ||
5619 | pci_set_drvdata(pdev, NULL); | ||
5613 | } | 5620 | } |
5614 | 5621 | ||
5615 | static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state) | 5622 | static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state) |
@@ -5646,7 +5653,6 @@ static int airo_pci_resume(struct pci_dev *pdev) | |||
5646 | { | 5653 | { |
5647 | struct net_device *dev = pci_get_drvdata(pdev); | 5654 | struct net_device *dev = pci_get_drvdata(pdev); |
5648 | struct airo_info *ai = dev->priv; | 5655 | struct airo_info *ai = dev->priv; |
5649 | Resp rsp; | ||
5650 | pci_power_t prev_state = pdev->current_state; | 5656 | pci_power_t prev_state = pdev->current_state; |
5651 | 5657 | ||
5652 | pci_set_power_state(pdev, PCI_D0); | 5658 | pci_set_power_state(pdev, PCI_D0); |
@@ -5679,7 +5685,7 @@ static int airo_pci_resume(struct pci_dev *pdev) | |||
5679 | ai->APList = NULL; | 5685 | ai->APList = NULL; |
5680 | } | 5686 | } |
5681 | writeConfigRid(ai, 0); | 5687 | writeConfigRid(ai, 0); |
5682 | enable_MAC(ai, &rsp, 0); | 5688 | enable_MAC(ai, 0); |
5683 | ai->power = PMSG_ON; | 5689 | ai->power = PMSG_ON; |
5684 | netif_device_attach(dev); | 5690 | netif_device_attach(dev); |
5685 | netif_wake_queue(dev); | 5691 | netif_wake_queue(dev); |
@@ -5903,7 +5909,6 @@ static int airo_set_essid(struct net_device *dev, | |||
5903 | char *extra) | 5909 | char *extra) |
5904 | { | 5910 | { |
5905 | struct airo_info *local = dev->priv; | 5911 | struct airo_info *local = dev->priv; |
5906 | Resp rsp; | ||
5907 | SsidRid SSID_rid; /* SSIDs */ | 5912 | SsidRid SSID_rid; /* SSIDs */ |
5908 | 5913 | ||
5909 | /* Reload the list of current SSID */ | 5914 | /* Reload the list of current SSID */ |
@@ -5935,7 +5940,7 @@ static int airo_set_essid(struct net_device *dev, | |||
5935 | /* Write it to the card */ | 5940 | /* Write it to the card */ |
5936 | disable_MAC(local, 1); | 5941 | disable_MAC(local, 1); |
5937 | writeSsidRid(local, &SSID_rid, 1); | 5942 | writeSsidRid(local, &SSID_rid, 1); |
5938 | enable_MAC(local, &rsp, 1); | 5943 | enable_MAC(local, 1); |
5939 | 5944 | ||
5940 | return 0; | 5945 | return 0; |
5941 | } | 5946 | } |
@@ -6000,7 +6005,7 @@ static int airo_set_wap(struct net_device *dev, | |||
6000 | memcpy(APList_rid.ap[0], awrq->sa_data, ETH_ALEN); | 6005 | memcpy(APList_rid.ap[0], awrq->sa_data, ETH_ALEN); |
6001 | disable_MAC(local, 1); | 6006 | disable_MAC(local, 1); |
6002 | writeAPListRid(local, &APList_rid, 1); | 6007 | writeAPListRid(local, &APList_rid, 1); |
6003 | enable_MAC(local, &rsp, 1); | 6008 | enable_MAC(local, 1); |
6004 | } | 6009 | } |
6005 | return 0; | 6010 | return 0; |
6006 | } | 6011 | } |
@@ -7454,7 +7459,6 @@ static int airo_config_commit(struct net_device *dev, | |||
7454 | char *extra) /* NULL */ | 7459 | char *extra) /* NULL */ |
7455 | { | 7460 | { |
7456 | struct airo_info *local = dev->priv; | 7461 | struct airo_info *local = dev->priv; |
7457 | Resp rsp; | ||
7458 | 7462 | ||
7459 | if (!test_bit (FLAG_COMMIT, &local->flags)) | 7463 | if (!test_bit (FLAG_COMMIT, &local->flags)) |
7460 | return 0; | 7464 | return 0; |
@@ -7479,7 +7483,7 @@ static int airo_config_commit(struct net_device *dev, | |||
7479 | if (down_interruptible(&local->sem)) | 7483 | if (down_interruptible(&local->sem)) |
7480 | return -ERESTARTSYS; | 7484 | return -ERESTARTSYS; |
7481 | writeConfigRid(local, 0); | 7485 | writeConfigRid(local, 0); |
7482 | enable_MAC(local, &rsp, 0); | 7486 | enable_MAC(local, 0); |
7483 | if (test_bit (FLAG_RESET, &local->flags)) | 7487 | if (test_bit (FLAG_RESET, &local->flags)) |
7484 | airo_set_promisc(local); | 7488 | airo_set_promisc(local); |
7485 | else | 7489 | else |
@@ -7746,7 +7750,6 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { | |||
7746 | unsigned char *iobuf; | 7750 | unsigned char *iobuf; |
7747 | int len; | 7751 | int len; |
7748 | struct airo_info *ai = dev->priv; | 7752 | struct airo_info *ai = dev->priv; |
7749 | Resp rsp; | ||
7750 | 7753 | ||
7751 | if (test_bit(FLAG_FLASHING, &ai->flags)) | 7754 | if (test_bit(FLAG_FLASHING, &ai->flags)) |
7752 | return -EIO; | 7755 | return -EIO; |
@@ -7758,7 +7761,7 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { | |||
7758 | if (test_bit(FLAG_COMMIT, &ai->flags)) { | 7761 | if (test_bit(FLAG_COMMIT, &ai->flags)) { |
7759 | disable_MAC (ai, 1); | 7762 | disable_MAC (ai, 1); |
7760 | writeConfigRid (ai, 1); | 7763 | writeConfigRid (ai, 1); |
7761 | enable_MAC (ai, &rsp, 1); | 7764 | enable_MAC(ai, 1); |
7762 | } | 7765 | } |
7763 | break; | 7766 | break; |
7764 | case AIROGSLIST: ridcode = RID_SSID; break; | 7767 | case AIROGSLIST: ridcode = RID_SSID; break; |
@@ -7815,7 +7818,6 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { | |||
7815 | struct airo_info *ai = dev->priv; | 7818 | struct airo_info *ai = dev->priv; |
7816 | int ridcode; | 7819 | int ridcode; |
7817 | int enabled; | 7820 | int enabled; |
7818 | Resp rsp; | ||
7819 | static int (* writer)(struct airo_info *, u16 rid, const void *, int, int); | 7821 | static int (* writer)(struct airo_info *, u16 rid, const void *, int, int); |
7820 | unsigned char *iobuf; | 7822 | unsigned char *iobuf; |
7821 | 7823 | ||
@@ -7849,7 +7851,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { | |||
7849 | * same with MAC off | 7851 | * same with MAC off |
7850 | */ | 7852 | */ |
7851 | case AIROPMACON: | 7853 | case AIROPMACON: |
7852 | if (enable_MAC(ai, &rsp, 1) != 0) | 7854 | if (enable_MAC(ai, 1) != 0) |
7853 | return -EIO; | 7855 | return -EIO; |
7854 | return 0; | 7856 | return 0; |
7855 | 7857 | ||