fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / net / wireless / prism54 / islpci_dev.c
index 650f86a..f057fd9 100644 (file)
@@ -1,5 +1,4 @@
 /*
- *  
  *  Copyright (C) 2002 Intersil Americas Inc.
  *  Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
  *  Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
@@ -19,7 +18,6 @@
  *
  */
 
-#include <linux/version.h>
 #include <linux/module.h>
 
 #include <linux/netdevice.h>
@@ -44,6 +42,7 @@
 
 static int prism54_bring_down(islpci_private *);
 static int islpci_alloc_memory(islpci_private *);
+static struct net_device_stats *islpci_statistics(struct net_device *);
 
 /* Temporary dummy MAC address to use until firmware is loaded.
  * The idea there is that some tools (such as nameif) may query
@@ -52,7 +51,7 @@ static int islpci_alloc_memory(islpci_private *);
  * Of course, this is not the final/real MAC address. It doesn't
  * matter, as you are suppose to be able to change it anytime via
  * ndev->set_mac_address. Jean II */
-const unsigned char    dummy_mac[6] = { 0x00, 0x30, 0xB4, 0x00, 0x00, 0x00 };
+static const unsigned char     dummy_mac[6] = { 0x00, 0x30, 0xB4, 0x00, 0x00, 0x00 };
 
 static int
 isl_upload_firmware(islpci_private *priv)
@@ -105,7 +104,7 @@ isl_upload_firmware(islpci_private *priv)
                               "%s: firmware '%s' size is not multiple of 32bit, aborting!\n",
                               "prism54", priv->firmware);
                        release_firmware(fw_entry);
-                       return EILSEQ; /* Illegal byte sequence  */;
+                       return -EILSEQ; /* Illegal byte sequence  */;
                }
 
                while (fw_len > 0) {
@@ -142,6 +141,10 @@ isl_upload_firmware(islpci_private *priv)
 
                BUG_ON(fw_len != 0);
 
+               /* Firmware version is at offset 40 (also for "newmac") */
+               printk(KERN_DEBUG "%s: firmware version: %.8s\n",
+                      priv->ndev->name, fw_entry->data + 40);
+
                release_firmware(fw_entry);
        }
 
@@ -178,7 +181,7 @@ isl_upload_firmware(islpci_private *priv)
 ******************************************************************************/
 
 irqreturn_t
-islpci_interrupt(int irq, void *config, struct pt_regs *regs)
+islpci_interrupt(int irq, void *config)
 {
        u32 reg;
        islpci_private *priv = config;
@@ -375,8 +378,6 @@ islpci_open(struct net_device *ndev)
        u32 rc;
        islpci_private *priv = netdev_priv(ndev);
 
-       printk(KERN_DEBUG "%s: islpci_open()\n", ndev->name);
-
        /* reset data structures, upload firmware and reset device */
        rc = islpci_reset(priv,1);
        if (rc) {
@@ -411,13 +412,13 @@ prism54_bring_down(islpci_private *priv)
        islpci_set_state(priv, PRV_STATE_PREBOOT);
 
        /* disable all device interrupts in case they weren't */
-       isl38xx_disable_interrupts(priv->device_base);  
+       isl38xx_disable_interrupts(priv->device_base);
 
        /* For safety reasons, we may want to ensure that no DMA transfer is
         * currently in progress by emptying the TX and RX queues. */
 
        /* wait until interrupts have finished executing on other CPUs */
-       prism54_synchronize_irq(priv->pdev->irq);
+       synchronize_irq(priv->pdev->irq);
 
        reg = readl(device_base + ISL38XX_CTRL_STAT_REG);
        reg &= ~(ISL38XX_CTRL_STAT_RESET | ISL38XX_CTRL_STAT_RAMBOOT);
@@ -436,8 +437,7 @@ prism54_bring_down(islpci_private *priv)
        wmb();
 
        /* wait a while for the device to reset */
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(50*HZ/1000);
+       schedule_timeout_uninterruptible(msecs_to_jiffies(50));
 
        return 0;
 }
@@ -462,8 +462,7 @@ islpci_upload_fw(islpci_private *priv)
                return rc;
        }
 
-       printk(KERN_DEBUG
-              "%s: firmware uploaded done, now triggering reset...\n",
+       printk(KERN_DEBUG "%s: firmware upload complete\n",
               priv->ndev->name);
 
        islpci_set_state(priv, PRV_STATE_POSTBOOT);
@@ -480,7 +479,7 @@ islpci_reset_if(islpci_private *priv)
 
        DEFINE_WAIT(wait);
        prepare_to_wait(&priv->reset_done, &wait, TASK_UNINTERRUPTIBLE);
-       
+
        /* now the last step is to reset the interface */
        isl38xx_interface_reset(priv->device_base, priv->device_host_address);
        islpci_set_state(priv, PRV_STATE_PREINIT);
@@ -488,42 +487,49 @@ islpci_reset_if(islpci_private *priv)
         for(count = 0; count < 2 && result; count++) {
                /* The software reset acknowledge needs about 220 msec here.
                 * Be conservative and wait for up to one second. */
-       
-               remaining = schedule_timeout(HZ);
+
+               remaining = schedule_timeout_uninterruptible(HZ);
 
                if(remaining > 0) {
                        result = 0;
                        break;
                }
 
-               /* If we're here it's because our IRQ hasn't yet gone through. 
+               /* If we're here it's because our IRQ hasn't yet gone through.
                 * Retry a bit more...
                 */
-                printk(KERN_ERR "%s: device soft reset timed out\n",
-                      priv->ndev->name);
-
+               printk(KERN_ERR "%s: no 'reset complete' IRQ seen - retrying\n",
+                       priv->ndev->name);
        }
 
        finish_wait(&priv->reset_done, &wait);
 
-       if(result)
+       if (result) {
+               printk(KERN_ERR "%s: interface reset failure\n", priv->ndev->name);
                return result;
+       }
 
        islpci_set_state(priv, PRV_STATE_INIT);
 
        /* Now that the device is 100% up, let's allow
         * for the other interrupts --
-        * NOTE: this is not *yet* true since we've only allowed the 
+        * NOTE: this is not *yet* true since we've only allowed the
         * INIT interrupt on the IRQ line. We can perhaps poll
         * the IRQ line until we know for sure the reset went through */
        isl38xx_enable_common_interrupts(priv->device_base);
 
        down_write(&priv->mib_sem);
-       mgt_commit(priv);
+       result = mgt_commit(priv);
+       if (result) {
+               printk(KERN_ERR "%s: interface reset failure\n", priv->ndev->name);
+               up_write(&priv->mib_sem);
+               return result;
+       }
        up_write(&priv->mib_sem);
 
        islpci_set_state(priv, PRV_STATE_READY);
 
+       printk(KERN_DEBUG "%s: interface reset complete\n", priv->ndev->name);
        return 0;
 }
 
@@ -584,27 +590,27 @@ islpci_reset(islpci_private *priv, int reload_firmware)
        /* now that the data structures are cleaned up, upload
         * firmware and reset interface */
                rc = islpci_upload_fw(priv);
-               if (rc) 
+               if (rc) {
+                       printk(KERN_ERR "%s: islpci_reset: failure\n",
+                               priv->ndev->name);
                        return rc;
+               }
        }
 
        /* finally reset interface */
        rc = islpci_reset_if(priv);
-       if (!rc) /* If successful */
-               return rc;
-       
-       printk(KERN_DEBUG  "prism54: Your card/socket may be faulty, or IRQ line too busy :(\n");
+       if (rc)
+               printk(KERN_ERR "prism54: Your card/socket may be faulty, or IRQ line too busy :(\n");
        return rc;
-
 }
 
-struct net_device_stats *
+static struct net_device_stats *
 islpci_statistics(struct net_device *ndev)
 {
        islpci_private *priv = netdev_priv(ndev);
 
 #if VERBOSE > SHOW_ERROR_MESSAGES
-       DEBUG(SHOW_FUNCTION_CALLS, "islpci_statistics \n");
+       DEBUG(SHOW_FUNCTION_CALLS, "islpci_statistics\n");
 #endif
 
        return &priv->statistics;
@@ -708,8 +714,8 @@ islpci_alloc_memory(islpci_private *priv)
        }
 
        prism54_acl_init(&priv->acl);
-       prism54_wpa_ie_init(priv);
-       if (mgt_init(priv)) 
+       prism54_wpa_bss_ie_init(priv);
+       if (mgt_init(priv))
                goto out_free;
 
        return 0;
@@ -746,8 +752,7 @@ islpci_free_memory(islpci_private *priv)
                        pci_unmap_single(priv->pdev, buf->pci_addr,
                                         buf->size, PCI_DMA_FROMDEVICE);
                buf->pci_addr = 0;
-               if (buf->mem)
-                       kfree(buf->mem);
+               kfree(buf->mem);
                buf->size = 0;
                buf->mem = NULL;
         }
@@ -768,7 +773,7 @@ islpci_free_memory(islpci_private *priv)
 
        /* Free the acces control list and the WPA list */
        prism54_acl_clean(&priv->acl);
-       prism54_wpa_ie_clean(priv);
+       prism54_wpa_bss_ie_clean(priv);
        mgt_clean(priv);
 
        return 0;
@@ -805,7 +810,6 @@ islpci_setup(struct pci_dev *pdev)
        ndev->open = &islpci_open;
        ndev->stop = &islpci_close;
        ndev->get_stats = &islpci_statistics;
-       ndev->get_wireless_stats = &prism54_get_wireless_stats;
        ndev->do_ioctl = &prism54_ioctl;
        ndev->wireless_handlers =
            (struct iw_handler_def *) &prism54_handler_def;
@@ -830,6 +834,10 @@ islpci_setup(struct pci_dev *pdev)
        priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR) ?
                priv->monitor_type : ARPHRD_ETHER;
 
+       /* Add pointers to enable iwspy support. */
+       priv->wireless_data.spy_data = &priv->spy_data;
+       ndev->wireless_data = &priv->wireless_data;
+
        /* save the start and end address of the PCI memory area */
        ndev->mem_start = (unsigned long) priv->device_base;
        ndev->mem_end = ndev->mem_start + ISL38XX_PCI_MEM_SIZE;
@@ -852,11 +860,10 @@ islpci_setup(struct pci_dev *pdev)
        priv->state_off = 1;
 
        /* initialize workqueue's */
-       INIT_WORK(&priv->stats_work,
-                 (void (*)(void *)) prism54_update_stats, priv);
+       INIT_WORK(&priv->stats_work, prism54_update_stats);
        priv->stats_timestamp = 0;
 
-       INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake, priv);
+       INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake);
        priv->reset_task_pending = 0;
 
        /* allocate various memory areas */