Since we have a table for each device anyway, we can also use it to
authorJoerg Sonnenberger <joerg@dragonflybsd.org>
Sat, 30 Jul 2005 18:15:18 +0000 (18:15 +0000)
committerJoerg Sonnenberger <joerg@dragonflybsd.org>
Sat, 30 Jul 2005 18:15:18 +0000 (18:15 +0000)
describe the default RID to use.

Suggestion-from: me
Submitted-by: Sepherosa Ziehau <sepherosa@gmail.com>
sys/dev/netif/an/if_an_pci.c

index b9824b6..16788eb 100644 (file)
@@ -30,7 +30,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/an/if_an_pci.c,v 1.2.2.8 2003/02/11 03:32:48 ambrisko Exp $
- * $DragonFly: src/sys/dev/netif/an/if_an_pci.c,v 1.15 2005/07/28 16:33:25 joerg Exp $
+ * $DragonFly: src/sys/dev/netif/an/if_an_pci.c,v 1.16 2005/07/30 18:15:18 joerg Exp $
  */
 
 /*
 #include "if_anreg.h"
 
 struct an_type {
-       u_int16_t               an_vid;
-       u_int16_t               an_did;
+       uint16_t                 an_vid;
+       uint16_t                 an_did;
+       int                      an_port_rid;
        const char              *an_name;
 };
 
-#define AN_PCI_LOIO            0x18    /* Aironet iobase */
-
 static const struct an_type an_devs[] = {
        { PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_350,
-         "Cisco Aironet 350 Series" },
+         PCIR_BAR(2), "Cisco Aironet 350 Series" },
        { PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_PC4500,
-         "Aironet PCI4500" },
+         PCIR_BAR(2), "Aironet PCI4500" },
        { PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_PC4800,
-         "Aironet PCI4800" },
+         PCIR_BAR(2), "Aironet PCI4800" },
        { PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_PC4xxx,
-         "Aironet PCI4500/PCI4800" },
+         PCIR_BAR(2), "Aironet PCI4500/PCI4800" },
        { PCI_VENDOR_AIRONET, PCI_PRODUCT_AIRONET_MPI350,
-         "Cisco Aironet MPI350" },
-       { 0, 0, NULL }
+         PCIR_BAR(0), "Cisco Aironet MPI350" },
+       { 0, 0, 0, NULL }
 };
 
 static int an_probe_pci                (device_t);
@@ -123,6 +122,14 @@ an_probe_pci(device_t dev)
        did = pci_get_device(dev);
        for (t = an_devs; t->an_name != NULL; ++t) {
                if (vid == t->an_vid && did == t->an_did) {
+                       struct an_softc *sc;
+
+                       sc = device_get_softc(dev);
+                       sc->port_rid = t->an_port_rid;
+                       if (vid == PCI_VENDOR_AIRONET &&
+                           did == PCI_PRODUCT_AIRONET_MPI350)
+                               sc->mpi350 = 1;
+
                        device_set_desc(dev, t->an_name);
                        return(0);
                }
@@ -140,15 +147,7 @@ an_attach_pci(dev)
        sc = device_get_softc(dev);
        flags = device_get_flags(dev);
 
-       if (pci_get_vendor(dev) == PCI_VENDOR_AIRONET &&
-           pci_get_device(dev) == PCI_PRODUCT_AIRONET_MPI350) {
-               sc->mpi350 = 1;
-               sc->port_rid = PCIR_MAPS;
-       } else {
-               sc->port_rid = AN_PCI_LOIO;
-       }
        error = an_alloc_port(dev, sc->port_rid, 1);
-
        if (error) {
                device_printf(dev, "couldn't map ports\n");
                goto fail;