Don't use "{ 0 }" to initialize structures, use "{ }"
[madwifi/.git] / ath / if_ath_pci.c
index 828122bd3f322014cf385ce88dfc848f2007a2a8..95069b1be396f88870b6d0dad59e8660944445d5 100644 (file)
@@ -42,7 +42,7 @@
 #define        EXPORT_SYMTAB
 #endif
 
-#ifndef AUTOCONF_INCLUDED
+#if !defined(AUTOCONF_INCLUDED) && !defined(CONFIG_LOCALVERSION)
 #include <linux/config.h>
 #endif
 #include <linux/version.h>
@@ -80,6 +80,15 @@ struct ath_pci_softc {
 #endif
 };
 
+/*
+ * Module glue.
+ */
+#include "release.h"
+static char *version = RELEASE_VERSION;
+static char *dev_info = "ath_pci";
+
+#include <linux/ethtool.h>
+
 /*
  * User a static table of PCI IDs for now.  While this is the
  * "new way" to do things, we may want to switch back to having
@@ -104,8 +113,13 @@ static struct pci_device_id ath_pci_id_table[] __devinitdata = {
        { 0x168c, 0x001d, PCI_ANY_ID, PCI_ANY_ID }, /* PCI Express ???  */
        { 0x168c, 0x0023, PCI_ANY_ID, PCI_ANY_ID },
        { 0x168c, 0x0024, PCI_ANY_ID, PCI_ANY_ID },
+       { 0x168c, 0x0027, PCI_ANY_ID, PCI_ANY_ID },
+#if 0 /* PCI based AR9280 doesn't work yet */
+       { 0x168c, 0x0029, PCI_ANY_ID, PCI_ANY_ID }, /* AR9280 PCI */
+#endif
+       { 0x168c, 0x002a, PCI_ANY_ID, PCI_ANY_ID }, /* AR9280 PCI Express */
        { 0x168c, 0x9013, PCI_ANY_ID, PCI_ANY_ID }, /* sonicwall */
-       { }
+       { }
 };
 
 static u16 ath_devidmap[][2] = {
@@ -115,7 +129,7 @@ static u16 ath_devidmap[][2] = {
 static int
 ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
-       unsigned long phymem;
+       resource_size_t phymem;
        void __iomem *mem;
        struct ath_pci_softc *sc;
        struct net_device *dev;
@@ -130,7 +144,7 @@ ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
        /* XXX 32-bit addressing only */
        if (pci_set_dma_mask(pdev, 0xffffffff)) {
-               printk(KERN_ERR "ath_pci: 32-bit DMA not available\n");
+               printk(KERN_ERR "%s: 32-bit DMA not available\n", dev_info);
                goto bad;
        }
 
@@ -155,7 +169,7 @@ ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
         * set it to the value used by other systems.  It may be worth
         * tweaking this setting more.
         */
-       pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xa8);
+       pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x60);
 
        pci_set_master(pdev);
 
@@ -171,22 +185,22 @@ ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
        phymem = pci_resource_start(pdev, 0);
        if (!request_mem_region(phymem, pci_resource_len(pdev, 0), "ath")) {
-               printk(KERN_ERR "ath_pci: cannot reserve PCI memory region\n");
+               printk(KERN_ERR "%s: cannot reserve PCI memory region\n", dev_info);
                goto bad;
        }
 
        mem = ioremap(phymem, pci_resource_len(pdev, 0));
        if (!mem) {
-               printk(KERN_ERR "ath_pci: cannot remap PCI memory region\n") ;
+               printk(KERN_ERR "%s: cannot remap PCI memory region\n", dev_info);
                goto bad1;
        }
 
        dev = alloc_netdev(sizeof(struct ath_pci_softc), "wifi%d", ether_setup);
        if (dev == NULL) {
-               printk(KERN_ERR "ath_pci: no memory for device state\n");
+               printk(KERN_ERR "%s: no memory for device state\n", dev_info);
                goto bad2;
        }
-       sc = dev->priv;
+       sc = netdev_priv(dev);
        sc->aps_sc.sc_dev = dev;
        sc->aps_sc.sc_iobase = mem;
 
@@ -197,31 +211,22 @@ ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        sc->aps_sc.sc_invalid = 1;
 
        dev->irq = pdev->irq;
-       /*
-        * Don't leave arp type as ARPHRD_ETHER as this is no eth device
-        */
-       dev->type = ARPHRD_IEEE80211;
 
        SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
 
-       sc->aps_sc.sc_bdev = (void *) pdev;
+       sc->aps_sc.sc_bdev = (void *)pdev;
 
        pci_set_drvdata(pdev, dev);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
        if (request_irq(dev->irq, ath_intr, IRQF_SHARED, dev->name, dev)) {
-#else
-       if (request_irq(dev->irq, ath_intr, SA_SHIRQ, dev->name, dev)) {
-#endif
-
                printk(KERN_WARNING "%s: request_irq failed\n", dev->name);
                goto bad3;
        }
 
        /* looking for device type from broken device id */
        vdevice = id->device;
-       for (i = 0; i < (sizeof(ath_devidmap) / sizeof(ath_devidmap[0])); i++) {
+       for (i = 0; i < ARRAY_SIZE(ath_devidmap); i++) {
                if (id->device == ath_devidmap[i][0]) {
                        vdevice = ath_devidmap[i][1];
                        break;
@@ -248,8 +253,12 @@ ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
                goto bad4;
 
        athname = ath_hal_probe(id->vendor, vdevice);
-       printk(KERN_INFO "%s: %s: mem=0x%lx, irq=%d\n",
-               dev->name, athname ? athname : "Atheros ???", phymem, dev->irq);
+       printk(KERN_INFO "%s: %s: %s: mem=0x%llx, irq=%d\n",
+               dev_info, dev->name, athname ? athname : "Atheros ???",
+               (unsigned long long)phymem, dev->irq);
+
+       if (vdevice == AR5416_DEVID_PCIE)
+               sc->aps_sc.sc_dmasize_stomp = 1;
 
        /* ready to process interrupts */
        sc->aps_sc.sc_invalid = 0;
@@ -272,7 +281,7 @@ static void
 ath_pci_remove(struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
-       struct ath_pci_softc *sc = dev->priv;
+       struct ath_pci_softc *sc = netdev_priv(dev);
 
        ath_detach(dev);
        if (dev->irq)
@@ -290,7 +299,7 @@ ath_pci_suspend(struct pci_dev *pdev, pm_message_t state)
        struct net_device *dev = pci_get_drvdata(pdev);
 
        ath_suspend(dev);
-       PCI_SAVE_STATE(pdev, ((struct ath_pci_softc *)dev->priv)->aps_pmstate);
+       PCI_SAVE_STATE(pdev, ((struct ath_pci_softc *)netdev_priv(dev))->aps_pmstate);
        pci_disable_device(pdev);
        return pci_set_power_state(pdev, PCI_D3hot);
 }
@@ -307,7 +316,7 @@ ath_pci_resume(struct pci_dev *pdev)
                return err;
 
        /* XXX - Should this return nonzero on fail? */
-       PCI_RESTORE_STATE(pdev, ((struct ath_pci_softc *)dev->priv)->aps_pmstate);
+       PCI_RESTORE_STATE(pdev, ((struct ath_pci_softc *)netdev_priv(dev))->aps_pmstate);
 
        err = pci_enable_device(pdev);
        if (err)
@@ -332,7 +341,7 @@ ath_pci_resume(struct pci_dev *pdev)
 
 MODULE_DEVICE_TABLE(pci, ath_pci_id_table);
 
-static struct pci_driver ath_pci_drv_id = {
+static struct pci_driver ath_pci_driver = {
        .name           = "ath_pci",
        .id_table       = ath_pci_id_table,
        .probe          = ath_pci_probe,
@@ -344,16 +353,6 @@ static struct pci_driver ath_pci_drv_id = {
        /* Linux 2.4.6 has save_state and enable_wake that are not used here */
 };
 
-/*
- * Module glue.
- */
-#include "version.h"
-#include "release.h"
-static char *version = ATH_PCI_VERSION " (" RELEASE_VERSION ")";
-static char *dev_info = "ath_pci";
-
-#include <linux/ethtool.h>
-
 int
 ath_ioctl_ethtool(struct ath_softc *sc, int cmd, void __user *addr)
 {
@@ -386,13 +385,12 @@ MODULE_LICENSE("Dual BSD/GPL");
 static int __init
 init_ath_pci(void)
 {
-       printk(KERN_INFO "%s: %s\n", dev_info, version);
-
-       if (pci_register_driver(&ath_pci_drv_id) < 0) {
-               printk("ath_pci: No devices found, driver not installed.\n");
-               return (-ENODEV);
-       }
+       int status;
        ath_sysctl_register();
+       if ((status = pci_register_driver(&ath_pci_driver))) {
+               ath_sysctl_unregister();
+               return (status);
+       }
        return (0);
 }
 module_init(init_ath_pci);
@@ -401,9 +399,7 @@ static void __exit
 exit_ath_pci(void)
 {
        ath_sysctl_unregister();
-       pci_unregister_driver(&ath_pci_drv_id);
-
-       printk(KERN_INFO "%s: driver unloaded\n", dev_info);
+       pci_unregister_driver(&ath_pci_driver);
 }
 module_exit(exit_ath_pci);