diff options
author | tmm <tmm@FreeBSD.org> | 2001-12-21 21:49:57 +0000 |
---|---|---|
committer | tmm <tmm@FreeBSD.org> | 2001-12-21 21:49:57 +0000 |
commit | fe2f3a4e09e1db7afd528deaf26ef80c71e27ad7 (patch) | |
tree | 02cd36993f4b8348653e8837c86459d3c6f87d4a /sys | |
parent | c923af5389b5d85b4b6260f2468260c67a7d7799 (diff) | |
download | FreeBSD-src-fe2f3a4e09e1db7afd528deaf26ef80c71e27ad7.zip FreeBSD-src-fe2f3a4e09e1db7afd528deaf26ef80c71e27ad7.tar.gz |
Use the new resource_list_print_type() function to print resource list
contents, and the new __BUS_ACCESSOR macro to construct the accessor
functions.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/pci.c | 37 | ||||
-rw-r--r-- | sys/dev/pci/pcivar.h | 16 |
2 files changed, 5 insertions, 48 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 692a483..2897f22 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -78,9 +78,6 @@ static void pci_add_resources(device_t pcib, int b, int s, int f, device_t dev); static void pci_add_children(device_t dev, int busno); static int pci_probe(device_t dev); -static int pci_print_resources(struct resource_list *rl, - const char *name, int type, - const char *format); static int pci_print_child(device_t dev, device_t child); static void pci_probe_nomatch(device_t dev, device_t child); static int pci_describe_parse_line(char **ptr, int *vendor, @@ -834,34 +831,6 @@ pci_probe(device_t dev) } static int -pci_print_resources(struct resource_list *rl, const char *name, int type, - const char *format) -{ - struct resource_list_entry *rle; - int printed, retval; - - printed = 0; - retval = 0; - /* Yes, this is kinda cheating */ - SLIST_FOREACH(rle, rl, link) { - if (rle->type == type) { - if (printed == 0) - retval += printf(" %s ", name); - else if (printed > 0) - retval += printf(","); - printed++; - retval += printf(format, rle->start); - if (rle->count > 1) { - retval += printf("-"); - retval += printf(format, rle->start + - rle->count - 1); - } - } - } - return retval; -} - -static int pci_print_child(device_t dev, device_t child) { struct pci_devinfo *dinfo; @@ -875,9 +844,9 @@ pci_print_child(device_t dev, device_t child) retval += bus_print_child_header(dev, child); - retval += pci_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx"); - retval += pci_print_resources(rl, "mem", SYS_RES_MEMORY, "%#lx"); - retval += pci_print_resources(rl, "irq", SYS_RES_IRQ, "%ld"); + retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#lx"); + retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx"); + retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld"); if (device_get_flags(dev)) retval += printf(" flags %#x", device_get_flags(dev)); diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 5014d31..3fc06c7 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -182,20 +182,8 @@ enum pci_device_ivars { /* * Simplified accessors for pci devices */ -#define PCI_ACCESSOR(A, B, T) \ - \ -static __inline T pci_get_ ## A(device_t dev) \ -{ \ - uintptr_t v; \ - BUS_READ_IVAR(device_get_parent(dev), dev, PCI_IVAR_ ## B, &v); \ - return (T) v; \ -} \ - \ -static __inline void pci_set_ ## A(device_t dev, T t) \ -{ \ - uintptr_t v = (uintptr_t) t; \ - BUS_WRITE_IVAR(device_get_parent(dev), dev, PCI_IVAR_ ## B, v); \ -} +#define PCI_ACCESSOR(var, ivar, type) \ + __BUS_ACCESSOR(pci, var, PCI, ivar, type) PCI_ACCESSOR(subvendor, SUBVENDOR, u_int16_t) PCI_ACCESSOR(subdevice, SUBDEVICE, u_int16_t) |