summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2011-01-12 20:17:57 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2011-01-12 20:17:57 +0000
commite01e89157a60864a820df06ba2ca354db25cdc64 (patch)
tree1d928677fe2c02757c2631d3da3a2b063b1dd833 /usr.sbin
parent62998ae97921160faa55de1dc1d7715c82cf2ed0 (diff)
Add SATA capability. Use nitems() to decide if a capability is known or not.
ok krw@, deraadt@, dlg@, jsg@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pcidump/pcidump.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.sbin/pcidump/pcidump.c b/usr.sbin/pcidump/pcidump.c
index 9d9c9499cc7..bcfab605e80 100644
--- a/usr.sbin/pcidump/pcidump.c
+++ b/usr.sbin/pcidump/pcidump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcidump.c,v 1.26 2010/12/19 23:23:21 jmc Exp $ */
+/* $OpenBSD: pcidump.c,v 1.27 2011/01/12 20:17:56 kettenis Exp $ */
/*
* Copyright (c) 2006, 2007 David Gwynne <loki@animata.net>
@@ -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, u_int8_t ptr)
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)