Add PCICAP_{ID,NEXTPTR} to avoid using magic number
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 28 Dec 2008 03:37:49 +0000 (11:37 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 28 Dec 2008 03:45:41 +0000 (11:45 +0800)
Obtained-from: FreeBSD

sys/bus/pci/pci.c
sys/bus/pci/pcireg.h

index f8b0622..721b258 100644 (file)
@@ -619,7 +619,7 @@ pci_read_capabilities(device_t pcib, pcicfgregs *cfg)
                int ptr = nextptr;
 
                /* Process this entry */
-               switch (REG(ptr, 1)) {
+               switch (REG(ptr + PCICAP_ID, 1)) {
                case PCIY_PMG:          /* PCI power management */
                        pci_read_cap_pmgt(pcib, ptr, cfg);
                        break;
@@ -637,7 +637,7 @@ pci_read_capabilities(device_t pcib, pcicfgregs *cfg)
                }
 
                /* Find the next entry */
-               nextptr = REG(ptr + 1, 1);
+               nextptr = REG(ptr + PCICAP_NEXTPTR, 1);
        }
 
 #undef REG
index 9519943..8942145 100644 (file)
 #define PCIM_MFDEV     0x80
 #define PCIR_BIST      0x0f
 
+/* Capability Register Offsets */
+#define PCICAP_ID      0x0
+#define PCICAP_NEXTPTR 0x1
+
 /* Capability Identification Numbers */
 #define PCIY_PMG        0x01    /* PCI Power Management */
 #define PCIY_AGP        0x02    /* AGP */