pci: Narrow the scope of recently-added PCI_IOV #ifdefs

Push the #ifdefs down into the function body instead of defining
functions conditionally for ease of readability.  These aren't
critical paths, so one extra branch in the !PCI_IOV case is not a big
deal.

Requested by:	jrtc27
Differential Revision:	https://reviews.freebsd.org/D45877
This commit is contained in:
John Baldwin 2024-08-08 15:05:23 -04:00
parent d8ff42e816
commit 971c9f57d7

View file

@ -164,18 +164,12 @@ static device_method_t pci_methods[] = {
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
DEVMETHOD(bus_delete_resource, pci_delete_resource),
DEVMETHOD(bus_alloc_resource, pci_alloc_resource),
#ifdef PCI_IOV
DEVMETHOD(bus_adjust_resource, pci_adjust_resource),
#else
DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
#endif
DEVMETHOD(bus_release_resource, pci_release_resource),
DEVMETHOD(bus_activate_resource, pci_activate_resource),
DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
#ifdef PCI_IOV
DEVMETHOD(bus_map_resource, pci_map_resource),
DEVMETHOD(bus_unmap_resource, pci_unmap_resource),
#endif
DEVMETHOD(bus_child_deleted, pci_child_deleted),
DEVMETHOD(bus_child_detached, pci_child_detached),
DEVMETHOD(bus_child_pnpinfo, pci_child_pnpinfo_method),
@ -5754,11 +5748,11 @@ pci_deactivate_resource(device_t dev, device_t child, struct resource *r)
return (0);
}
#ifdef PCI_IOV
int
pci_adjust_resource(device_t dev, device_t child, struct resource *r,
rman_res_t start, rman_res_t end)
{
#ifdef PCI_IOV
struct pci_devinfo *dinfo;
if (device_get_parent(child) != dev)
@ -5778,6 +5772,7 @@ pci_adjust_resource(device_t dev, device_t child, struct resource *r,
/* Fall through for other types of resource allocations. */
}
#endif
return (bus_generic_adjust_resource(dev, child, r, start, end));
}
@ -5786,6 +5781,7 @@ int
pci_map_resource(device_t dev, device_t child, struct resource *r,
struct resource_map_request *argsp, struct resource_map *map)
{
#ifdef PCI_IOV
struct pci_devinfo *dinfo;
if (device_get_parent(child) != dev)
@ -5805,6 +5801,7 @@ pci_map_resource(device_t dev, device_t child, struct resource *r,
/* Fall through for other types of resource allocations. */
}
#endif
return (bus_generic_map_resource(dev, child, r, argsp, map));
}
@ -5813,6 +5810,7 @@ int
pci_unmap_resource(device_t dev, device_t child, struct resource *r,
struct resource_map *map)
{
#ifdef PCI_IOV
struct pci_devinfo *dinfo;
if (device_get_parent(child) != dev)
@ -5830,10 +5828,10 @@ pci_unmap_resource(device_t dev, device_t child, struct resource *r,
/* Fall through for other types of resource allocations. */
}
#endif
return (bus_generic_unmap_resource(dev, child, r, map));
}
#endif
void
pci_child_deleted(device_t dev, device_t child)