From: Sepherosa Ziehau Date: Sun, 28 Dec 2008 03:37:49 +0000 (+0800) Subject: Add PCICAP_{ID,NEXTPTR} to avoid using magic number X-Git-Tag: v2.3.0~193^2~7 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/2f3ceba1445b387358be826c86fd408278857a37 Add PCICAP_{ID,NEXTPTR} to avoid using magic number Obtained-from: FreeBSD --- diff --git a/sys/bus/pci/pci.c b/sys/bus/pci/pci.c index f8b06227b2..721b25899e 100644 --- a/sys/bus/pci/pci.c +++ b/sys/bus/pci/pci.c @@ -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 diff --git a/sys/bus/pci/pcireg.h b/sys/bus/pci/pcireg.h index 9519943682..8942145981 100644 --- a/sys/bus/pci/pcireg.h +++ b/sys/bus/pci/pcireg.h @@ -87,6 +87,10 @@ #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 */