ok On 12/01/2011, at 8:44 AM, Mark Kettenis wrote:
> Capability 0x12 is called "SATA". I have a diff to add PCI_CAP_SATA > to pcireg.h, but given the fact that we're in ABI lock, that'll have > to wait. But it is anyhow better to use the number of elements in the > array to decide whether we "know" about a capability or not. > > ok? > > Index: pcidump.c > =================================================================== > RCS file: /cvs/src/usr.sbin/pcidump/pcidump.c,v > retrieving revision 1.26 > diff -u -p -r1.26 pcidump.c > --- pcidump.c 19 Dec 2010 23:23:21 -0000 1.26 > +++ pcidump.c 11 Jan 2011 22:41:28 -0000 > @@ -35,6 +35,10 @@ > > #define PCIDEV "/dev/pci" > > +#ifndef nitems > +#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) > +#endif > + > __dead void usage(void); > void scanpcidomain(void); > int probe(int, int, int); > @@ -86,9 +90,9 @@ const char *pci_capnames[] = { > "AGP8", > "Secure", > "PCI Express", > - "Extended Message Signaled Interrupts (MSI-X)" > + "Extended Message Signaled Interrupts (MSI-X)", > + "SATA" > }; > -#define PCI_CAPNAMES_MAX PCI_CAP_MSIX > > int > main(int argc, char *argv[]) > @@ -337,7 +341,7 @@ dump_caplist(int bus, int dev, int func, > return; > cap = PCI_CAPLIST_CAP(reg); > printf("\t0x%04x: Capability 0x%02x: ", ptr, cap); > - if (cap > PCI_CAPNAMES_MAX) > + if (cap > nitems(pci_capnames)) > cap = 0; > printf("%s\n", pci_capnames[cap]); > if (cap == PCI_CAP_PCIEXPRESS)