git: a27c361e0503 - stable/14 - pci: Narrow the scope of recently-added PCI_IOV #ifdefs

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 27 Feb 2025 14:17:32 UTC
The branch stable/14 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=a27c361e050331cd50d5fc1a7230fce62eee536c

commit a27c361e050331cd50d5fc1a7230fce62eee536c
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-08-08 19:05:23 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-02-27 13:09:24 +0000

    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
    
    (cherry picked from commit 971c9f57d7e6b55161fecc008e19f00ccaba8060)
---
 sys/dev/pci/pci.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 4be3210840fc..b40a352a4818 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -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),
@@ -5784,11 +5778,11 @@ pci_deactivate_resource(device_t dev, device_t child, int type,
 	return (0);
 }
 
-#ifdef PCI_IOV
 int
 pci_adjust_resource(device_t dev, device_t child, int type, struct resource *r,
     rman_res_t start, rman_res_t end)
 {
+#ifdef PCI_IOV
 	struct pci_devinfo *dinfo;
 
 	if (device_get_parent(child) != dev)
@@ -5808,6 +5802,7 @@ pci_adjust_resource(device_t dev, device_t child, int type, struct resource *r,
 
 		/* Fall through for other types of resource allocations. */
 	}
+#endif
 
 	return (bus_generic_adjust_resource(dev, child, type, r, start, end));
 }
@@ -5816,6 +5811,7 @@ int
 pci_map_resource(device_t dev, device_t child, int type, 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)
@@ -5835,6 +5831,7 @@ pci_map_resource(device_t dev, device_t child, int type, struct resource *r,
 
 		/* Fall through for other types of resource allocations. */
 	}
+#endif
 
 	return (bus_generic_map_resource(dev, child, type, r, argsp, map));
 }
@@ -5843,6 +5840,7 @@ int
 pci_unmap_resource(device_t dev, device_t child, int type, struct resource *r,
     struct resource_map *map)
 {
+#ifdef PCI_IOV
 	struct pci_devinfo *dinfo;
 
 	if (device_get_parent(child) != dev)
@@ -5860,10 +5858,10 @@ pci_unmap_resource(device_t dev, device_t child, int type, struct resource *r,
 
 		/* Fall through for other types of resource allocations. */
 	}
+#endif
 
 	return (bus_generic_unmap_resource(dev, child, type, r, map));
 }
-#endif
 
 void
 pci_child_deleted(device_t dev, device_t child)