git: 2baed46e85d3 - main - new-bus: Remove the 'rid' and 'type' arguments from BUS_*ACTIVATE_RESOURCE

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 13 Mar 2024 22:13:42 UTC
The branch main has been updated by jhb:

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

commit 2baed46e85d33b1f99e6f96033acc85a9a6fbba4
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-03-13 22:05:54 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-03-13 22:05:54 +0000

    new-bus: Remove the 'rid' and 'type' arguments from BUS_*ACTIVATE_RESOURCE
    
    The public bus_activate/deactivate_resource() API still accepts both
    forms, but the internal kobj methods no longer pass the arguments.
    Implementations which need the rid or type now use rman_get_rid() or
    rman_get_type() to fetch the value from the allocated resource.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D44130
---
 share/man/man9/bus_activate_resource.9 | 24 ++--------------
 sys/arm/arm/nexus.c                    | 16 ++++-------
 sys/arm/mv/mv_pci.c                    | 33 ++++++++--------------
 sys/arm64/arm64/nexus.c                | 26 ++++++++----------
 sys/arm64/cavium/thunder_pcie_pem.c    | 30 ++++++++------------
 sys/dev/acpica/acpi.c                  | 16 ++++-------
 sys/dev/acpica/acpi_pcib_acpi.c        | 25 ++++++++---------
 sys/dev/agp/agp_i810.c                 |  4 +--
 sys/dev/bhnd/bhndb/bhndb.c             | 50 ++++++++++++++--------------------
 sys/dev/bhnd/cores/chipc/chipc.c       | 34 ++++++++++-------------
 sys/dev/bhnd/cores/usb/bhnd_usb.c      | 16 ++++-------
 sys/dev/dpaa/fman.c                    |  7 ++---
 sys/dev/dpaa/fman.h                    |  2 +-
 sys/dev/dpaa2/dpaa2_mc.c               | 20 ++++++--------
 sys/dev/dpaa2/dpaa2_mc.h               |  8 +++---
 sys/dev/exca/exca.c                    | 18 ++++++------
 sys/dev/exca/excavar.h                 |  8 +++---
 sys/dev/fdt/simplebus.c                | 28 ++-----------------
 sys/dev/hyperv/pcib/vmbus_pcib.c       | 18 ++++++------
 sys/dev/ofw/ofw_pcib.c                 | 33 ++++++++--------------
 sys/dev/pccbb/pccbb.c                  | 49 +++++++++++++++------------------
 sys/dev/pccbb/pccbbvar.h               |  4 +--
 sys/dev/pci/pci.c                      | 18 ++++++------
 sys/dev/pci/pci_host_generic.c         | 27 ++++++++----------
 sys/dev/pci/pci_pci.c                  | 18 ++++++------
 sys/dev/pci/pci_private.h              |  8 +++---
 sys/dev/pci/pci_subr.c                 |  4 +--
 sys/dev/pci/pcib_private.h             |  4 +--
 sys/dev/vmd/vmd.c                      | 20 ++++++--------
 sys/kern/bus_if.m                      |  8 ------
 sys/kern/subr_bus.c                    | 45 ++++++++++++++----------------
 sys/powerpc/mpc85xx/lbc.c              | 31 +++++++--------------
 sys/powerpc/powermac/macgpio.c         | 18 ++++++------
 sys/powerpc/powermac/macio.c           | 28 +++++++------------
 sys/powerpc/powermac/uninorth.c        | 25 +++++++----------
 sys/powerpc/psim/iobus.c               | 26 +++++++-----------
 sys/riscv/riscv/nexus.c                | 16 ++++-------
 sys/sys/bus.h                          | 30 ++++++++++----------
 sys/x86/include/legacyvar.h            |  8 +++---
 sys/x86/pci/pci_bus.c                  | 17 ++++++------
 40 files changed, 325 insertions(+), 495 deletions(-)

diff --git a/share/man/man9/bus_activate_resource.9 b/share/man/man9/bus_activate_resource.9
index be878349ab3c..7b87197b8d11 100644
--- a/share/man/man9/bus_activate_resource.9
+++ b/share/man/man9/bus_activate_resource.9
@@ -22,7 +22,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 20, 2016
+.Dd March 13, 2024
 .Dt BUS_ACTIVATE_RESOURCE 9
 .Os
 .Sh NAME
@@ -37,11 +37,11 @@
 .In machine/resource.h
 .Ft int
 .Fo bus_activate_resource
-.Fa "device_t dev" "int type" "int rid" "struct resource *r"
+.Fa "device_t dev" "struct resource *r"
 .Fc
 .Ft int
 .Fo bus_deactivate_resource
-.Fa "device_t dev" "int type" "int rid" "struct resource *r"
+.Fa "device_t dev" "struct resource *r"
 .Fc
 .Sh DESCRIPTION
 These functions activate or deactivate a previously allocated resource.
@@ -58,24 +58,6 @@ The arguments are as follows:
 .It Fa dev
 The device that requests ownership of the resource.
 Before allocation, the resource is owned by the parent bus.
-.It Fa type
-The type of resource you want to allocate.
-It is one of:
-.Pp
-.Bl -tag -width ".Dv SYS_RES_MEMORY" -compact
-.It Dv PCI_RES_BUS
-for PCI bus numbers
-.It Dv SYS_RES_IRQ
-for IRQs
-.It Dv SYS_RES_DRQ
-for ISA DMA lines
-.It Dv SYS_RES_IOPORT
-for I/O ports
-.It Dv SYS_RES_MEMORY
-for I/O memory
-.El
-.It Fa rid
-A pointer to a bus specific handle that identifies the resource being allocated.
 .It Fa r
 A pointer to the
 .Vt "struct resource"
diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c
index 0cb896ce346e..8274a792839d 100644
--- a/sys/arm/arm/nexus.c
+++ b/sys/arm/arm/nexus.c
@@ -305,16 +305,14 @@ nexus_bind_intr(device_t dev, device_t child, struct resource *irq, int cpu)
 #endif
 
 static int
-nexus_activate_resource(device_t bus, device_t child, int type, int rid,
-    struct resource *r)
+nexus_activate_resource(device_t bus, device_t child, struct resource *r)
 {
 	int err;
 
-	switch (type) {
+	switch (rman_get_type(r)) {
 	case SYS_RES_MEMORY:
 	case SYS_RES_IOPORT:
-		return (bus_generic_rman_activate_resource(bus, child, type,
-		    rid, r));
+		return (bus_generic_rman_activate_resource(bus, child, r));
 	case SYS_RES_IRQ:
 		err = rman_activate_resource(r);
 		if (err != 0)
@@ -393,16 +391,14 @@ nexus_unmap_resource(device_t bus, device_t child, struct resource *r,
 }
 
 static int
-nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
-    struct resource *r)
+nexus_deactivate_resource(device_t bus, device_t child, struct resource *r)
 {
 	int error;
 
-	switch (type) {
+	switch (rman_get_type(r)) {
 	case SYS_RES_MEMORY:
 	case SYS_RES_IOPORT:
-		return (bus_generic_rman_deactivate_resource(bus, child, type,
-		    rid, r));
+		return (bus_generic_rman_deactivate_resource(bus, child, r));
 	case SYS_RES_IRQ:
 		error = rman_deactivate_resource(r);
 		if (error)
diff --git a/sys/arm/mv/mv_pci.c b/sys/arm/mv/mv_pci.c
index a8a6d1d50002..a24a71cd4ecf 100644
--- a/sys/arm/mv/mv_pci.c
+++ b/sys/arm/mv/mv_pci.c
@@ -349,10 +349,8 @@ static int mv_pcib_adjust_resource(device_t, device_t, struct resource *,
     rman_res_t, rman_res_t);
 static int mv_pcib_release_resource(device_t, device_t, int, int,
     struct resource *);
-static int mv_pcib_activate_resource(device_t, device_t, int, int,
-    struct resource *r);
-static int mv_pcib_deactivate_resource(device_t, device_t, int, int,
-    struct resource *r);
+static int mv_pcib_activate_resource(device_t, device_t, struct resource *);
+static int mv_pcib_deactivate_resource(device_t, device_t, struct resource *);
 static int mv_pcib_map_resource(device_t, device_t, struct resource *,
     struct resource_map_request *, struct resource_map *);
 static int mv_pcib_unmap_resource(device_t, device_t, struct resource *,
@@ -987,49 +985,42 @@ mv_pcib_release_resource(device_t dev, device_t child, int type, int rid,
 }
 
 static int
-mv_pcib_activate_resource(device_t dev, device_t child, int type, int rid,
-    struct resource *r)
+mv_pcib_activate_resource(device_t dev, device_t child, struct resource *r)
 {
 #ifdef PCI_RES_BUS
 	struct mv_pcib_softc *sc = device_get_softc(dev);
 #endif
 
-	switch (type) {
+	switch (rman_get_type(r)) {
 	case SYS_RES_IOPORT:
 	case SYS_RES_MEMORY:
-		return (bus_generic_rman_activate_resource(dev, child, type,
-		    rid, r));
+		return (bus_generic_rman_activate_resource(dev, child, r));
 #ifdef PCI_RES_BUS
 	case PCI_RES_BUS:
-		return (pci_domain_activate_bus(sc->ap_segment, child, rid, r));
+		return (pci_domain_activate_bus(sc->ap_segment, child, r));
 #endif
 	default:
-		return (bus_generic_activate_resource(dev, child, type, rid,
-		    r));
+		return (bus_generic_activate_resource(dev, child, r));
 	}
 }
 
 static int
-mv_pcib_deactivate_resource(device_t dev, device_t child, int type, int rid,
-    struct resource *r)
+mv_pcib_deactivate_resource(device_t dev, device_t child, struct resource *r)
 {
 #ifdef PCI_RES_BUS
 	struct mv_pcib_softc *sc = device_get_softc(dev);
 #endif
 
-	switch (type) {
+	switch (rman_get_type(r)) {
 	case SYS_RES_IOPORT:
 	case SYS_RES_MEMORY:
-		return (bus_generic_rman_deactivate_resource(dev, child, type,
-		    rid, r));
+		return (bus_generic_rman_deactivate_resource(dev, child, r));
 #ifdef PCI_RES_BUS
 	case PCI_RES_BUS:
-		return (pci_domain_deactivate_bus(sc->ap_segment, child, rid,
-		    r));
+		return (pci_domain_deactivate_bus(sc->ap_segment, child, r));
 #endif
 	default:
-		return (bus_generic_deactivate_resource(dev, child, type, rid,
-		    r));
+		return (bus_generic_deactivate_resource(dev, child, r));
 	}
 }
 
diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c
index ed500ba5ea6d..3e9399384855 100644
--- a/sys/arm64/arm64/nexus.c
+++ b/sys/arm64/arm64/nexus.c
@@ -324,8 +324,8 @@ nexus_get_bus_tag(device_t bus __unused, device_t child __unused)
 }
 
 static int
-nexus_activate_resource_flags(device_t bus, device_t child, int type, int rid,
-    struct resource *r, int flags)
+nexus_activate_resource_flags(device_t bus, device_t child, struct resource *r,
+    int flags)
 {
 	struct resource_map_request args;
 	struct resource_map map;
@@ -337,7 +337,7 @@ nexus_activate_resource_flags(device_t bus, device_t child, int type, int rid,
 	/*
 	 * If this is a memory resource, map it into the kernel.
 	 */
-	switch (type) {
+	switch (rman_get_type(r)) {
 	case SYS_RES_IOPORT:
 	case SYS_RES_MEMORY:
 		if ((rman_get_flags(r) & RF_UNMAPPED) == 0) {
@@ -370,10 +370,9 @@ nexus_activate_resource_flags(device_t bus, device_t child, int type, int rid,
 }
 
 static int
-nexus_activate_resource(device_t dev, device_t child, int type, int rid,
-    struct resource *r)
+nexus_activate_resource(device_t dev, device_t child, struct resource *r)
 {
-	return (nexus_activate_resource_flags(dev, child, type, rid, r, 0));
+	return (nexus_activate_resource_flags(dev, child, r, 0));
 }
 
 static struct resource_list *
@@ -385,16 +384,14 @@ nexus_get_reslist(device_t dev, device_t child)
 }
 
 static int
-nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
-    struct resource *r)
+nexus_deactivate_resource(device_t bus, device_t child, struct resource *r)
 {
 	int error;
 
-	switch (type) {
+	switch (rman_get_type(r)) {
 	case SYS_RES_MEMORY:
 	case SYS_RES_IOPORT:
-		return (bus_generic_rman_deactivate_resource(bus, child, type,
-		    rid, r));
+		return (bus_generic_rman_deactivate_resource(bus, child, r));
 	case SYS_RES_IRQ:
 		error = rman_deactivate_resource(r);
 		if (error)
@@ -500,14 +497,13 @@ nexus_fdt_attach(device_t dev)
 }
 
 static int
-nexus_fdt_activate_resource(device_t bus, device_t child, int type, int rid,
-    struct resource *r)
+nexus_fdt_activate_resource(device_t bus, device_t child, struct resource *r)
 {
 	phandle_t node, parent;
 	int flags;
 
 	flags = 0;
-	switch (type) {
+	switch (rman_get_type(r)) {
 	case SYS_RES_MEMORY:
 	case SYS_RES_IOPORT:
 		/*
@@ -529,7 +525,7 @@ nexus_fdt_activate_resource(device_t bus, device_t child, int type, int rid,
 		break;
 	}
 
-	return (nexus_activate_resource_flags(bus, child, type, rid, r, flags));
+	return (nexus_activate_resource_flags(bus, child, r, flags));
 }
 
 static int
diff --git a/sys/arm64/cavium/thunder_pcie_pem.c b/sys/arm64/cavium/thunder_pcie_pem.c
index b53f70696ff1..f7c3c5ee1c0a 100644
--- a/sys/arm64/cavium/thunder_pcie_pem.c
+++ b/sys/arm64/cavium/thunder_pcie_pem.c
@@ -120,8 +120,7 @@
 
 #define	RID_PEM_SPACE		1
 
-static int thunder_pem_activate_resource(device_t, device_t, int, int,
-    struct resource *);
+static int thunder_pem_activate_resource(device_t, device_t, struct resource *);
 static int thunder_pem_adjust_resource(device_t, device_t,
     struct resource *, rman_res_t, rman_res_t);
 static struct resource * thunder_pem_alloc_resource(device_t, device_t, int,
@@ -134,7 +133,7 @@ static int thunder_pem_map_msi(device_t, device_t, int, uint64_t *, uint32_t *);
 static int thunder_pem_get_id(device_t, device_t, enum pci_id_type,
     uintptr_t *);
 static int thunder_pem_attach(device_t);
-static int thunder_pem_deactivate_resource(device_t, device_t, int, int,
+static int thunder_pem_deactivate_resource(device_t, device_t,
     struct resource *);
 static int thunder_pem_map_resource(device_t, device_t, struct resource *,
     struct resource_map_request *, struct resource_map *);
@@ -254,31 +253,28 @@ thunder_pem_write_ivar(device_t dev, device_t child, int index,
 }
 
 static int
-thunder_pem_activate_resource(device_t dev, device_t child, int type, int rid,
-    struct resource *r)
+thunder_pem_activate_resource(device_t dev, device_t child, struct resource *r)
 {
 #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
 	struct thunder_pem_softc *sc;
 
 	sc = device_get_softc(dev);
 #endif
-	switch (type) {
+	switch (rman_get_type(r)) {
 #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
 	case PCI_RES_BUS:
-		return (pci_domain_activate_bus(sc->id, child, rid, r));
+		return (pci_domain_activate_bus(sc->id, child, r));
 #endif
 	case SYS_RES_MEMORY:
 	case SYS_RES_IOPORT:
-		return (bus_generic_rman_activate_resource(dev, child, type,
-		    rid, r));
+		return (bus_generic_rman_activate_resource(dev, child, r));
 	default:
-		return (bus_generic_activate_resource(dev, child, type, rid,
-		    r));
+		return (bus_generic_activate_resource(dev, child, r));
 	}
 }
 
 static int
-thunder_pem_deactivate_resource(device_t dev, device_t child, int type, int rid,
+thunder_pem_deactivate_resource(device_t dev, device_t child,
     struct resource *r)
 {
 #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
@@ -286,18 +282,16 @@ thunder_pem_deactivate_resource(device_t dev, device_t child, int type, int rid,
 
 	sc = device_get_softc(dev);
 #endif
-	switch (type) {
+	switch (rman_get_type(r)) {
 #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
 	case PCI_RES_BUS:
-		return (pci_domain_deactivate_bus(sc->id, child, rid, r));
+		return (pci_domain_deactivate_bus(sc->id, child, r));
 #endif
 	case SYS_RES_MEMORY:
 	case SYS_RES_IOPORT:
-		return (bus_generic_rman_deactivate_resource(dev, child, type,
-		    rid, r));
+		return (bus_generic_rman_deactivate_resource(dev, child, r));
 	default:
-		return (bus_generic_deactivate_resource(dev, child, type, rid,
-		    r));
+		return (bus_generic_deactivate_resource(dev, child, r));
 	}
 }
 
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index ab34009bf654..df2017e69a86 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -1610,23 +1610,19 @@ acpi_delete_resource(device_t bus, device_t child, int type, int rid)
 }
 
 static int
-acpi_activate_resource(device_t bus, device_t child, int type, int rid,
-    struct resource *r)
+acpi_activate_resource(device_t bus, device_t child, struct resource *r)
 {
 	if (acpi_is_resource_managed(bus, r))
-		return (bus_generic_rman_activate_resource(bus, child, type,
-		    rid, r));
-	return (bus_generic_activate_resource(bus, child, type, rid, r));
+		return (bus_generic_rman_activate_resource(bus, child, r));
+	return (bus_generic_activate_resource(bus, child, r));
 }
 
 static int
-acpi_deactivate_resource(device_t bus, device_t child, int type, int rid,
-    struct resource *r)
+acpi_deactivate_resource(device_t bus, device_t child, struct resource *r)
 {
 	if (acpi_is_resource_managed(bus, r))
-		return (bus_generic_rman_deactivate_resource(bus, child, type,
-		    rid, r));
-	return (bus_generic_deactivate_resource(bus, child, type, rid, r));
+		return (bus_generic_rman_deactivate_resource(bus, child, r));
+	return (bus_generic_deactivate_resource(bus, child, r));
 }
 
 static int
diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c
index 235670076dae..fdf8e84d14e0 100644
--- a/sys/dev/acpica/acpi_pcib_acpi.c
+++ b/sys/dev/acpica/acpi_pcib_acpi.c
@@ -104,11 +104,9 @@ static int		acpi_pcib_acpi_release_resource(device_t dev,
 			    device_t child, int type, int rid,
 			    struct resource *r);
 static int		acpi_pcib_acpi_activate_resource(device_t dev,
-			    device_t child, int type, int rid,
-			    struct resource *r);
+			    device_t child, struct resource *r);
 static int		acpi_pcib_acpi_deactivate_resource(device_t dev,
-			    device_t child, int type, int rid,
-			    struct resource *r);
+			    device_t child, struct resource *r);
 #endif
 #endif
 static int		acpi_pcib_request_feature(device_t pcib, device_t dev,
@@ -773,28 +771,27 @@ acpi_pcib_acpi_release_resource(device_t dev, device_t child, int type, int rid,
 }
 
 int
-acpi_pcib_acpi_activate_resource(device_t dev, device_t child, int type, int rid,
+acpi_pcib_acpi_activate_resource(device_t dev, device_t child,
     struct resource *r)
 {
 	struct acpi_hpcib_softc *sc;
 
 	sc = device_get_softc(dev);
-	if (type == PCI_RES_BUS)
-		return (pci_domain_activate_bus(sc->ap_segment, child, rid, r));
-	return (bus_generic_activate_resource(dev, child, type, rid, r));
+	if (rman_get_type(r) == PCI_RES_BUS)
+		return (pci_domain_activate_bus(sc->ap_segment, child, r));
+	return (bus_generic_activate_resource(dev, child, r));
 }
 
 int
-acpi_pcib_acpi_deactivate_resource(device_t dev, device_t child, int type,
-    int rid, struct resource *r)
+acpi_pcib_acpi_deactivate_resource(device_t dev, device_t child,
+    struct resource *r)
 {
 	struct acpi_hpcib_softc *sc;
 
 	sc = device_get_softc(dev);
-	if (type == PCI_RES_BUS)
-		return (pci_domain_deactivate_bus(sc->ap_segment, child, rid,
-		    r));
-	return (bus_generic_deactivate_resource(dev, child, type, rid, r));
+	if (rman_get_type(r) == PCI_RES_BUS)
+		return (pci_domain_deactivate_bus(sc->ap_segment, child, r));
+	return (bus_generic_deactivate_resource(dev, child, r));
 }
 #endif
 #endif
diff --git a/sys/dev/agp/agp_i810.c b/sys/dev/agp/agp_i810.c
index 6ed04297f6c8..a83189ca7bc8 100644
--- a/sys/dev/agp/agp_i810.c
+++ b/sys/dev/agp/agp_i810.c
@@ -2051,8 +2051,8 @@ agp_i915_chipset_flush_free_page(device_t dev)
 	vga = device_get_parent(dev);
 	if (sc->sc_flush_page_res == NULL)
 		return;
-	BUS_DEACTIVATE_RESOURCE(device_get_parent(vga), dev, SYS_RES_MEMORY,
-	    sc->sc_flush_page_rid, sc->sc_flush_page_res);
+	BUS_DEACTIVATE_RESOURCE(device_get_parent(vga), dev,
+	    sc->sc_flush_page_res);
 	BUS_RELEASE_RESOURCE(device_get_parent(vga), dev, SYS_RES_MEMORY,
 	    sc->sc_flush_page_rid, sc->sc_flush_page_res);
 }
diff --git a/sys/dev/bhnd/bhndb/bhndb.c b/sys/dev/bhnd/bhndb/bhndb.c
index f8a1467894d1..5148c1c8452b 100644
--- a/sys/dev/bhnd/bhndb/bhndb.c
+++ b/sys/dev/bhnd/bhndb/bhndb.c
@@ -104,13 +104,11 @@ static int			 bhndb_init_child_resource(struct resource *r,
 static int			 bhndb_activate_static_region(
 				     struct bhndb_softc *sc,
 				     struct bhndb_region *region, 
-				     device_t child, int type, int rid,
-				     struct resource *r);
+				     device_t child, struct resource *r);
 
 static int			 bhndb_try_activate_resource(
 				     struct bhndb_softc *sc, device_t child,
-				     int type, int rid, struct resource *r,
-				     bool *indirect);
+				     struct resource *r, bool *indirect);
 
 static inline struct bhndb_dw_alloc *bhndb_io_resource(struct bhndb_softc *sc,
 					bus_addr_t addr, bus_size_t size,
@@ -755,8 +753,7 @@ bhndb_resume_resource(device_t dev, device_t child, int type,
 		device_printf(child, "resume resource type=%d 0x%jx+0x%jx\n",
 		    type, rman_get_start(r), rman_get_size(r));
 
-	return (bhndb_try_activate_resource(sc, rman_get_device(r), type,
-	    rman_get_rid(r), r, NULL));
+	return (bhndb_try_activate_resource(sc, rman_get_device(r), r, NULL));
 }
 
 /**
@@ -1057,7 +1054,7 @@ bhndb_release_resource(device_t dev, device_t child, int type, int rid,
 
 	/* Deactivate resources */
 	if (rman_get_flags(r) & RF_ACTIVE) {
-		error = BUS_DEACTIVATE_RESOURCE(dev, child, type, rid, r);
+		error = BUS_DEACTIVATE_RESOURCE(dev, child, r);
 		if (error)
 			return (error);
 	}
@@ -1186,8 +1183,7 @@ bhndb_init_child_resource(struct resource *r,
  */
 static int
 bhndb_activate_static_region(struct bhndb_softc *sc,
-    struct bhndb_region *region, device_t child, int type, int rid,
-    struct resource *r)
+    struct bhndb_region *region, device_t child, struct resource *r)
 {
 	struct resource			*bridge_res;
 	const struct bhndb_regwin	*win;
@@ -1287,8 +1283,6 @@ bhndb_retain_dynamic_window(struct bhndb_softc *sc, struct resource *r)
  * 
  * @param sc The bhndb driver state.
  * @param child The child holding ownership of @p r.
- * @param type The type of the resource to be activated.
- * @param rid The resource ID of @p r.
  * @param r The resource to be activated
  * @param[out] indirect On error and if not NULL, will be set to 'true' if
  * the caller should instead use an indirect resource mapping.
@@ -1297,21 +1291,22 @@ bhndb_retain_dynamic_window(struct bhndb_softc *sc, struct resource *r)
  * @retval non-zero activation failed.
  */
 static int
-bhndb_try_activate_resource(struct bhndb_softc *sc, device_t child, int type,
-    int rid, struct resource *r, bool *indirect)
+bhndb_try_activate_resource(struct bhndb_softc *sc, device_t child,
+    struct resource *r, bool *indirect)
 {
 	struct bhndb_region	*region;
 	struct bhndb_dw_alloc	*dwa;
 	bhndb_priority_t	 dw_priority;
 	rman_res_t		 r_start, r_size;
 	rman_res_t		 parent_offset;
-	int			 error;
+	int			 error, type;
 
 	BHNDB_LOCK_ASSERT(sc, MA_NOTOWNED);
 
 	if (indirect != NULL)
 		*indirect = false;
 
+	type = rman_get_type(r);
 	switch (type) {
 	case SYS_RES_IRQ:
 		/* IRQ resources are always directly mapped */
@@ -1367,8 +1362,7 @@ bhndb_try_activate_resource(struct bhndb_softc *sc, device_t child, int type,
 
 	/* Prefer static mappings over consuming a dynamic windows. */
 	if (region && region->static_regwin) {
-		error = bhndb_activate_static_region(sc, region, child, type,
-		    rid, r);
+		error = bhndb_activate_static_region(sc, region, child, r);
 		if (error)
 			device_printf(sc->dev, "static window allocation "
 			     "for 0x%llx-0x%llx failed\n",
@@ -1425,41 +1419,40 @@ failed:
  * Default bhndb(4) implementation of BUS_ACTIVATE_RESOURCE().
  */
 static int
-bhndb_activate_resource(device_t dev, device_t child, int type, int rid,
-    struct resource *r)
+bhndb_activate_resource(device_t dev, device_t child, struct resource *r)
 {
 	struct bhndb_softc *sc = device_get_softc(dev);
 
 	/* Delegate directly to our parent device's bus if the requested
 	 * resource type isn't handled locally. */
-	if (bhndb_get_rman(sc, child, type) == NULL) {
+	if (bhndb_get_rman(sc, child, rman_get_type(r)) == NULL) {
 		return (BUS_ACTIVATE_RESOURCE(device_get_parent(sc->parent_dev),
-		    child, type, rid, r));
+		    child, r));
 	}
 
-	return (bhndb_try_activate_resource(sc, child, type, rid, r, NULL));
+	return (bhndb_try_activate_resource(sc, child, r, NULL));
 }
 
 /**
  * Default bhndb(4) implementation of BUS_DEACTIVATE_RESOURCE().
  */
 static int
-bhndb_deactivate_resource(device_t dev, device_t child, int type,
-    int rid, struct resource *r)
+bhndb_deactivate_resource(device_t dev, device_t child, struct resource *r)
 {
 	struct bhndb_dw_alloc	*dwa;
 	struct bhndb_softc	*sc;
 	struct rman		*rm;
-	int			 error;
+	int			 error, type;
 
 	sc = device_get_softc(dev);
+	type = rman_get_type(r);
 
 	/* Delegate directly to our parent device's bus if the requested
 	 * resource type isn't handled locally. */
 	rm = bhndb_get_rman(sc, child, type);
 	if (rm == NULL) {
 		return (BUS_DEACTIVATE_RESOURCE(
-		    device_get_parent(sc->parent_dev), child, type, rid, r));
+		    device_get_parent(sc->parent_dev), child, r));
 	}
 
 	/* Mark inactive */
@@ -1534,7 +1527,7 @@ bhndb_activate_bhnd_resource(device_t dev, device_t child,
 	/* Delegate directly to BUS_ACTIVATE_RESOURCE() if the requested
 	 * resource type isn't handled locally. */
 	if (bhndb_get_rman(sc, child, type) == NULL) {
-		error = BUS_ACTIVATE_RESOURCE(dev, child, type, rid, r->res);
+		error = BUS_ACTIVATE_RESOURCE(dev, child, r->res);
 		if (error == 0)
 			r->direct = true;
 		return (error);
@@ -1574,8 +1567,7 @@ bhndb_activate_bhnd_resource(device_t dev, device_t child,
 	}
 
 	/* Attempt direct activation */
-	error = bhndb_try_activate_resource(sc, child, type, rid, r->res,
-	    &indirect);
+	error = bhndb_try_activate_resource(sc, child, r->res, &indirect);
 	if (!error) {
 		r->direct = true;
 	} else if (indirect) {
@@ -1615,7 +1607,7 @@ bhndb_deactivate_bhnd_resource(device_t dev, device_t child,
 	    ("RF_ACTIVE not set on direct resource"));
 
 	/* Perform deactivation */
-	error = BUS_DEACTIVATE_RESOURCE(dev, child, type, rid, r->res);
+	error = BUS_DEACTIVATE_RESOURCE(dev, child, r->res);
 	if (!error)
 		r->direct = false;
 
diff --git a/sys/dev/bhnd/cores/chipc/chipc.c b/sys/dev/bhnd/cores/chipc/chipc.c
index 2d1440e5c987..bdba61a2b942 100644
--- a/sys/dev/bhnd/cores/chipc/chipc.c
+++ b/sys/dev/bhnd/cores/chipc/chipc.c
@@ -124,8 +124,8 @@ static int		 chipc_enable_sprom_pins(struct chipc_softc *sc);
 static void		 chipc_disable_sprom_pins(struct chipc_softc *sc);
 
 static int		 chipc_try_activate_resource(device_t dev,
-			     device_t child, int type, int rid,
-			     struct resource *r, bool req_direct);
+			     device_t child, struct resource *r,
+			     bool req_direct);
 
 static int		 chipc_init_rman(struct chipc_softc *sc);
 static void		 chipc_free_rman(struct chipc_softc *sc);
@@ -949,16 +949,14 @@ chipc_adjust_resource(device_t dev, device_t child,
  *
  * @param sc Driver instance state.
  * @param child Requesting child device.
- * @param type resource type of @p r.
- * @param rid resource id of @p r
  * @param r resource to be activated.
  * @param req_direct If true, failure to allocate a direct bhnd resource
  * will be treated as an error. If false, the resource will not be marked
  * as RF_ACTIVE if bhnd direct resource allocation fails.
  */
 static int
-chipc_try_activate_resource(device_t dev, device_t child, int type,
-    int rid, struct resource *r, bool req_direct)
+chipc_try_activate_resource(device_t dev, device_t child,
+    struct resource *r, bool req_direct)
 {
 	struct chipc_softc	*sc = device_get_softc(dev);
 	struct rman		*rm;
@@ -967,7 +965,7 @@ chipc_try_activate_resource(device_t dev, device_t child, int type,
 	rman_res_t		 r_start, r_end, r_size;
 	int			 error;
 
-	rm = chipc_get_rman(dev, type, rman_get_flags(r));
+	rm = chipc_get_rman(dev, rman_get_type(r), rman_get_flags(r));
 	if (rm == NULL || !rman_is_region_manager(r, rm))
 		return (EINVAL);
 
@@ -1024,8 +1022,7 @@ chipc_activate_bhnd_resource(device_t dev, device_t child, int type,
 	}
 
 	/* Try activating the chipc region resource */
-	error = chipc_try_activate_resource(dev, child, type, rid, r->res,
-	    false);
+	error = chipc_try_activate_resource(dev, child, r->res, false);
 	if (error)
 		return (error);
 
@@ -1038,28 +1035,26 @@ chipc_activate_bhnd_resource(device_t dev, device_t child, int type,
 }
 
 static int
-chipc_activate_resource(device_t dev, device_t child, int type, int rid,
-    struct resource *r)
+chipc_activate_resource(device_t dev, device_t child, struct resource *r)
 {
 	struct rman		*rm;
 
 	/* Delegate non-locally managed resources to parent */
-	rm = chipc_get_rman(dev, type, rman_get_flags(r));
+	rm = chipc_get_rman(dev, rman_get_type(r), rman_get_flags(r));
 	if (rm == NULL || !rman_is_region_manager(r, rm)) {
-		return (bus_generic_activate_resource(dev, child, type, rid,
-		    r));
+		return (bus_generic_activate_resource(dev, child, r));
 	}
 
 	/* Try activating the chipc region-based resource */
-	return (chipc_try_activate_resource(dev, child, type, rid, r, true));
+	return (chipc_try_activate_resource(dev, child, r, true));
 }
 
 /**
  * Default bhndb(4) implementation of BUS_DEACTIVATE_RESOURCE().
  */
 static int
-chipc_deactivate_resource(device_t dev, device_t child, int type,
-    int rid, struct resource *r)
+chipc_deactivate_resource(device_t dev, device_t child,
+    struct resource *r)
 {
 	struct chipc_softc	*sc;
 	struct chipc_region	*cr;
@@ -1069,10 +1064,9 @@ chipc_deactivate_resource(device_t dev, device_t child, int type,
 	sc = device_get_softc(dev);
 
 	/* Handled by parent bus? */
-	rm = chipc_get_rman(dev, type, rman_get_flags(r));
+	rm = chipc_get_rman(dev, rman_get_type(r), rman_get_flags(r));
 	if (rm == NULL || !rman_is_region_manager(r, rm)) {
-		return (bus_generic_deactivate_resource(dev, child, type, rid,
-		    r));
+		return (bus_generic_deactivate_resource(dev, child, r));
 	}
 
 	/* Find the corresponding chipc region */
diff --git a/sys/dev/bhnd/cores/usb/bhnd_usb.c b/sys/dev/bhnd/cores/usb/bhnd_usb.c
index 68701df14c50..fa9e6d7ec31a 100644
--- a/sys/dev/bhnd/cores/usb/bhnd_usb.c
+++ b/sys/dev/bhnd/cores/usb/bhnd_usb.c
@@ -345,23 +345,19 @@ bhnd_usb_release_resource(device_t dev, device_t child, int type,
 }
 
 static int
-bhnd_usb_activate_resource(device_t dev, device_t child, int type, int rid,
-    struct resource *r)
+bhnd_usb_activate_resource(device_t dev, device_t child, struct resource *r)
 {
 	if (type != SYS_RES_MEMORY)
-		return (bus_generic_activate_resource(dev, child, type, rid,
-		    r));
-	return (bus_generic_rman_activate_resource(dev, child, type, rid, r));
+		return (bus_generic_activate_resource(dev, child, r));
+	return (bus_generic_rman_activate_resource(dev, child, r));
 }
 
 static int
-bhnd_usb_deactivate_resource(device_t dev, device_t child, int type, int rid,
-    struct resource *r)
+bhnd_usb_deactivate_resource(device_t dev, device_t child, struct resource *r)
 {
 	if (type != SYS_RES_MEMORY)
-		return (bus_generic_deactivate_resource(dev, child, type, rid,
-		    r));
-	return (bus_generic_rman_deactivate_resource(dev, child, type, rid, r));
+		return (bus_generic_deactivate_resource(dev, child, r));
+	return (bus_generic_rman_deactivate_resource(dev, child, r));
 }
 
 static int
diff --git a/sys/dev/dpaa/fman.c b/sys/dev/dpaa/fman.c
index 7c8122a03ce7..2364df0be801 100644
--- a/sys/dev/dpaa/fman.c
+++ b/sys/dev/dpaa/fman.c
@@ -86,8 +86,7 @@ const uint32_t fman_firmware[] = FMAN_UC_IMG;
 const uint32_t fman_firmware_size = sizeof(fman_firmware);
 
 int
-fman_activate_resource(device_t bus, device_t child, int type, int rid,
-    struct resource *res)
+fman_activate_resource(device_t bus, device_t child, struct resource *res)
 {
 	struct fman_softc *sc;
 	bus_space_tag_t bt;
@@ -95,7 +94,7 @@ fman_activate_resource(device_t bus, device_t child, int type, int rid,
 	int i, rv;
 
 	sc = device_get_softc(bus);
-	if (type != SYS_RES_IRQ) {
+	if (rman_get_type(res) != SYS_RES_IRQ) {
 		for (i = 0; i < sc->sc_base.nranges; i++) {
 			if (rman_is_region_manager(res, &sc->rman) != 0) {
 				bt = rman_get_bustag(sc->mem_res);
@@ -113,7 +112,7 @@ fman_activate_resource(device_t bus, device_t child, int type, int rid,
 		}
 		return (EINVAL);
 	}
-	return (bus_generic_activate_resource(bus, child, type, rid, res));
+	return (bus_generic_activate_resource(bus, child, res));
 }
 
 int
diff --git a/sys/dev/dpaa/fman.h b/sys/dev/dpaa/fman.h
index c7b57c60171d..b201b9fd9355 100644
--- a/sys/dev/dpaa/fman.h
+++ b/sys/dev/dpaa/fman.h
@@ -56,7 +56,7 @@ struct fman_softc {
 struct resource * fman_alloc_resource(device_t bus, device_t child, int type,
     int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags);
 int fman_activate_resource(device_t bus, device_t child,
-    int type, int rid, struct resource *res);
+    struct resource *res);
 int fman_release_resource(device_t bus, device_t child, int type, int rid,
     struct resource *res);
 int	fman_attach(device_t dev);
diff --git a/sys/dev/dpaa2/dpaa2_mc.c b/sys/dev/dpaa2/dpaa2_mc.c
index 0dbb282399ae..3e0920cbf8a5 100644
--- a/sys/dev/dpaa2/dpaa2_mc.c
+++ b/sys/dev/dpaa2/dpaa2_mc.c
@@ -369,29 +369,25 @@ dpaa2_mc_release_resource(device_t mcdev, device_t child, int type, int rid,
 }
 
 int
-dpaa2_mc_activate_resource(device_t mcdev, device_t child, int type, int rid,
-    struct resource *r)
+dpaa2_mc_activate_resource(device_t mcdev, device_t child, struct resource *r)
 {
 	struct rman *rm;
 
-	rm = dpaa2_mc_rman(mcdev, type, rman_get_flags(r));
+	rm = dpaa2_mc_rman(mcdev, rman_get_type(r), rman_get_flags(r));
 	if (rm)
-		return (bus_generic_rman_activate_resource(mcdev, child, type,
-		    rid, r));
-	return (bus_generic_activate_resource(mcdev, child, type, rid, r));
+		return (bus_generic_rman_activate_resource(mcdev, child, r));
+	return (bus_generic_activate_resource(mcdev, child, r));
 }
 
 int
-dpaa2_mc_deactivate_resource(device_t mcdev, device_t child, int type, int rid,
-    struct resource *r)
+dpaa2_mc_deactivate_resource(device_t mcdev, device_t child, struct resource *r)
 {
 	struct rman *rm;
 
-	rm = dpaa2_mc_rman(mcdev, type, rman_get_flags(r));
+	rm = dpaa2_mc_rman(mcdev, rman_get_type(r), rman_get_flags(r));
 	if (rm)
-		return (bus_generic_rman_deactivate_resource(mcdev, child, type,
-		    rid, r));
-	return (bus_generic_deactivate_resource(mcdev, child, type, rid, r));
+		return (bus_generic_rman_deactivate_resource(mcdev, child, r));
+	return (bus_generic_deactivate_resource(mcdev, child, r));
 }
 
 /*
diff --git a/sys/dev/dpaa2/dpaa2_mc.h b/sys/dev/dpaa2/dpaa2_mc.h
index 23b18f8d2ca6..7af3b2a4eb24 100644
--- a/sys/dev/dpaa2/dpaa2_mc.h
+++ b/sys/dev/dpaa2/dpaa2_mc.h
@@ -187,10 +187,10 @@ int dpaa2_mc_adjust_resource(device_t mcdev, device_t child,
     struct resource *r, rman_res_t start, rman_res_t end);
 int dpaa2_mc_release_resource(device_t mcdev, device_t child, int type,
     int rid, struct resource *r);
-int dpaa2_mc_activate_resource(device_t mcdev, device_t child, int type,
-    int rid, struct resource *r);
-int dpaa2_mc_deactivate_resource(device_t mcdev, device_t child, int type,
-    int rid, struct resource *r);
+int dpaa2_mc_activate_resource(device_t mcdev, device_t child,
+    struct resource *r);
+int dpaa2_mc_deactivate_resource(device_t mcdev, device_t child,
+    struct resource *r);
 
 /* For pseudo-pcib interface. */
 
diff --git a/sys/dev/exca/exca.c b/sys/dev/exca/exca.c
index 5a5a68b7dc62..98e0ffdf9d18 100644
--- a/sys/dev/exca/exca.c
+++ b/sys/dev/exca/exca.c
@@ -811,18 +811,18 @@ exca_removal(struct exca_softc *exca)
 }
 
 int
-exca_activate_resource(struct exca_softc *exca, device_t child, int type,
-    int rid, struct resource *res)
+exca_activate_resource(struct exca_softc *exca, device_t child,
+    struct resource *res)
 {
 	int err;
 
 	if (rman_get_flags(res) & RF_ACTIVE)
 		return (0);
 	err = BUS_ACTIVATE_RESOURCE(device_get_parent(exca->dev), child,
-	    type, rid, res);
+	    res);
 	if (err)
 		return (err);
-	switch (type) {
+	switch (rman_get_type(res)) {
 	case SYS_RES_IOPORT:
 		err = exca_io_map(exca, PCCARD_WIDTH_AUTO, res);
 		break;
@@ -832,16 +832,16 @@ exca_activate_resource(struct exca_softc *exca, device_t child, int type,
 	}
 	if (err)
 		BUS_DEACTIVATE_RESOURCE(device_get_parent(exca->dev), child,
-		    type, rid, res);
+		    res);
 	return (err);
 }
 
 int
-exca_deactivate_resource(struct exca_softc *exca, device_t child, int type,
-    int rid, struct resource *res)
+exca_deactivate_resource(struct exca_softc *exca, device_t child,
+    struct resource *res)
 {
 	if (rman_get_flags(res) & RF_ACTIVE) { /* if activated */
-		switch (type) {
+		switch (rman_get_type(res)) {
 		case SYS_RES_IOPORT:
 			if (exca_io_unmap_res(exca, res))
 				return (ENOENT);
@@ -853,7 +853,7 @@ exca_deactivate_resource(struct exca_softc *exca, device_t child, int type,
 		}
 	}
 	return (BUS_DEACTIVATE_RESOURCE(device_get_parent(exca->dev), child,
-	    type, rid, res));
+	    res));
 }
 
 #if 0
diff --git a/sys/dev/exca/excavar.h b/sys/dev/exca/excavar.h
index b301ab5ab26b..07cf2701c4a4 100644
--- a/sys/dev/exca/excavar.h
+++ b/sys/dev/exca/excavar.h
@@ -121,10 +121,10 @@ void exca_removal(struct exca_softc *);
 void exca_reset(struct exca_softc *, device_t child);
 
 /* bus/device interfaces */
-int exca_activate_resource(struct exca_softc *exca, device_t child, int type,
*** 1246 LINES SKIPPED ***