aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2024-03-13 22:05:54 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2024-03-13 22:05:54 +0000
commit2baed46e85d33b1f99e6f96033acc85a9a6fbba4 (patch)
treeb84c8a85556cbeba400cbccebda501f7787a7a41
parentd77f2092ceebaba115e6be53410428f6f5f6ae83 (diff)
downloadsrc-2baed46e85d33b1f99e6f96033acc85a9a6fbba4.tar.gz
src-2baed46e85d33b1f99e6f96033acc85a9a6fbba4.zip
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
-rw-r--r--share/man/man9/bus_activate_resource.924
-rw-r--r--sys/arm/arm/nexus.c16
-rw-r--r--sys/arm/mv/mv_pci.c33
-rw-r--r--sys/arm64/arm64/nexus.c26
-rw-r--r--sys/arm64/cavium/thunder_pcie_pem.c30
-rw-r--r--sys/dev/acpica/acpi.c16
-rw-r--r--sys/dev/acpica/acpi_pcib_acpi.c25
-rw-r--r--sys/dev/agp/agp_i810.c4
-rw-r--r--sys/dev/bhnd/bhndb/bhndb.c50
-rw-r--r--sys/dev/bhnd/cores/chipc/chipc.c34
-rw-r--r--sys/dev/bhnd/cores/usb/bhnd_usb.c16
-rw-r--r--sys/dev/dpaa/fman.c7
-rw-r--r--sys/dev/dpaa/fman.h2
-rw-r--r--sys/dev/dpaa2/dpaa2_mc.c20
-rw-r--r--sys/dev/dpaa2/dpaa2_mc.h8
-rw-r--r--sys/dev/exca/exca.c18
-rw-r--r--sys/dev/exca/excavar.h8
-rw-r--r--sys/dev/fdt/simplebus.c28
-rw-r--r--sys/dev/hyperv/pcib/vmbus_pcib.c18
-rw-r--r--sys/dev/ofw/ofw_pcib.c33
-rw-r--r--sys/dev/pccbb/pccbb.c49
-rw-r--r--sys/dev/pccbb/pccbbvar.h4
-rw-r--r--sys/dev/pci/pci.c18
-rw-r--r--sys/dev/pci/pci_host_generic.c27
-rw-r--r--sys/dev/pci/pci_pci.c18
-rw-r--r--sys/dev/pci/pci_private.h8
-rw-r--r--sys/dev/pci/pci_subr.c4
-rw-r--r--sys/dev/pci/pcib_private.h4
-rw-r--r--sys/dev/vmd/vmd.c20
-rw-r--r--sys/kern/bus_if.m8
-rw-r--r--sys/kern/subr_bus.c45
-rw-r--r--sys/powerpc/mpc85xx/lbc.c31
-rw-r--r--sys/powerpc/powermac/macgpio.c18
-rw-r--r--sys/powerpc/powermac/macio.c28
-rw-r--r--sys/powerpc/powermac/uninorth.c25
-rw-r--r--sys/powerpc/psim/iobus.c26
-rw-r--r--sys/riscv/riscv/nexus.c16
-rw-r--r--sys/sys/bus.h30
-rw-r--r--sys/x86/include/legacyvar.h8
-rw-r--r--sys/x86/pci/pci_bus.c17
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,
- int rid, struct resource *res);
-int exca_deactivate_resource(struct exca_softc *exca, device_t child, int type,
- int rid, struct resource *res);
+int exca_activate_resource(struct exca_softc *exca, device_t child,
+ struct resource *res);
+int exca_deactivate_resource(struct exca_softc *exca, device_t child,
+ struct resource *res);
static __inline uint8_t
exca_getb(struct exca_softc *sc, int reg)
diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c
index 2bd1a1402797..8069d3af69cf 100644
--- a/sys/dev/fdt/simplebus.c
+++ b/sys/dev/fdt/simplebus.c
@@ -48,10 +48,6 @@ static struct resource *simplebus_alloc_resource(device_t, device_t, int,
int *, rman_res_t, rman_res_t, rman_res_t, u_int);
static int simplebus_release_resource(device_t bus, device_t child,
int type, int rid, struct resource *r);
-static int simplebus_activate_resource(device_t bus,
- device_t child, int type, int rid, struct resource *r);
-static int simplebus_deactivate_resource(device_t bus,
- device_t child, int type, int rid, struct resource *r);
static void simplebus_probe_nomatch(device_t bus, device_t child);
static int simplebus_print_child(device_t bus, device_t child);
static device_t simplebus_add_child(device_t dev, u_int order,
@@ -90,8 +86,8 @@ static device_method_t simplebus_methods[] = {
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
DEVMETHOD(bus_alloc_resource, simplebus_alloc_resource),
DEVMETHOD(bus_release_resource, simplebus_release_resource),
- DEVMETHOD(bus_activate_resource, simplebus_activate_resource),
- DEVMETHOD(bus_deactivate_resource, simplebus_deactivate_resource),
+ DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
DEVMETHOD(bus_map_resource, bus_generic_map_resource),
DEVMETHOD(bus_unmap_resource, bus_generic_unmap_resource),
@@ -500,26 +496,6 @@ simplebus_release_resource(device_t bus, device_t child, int type, int rid,
}
static int
-simplebus_activate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
-
- if (type == SYS_RES_IOPORT)
- type = SYS_RES_MEMORY;
- return (bus_generic_activate_resource(bus, child, type, rid, r));
-}
-
-static int
-simplebus_deactivate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
-
- if (type == SYS_RES_IOPORT)
- type = SYS_RES_MEMORY;
- return (bus_generic_deactivate_resource(bus, child, type, rid, r));
-}
-
-static int
simplebus_print_res(struct simplebus_devinfo *di)
{
int rv;
diff --git a/sys/dev/hyperv/pcib/vmbus_pcib.c b/sys/dev/hyperv/pcib/vmbus_pcib.c
index 3d3041ee76b3..fd8a7feae984 100644
--- a/sys/dev/hyperv/pcib/vmbus_pcib.c
+++ b/sys/dev/hyperv/pcib/vmbus_pcib.c
@@ -1741,27 +1741,25 @@ vmbus_pcib_release_resource(device_t dev, device_t child, int type, int rid,
}
static int
-vmbus_pcib_activate_resource(device_t dev, device_t child, int type, int rid,
- struct resource *r)
+vmbus_pcib_activate_resource(device_t dev, device_t child, struct resource *r)
{
struct vmbus_pcib_softc *sc = device_get_softc(dev);
- if (type == PCI_RES_BUS)
+ if (rman_get_type(r) == PCI_RES_BUS)
return (pci_domain_activate_bus(sc->hbus->pci_domain, child,
- rid, r));
- return (bus_generic_activate_resource(dev, child, type, rid, r));
+ r));
+ return (bus_generic_activate_resource(dev, child, r));
}
static int
-vmbus_pcib_deactivate_resource(device_t dev, device_t child, int type, int rid,
- struct resource *r)
+vmbus_pcib_deactivate_resource(device_t dev, device_t child, struct resource *r)
{
struct vmbus_pcib_softc *sc = device_get_softc(dev);
- if (type == PCI_RES_BUS)
+ if (rman_get_type(r) == PCI_RES_BUS)
return (pci_domain_deactivate_bus(sc->hbus->pci_domain, child,
- rid, r));
- return (bus_generic_deactivate_resource(dev, child, type, rid, r));
+ r));
+ return (bus_generic_deactivate_resource(dev, child, r));
}
static int
diff --git a/sys/dev/ofw/ofw_pcib.c b/sys/dev/ofw/ofw_pcib.c
index 4f373030dc33..f9f17b21cdc2 100644
--- a/sys/dev/ofw/ofw_pcib.c
+++ b/sys/dev/ofw/ofw_pcib.c
@@ -69,10 +69,8 @@ static struct resource * ofw_pcib_alloc_resource(device_t, device_t,
int, int *, rman_res_t, rman_res_t, rman_res_t, u_int);
static int ofw_pcib_release_resource(device_t, device_t, int, int,
struct resource *);
-static int ofw_pcib_activate_resource(device_t, device_t, int, int,
- struct resource *);
-static int ofw_pcib_deactivate_resource(device_t, device_t, int, int,
- struct resource *);
+static int ofw_pcib_activate_resource(device_t, device_t, struct resource *);
+static int ofw_pcib_deactivate_resource(device_t, device_t, struct resource *);
static int ofw_pcib_adjust_resource(device_t, device_t,
struct resource *, rman_res_t, rman_res_t);
static int ofw_pcib_map_resource(device_t, device_t, struct resource *,
@@ -510,27 +508,23 @@ ofw_pcib_translate_resource(device_t bus, int type, rman_res_t start,
}
static int
-ofw_pcib_activate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *res)
+ofw_pcib_activate_resource(device_t bus, device_t child, struct resource *res)
{
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
struct ofw_pci_softc *sc;
sc = device_get_softc(bus);
#endif
- switch (type) {
+ switch (rman_get_type(res)) {
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
case PCI_RES_BUS:
- return (pci_domain_activate_bus(sc->sc_pci_domain, child, rid,
- res));
+ return (pci_domain_activate_bus(sc->sc_pci_domain, child, res));
#endif
case SYS_RES_MEMORY:
case SYS_RES_IOPORT:
- return (bus_generic_rman_activate_resource(bus, child, type, rid,
- res));
+ return (bus_generic_rman_activate_resource(bus, child, res));
default:
- return (bus_generic_activate_resource(bus, child, type, rid,
- res));
+ return (bus_generic_activate_resource(bus, child, res));
}
}
@@ -630,27 +624,24 @@ ofw_pcib_bus_get_bus_tag(device_t bus, device_t child)
#endif
static int
-ofw_pcib_deactivate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *res)
+ofw_pcib_deactivate_resource(device_t bus, device_t child, struct resource *res)
{
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
struct ofw_pci_softc *sc;
sc = device_get_softc(bus);
#endif
- switch (type) {
+ switch (rman_get_type(res)) {
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
case PCI_RES_BUS:
- return (pci_domain_deactivate_bus(sc->sc_pci_domain, child, rid,
+ return (pci_domain_deactivate_bus(sc->sc_pci_domain, child,
res));
#endif
case SYS_RES_MEMORY:
case SYS_RES_IOPORT:
- return (bus_generic_rman_deactivate_resource(bus, child, type,
- rid, res));
+ return (bus_generic_rman_deactivate_resource(bus, child, res));
default:
- return (bus_generic_deactivate_resource(bus, child, type, rid,
- res));
+ return (bus_generic_deactivate_resource(bus, child, res));
}
}
diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c
index b2a94cc04bb0..302b9d75c864 100644
--- a/sys/dev/pccbb/pccbb.c
+++ b/sys/dev/pccbb/pccbb.c
@@ -155,9 +155,9 @@ static int cbb_cardbus_mem_open(device_t brdev, int win,
uint32_t start, uint32_t end);
static void cbb_cardbus_auto_open(struct cbb_softc *sc, int type);
static int cbb_cardbus_activate_resource(device_t brdev, device_t child,
- int type, int rid, struct resource *res);
+ struct resource *res);
static int cbb_cardbus_deactivate_resource(device_t brdev,
- device_t child, int type, int rid, struct resource *res);
+ device_t child, struct resource *res);
static struct resource *cbb_cardbus_alloc_resource(device_t brdev,
device_t child, int type, int *rid, rman_res_t start,
rman_res_t end, rman_res_t count, u_int flags);
@@ -1175,30 +1175,30 @@ cbb_cardbus_auto_open(struct cbb_softc *sc, int type)
}
static int
-cbb_cardbus_activate_resource(device_t brdev, device_t child, int type,
- int rid, struct resource *res)
+cbb_cardbus_activate_resource(device_t brdev, device_t child,
+ struct resource *res)
{
int ret;
ret = BUS_ACTIVATE_RESOURCE(device_get_parent(brdev), child,
- type, rid, res);
+ res);
if (ret != 0)
return (ret);
- cbb_cardbus_auto_open(device_get_softc(brdev), type);
+ cbb_cardbus_auto_open(device_get_softc(brdev), rman_get_type(res));
return (0);
}
static int
-cbb_cardbus_deactivate_resource(device_t brdev, device_t child, int type,
- int rid, struct resource *res)
+cbb_cardbus_deactivate_resource(device_t brdev, device_t child,
+ struct resource *res)
{
int ret;
ret = BUS_DEACTIVATE_RESOURCE(device_get_parent(brdev), child,
- type, rid, res);
+ res);
if (ret != 0)
return (ret);
- cbb_cardbus_auto_open(device_get_softc(brdev), type);
+ cbb_cardbus_auto_open(device_get_softc(brdev), rman_get_type(res));
return (0);
}
@@ -1347,24 +1347,24 @@ cbb_power_disable_socket(device_t brdev, device_t child)
}
static int
-cbb_pcic_activate_resource(device_t brdev, device_t child, int type, int rid,
+cbb_pcic_activate_resource(device_t brdev, device_t child,
struct resource *res)
{
struct cbb_softc *sc = device_get_softc(brdev);
int error;
- error = exca_activate_resource(&sc->exca, child, type, rid, res);
+ error = exca_activate_resource(&sc->exca, child, res);
if (error == 0)
- cbb_activate_window(brdev, type);
+ cbb_activate_window(brdev, rman_get_type(res));
return (error);
}
static int
-cbb_pcic_deactivate_resource(device_t brdev, device_t child, int type,
- int rid, struct resource *res)
+cbb_pcic_deactivate_resource(device_t brdev, device_t child,
+ struct resource *res)
{
struct cbb_softc *sc = device_get_softc(brdev);
- return (exca_deactivate_resource(&sc->exca, child, type, rid, res));
+ return (exca_deactivate_resource(&sc->exca, child, res));
}
static struct resource *
@@ -1483,30 +1483,25 @@ cbb_pcic_set_memory_offset(device_t brdev, device_t child, int rid,
/************************************************************************/
int
-cbb_activate_resource(device_t brdev, device_t child, int type, int rid,
- struct resource *r)
+cbb_activate_resource(device_t brdev, device_t child, struct resource *r)
{
struct cbb_softc *sc = device_get_softc(brdev);
if (sc->flags & CBB_16BIT_CARD)
- return (cbb_pcic_activate_resource(brdev, child, type, rid, r));
+ return (cbb_pcic_activate_resource(brdev, child, r));
else
- return (cbb_cardbus_activate_resource(brdev, child, type, rid,
- r));
+ return (cbb_cardbus_activate_resource(brdev, child, r));
}
int
-cbb_deactivate_resource(device_t brdev, device_t child, int type,
- int rid, struct resource *r)
+cbb_deactivate_resource(device_t brdev, device_t child, struct resource *r)
{
struct cbb_softc *sc = device_get_softc(brdev);
if (sc->flags & CBB_16BIT_CARD)
- return (cbb_pcic_deactivate_resource(brdev, child, type,
- rid, r));
+ return (cbb_pcic_deactivate_resource(brdev, child, r));
else
- return (cbb_cardbus_deactivate_resource(brdev, child, type,
- rid, r));
+ return (cbb_cardbus_deactivate_resource(brdev, child, r));
}
struct resource *
diff --git a/sys/dev/pccbb/pccbbvar.h b/sys/dev/pccbb/pccbbvar.h
index 690f215ee302..5d6529070a12 100644
--- a/sys/dev/pccbb/pccbbvar.h
+++ b/sys/dev/pccbb/pccbbvar.h
@@ -108,14 +108,14 @@ struct cbb_softc {
extern int cbb_debug;
int cbb_activate_resource(device_t brdev, device_t child,
- int type, int rid, struct resource *r);
+ struct resource *r);
struct resource *cbb_alloc_resource(device_t brdev, device_t child,
int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count,
u_int flags);
void cbb_child_detached(device_t brdev, device_t child);
int cbb_child_present(device_t parent, device_t child);
int cbb_deactivate_resource(device_t brdev, device_t child,
- int type, int rid, struct resource *r);
+ struct resource *r);
int cbb_detach(device_t brdev);
void cbb_disable_func_intr(struct cbb_softc *sc);
void cbb_driver_added(device_t brdev, driver_t *driver);
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 8236b8bde41a..2797bded62fd 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -5687,13 +5687,12 @@ pci_release_resource(device_t dev, device_t child, int type, int rid,
}
int
-pci_activate_resource(device_t dev, device_t child, int type, int rid,
- struct resource *r)
+pci_activate_resource(device_t dev, device_t child, struct resource *r)
{
struct pci_devinfo *dinfo;
- int error;
+ int error, rid, type;
- error = bus_generic_activate_resource(dev, child, type, rid, r);
+ error = bus_generic_activate_resource(dev, child, r);
if (error)
return (error);
@@ -5701,6 +5700,8 @@ pci_activate_resource(device_t dev, device_t child, int type, int rid,
if (device_get_parent(child) == dev) {
/* Device ROMs need their decoding explicitly enabled. */
dinfo = device_get_ivars(child);
+ rid = rman_get_rid(r);
+ type = rman_get_type(r);
if (type == SYS_RES_MEMORY && PCIR_IS_BIOS(&dinfo->cfg, rid))
pci_write_bar(child, pci_find_bar(child, rid),
rman_get_start(r) | PCIM_BIOS_ENABLE);
@@ -5715,19 +5716,20 @@ pci_activate_resource(device_t dev, device_t child, int type, int rid,
}
int
-pci_deactivate_resource(device_t dev, device_t child, int type,
- int rid, struct resource *r)
+pci_deactivate_resource(device_t dev, device_t child, struct resource *r)
{
struct pci_devinfo *dinfo;
- int error;
+ int error, rid, type;
- error = bus_generic_deactivate_resource(dev, child, type, rid, r);
+ error = bus_generic_deactivate_resource(dev, child, r);
if (error)
return (error);
/* Disable decoding for device ROMs. */
if (device_get_parent(child) == dev) {
dinfo = device_get_ivars(child);
+ rid = rman_get_rid(r);
+ type = rman_get_type(r);
if (type == SYS_RES_MEMORY && PCIR_IS_BIOS(&dinfo->cfg, rid))
pci_write_bar(child, pci_find_bar(child, rid),
rman_get_start(r));
diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c
index 3657be018c99..5831b0f9a8d9 100644
--- a/sys/dev/pci/pci_host_generic.c
+++ b/sys/dev/pci/pci_host_generic.c
@@ -566,50 +566,45 @@ pci_host_generic_core_alloc_resource(device_t dev, device_t child, int type,
}
static int
-generic_pcie_activate_resource(device_t dev, device_t child, int type,
- int rid, struct resource *r)
+generic_pcie_activate_resource(device_t dev, device_t child, struct resource *r)
{
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
struct generic_pcie_core_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->ecam, child, rid, r));
+ return (pci_domain_activate_bus(sc->ecam, child, r));
#endif
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));
default:
- return (bus_generic_activate_resource(dev, child, type, rid,
- r));
+ return (bus_generic_activate_resource(dev, child, r));
}
}
static int
-generic_pcie_deactivate_resource(device_t dev, device_t child, int type,
- int rid, struct resource *r)
+generic_pcie_deactivate_resource(device_t dev, device_t child,
+ struct resource *r)
{
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
struct generic_pcie_core_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_deactivate_bus(sc->ecam, child, rid, r));
+ return (pci_domain_deactivate_bus(sc->ecam, child, r));
#endif
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));
default:
- return (bus_generic_deactivate_resource(dev, child, type, rid,
- r));
+ return (bus_generic_deactivate_resource(dev, child, r));
}
}
diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c
index 146b67c70801..cef58a1670d7 100644
--- a/sys/dev/pci/pci_pci.c
+++ b/sys/dev/pci/pci_pci.c
@@ -2459,21 +2459,20 @@ pcib_release_resource(device_t dev, device_t child, int type, int rid,
}
static int
-pcib_activate_resource(device_t dev, device_t child, int type, int rid,
- struct resource *r)
+pcib_activate_resource(device_t dev, device_t child, struct resource *r)
{
struct pcib_softc *sc = device_get_softc(dev);
struct resource_map map;
- int error;
+ int error, type;
if (!pcib_is_resource_managed(sc, r))
- return (bus_generic_activate_resource(dev, child, type, rid,
- r));
+ return (bus_generic_activate_resource(dev, child, r));
error = rman_activate_resource(r);
if (error != 0)
return (error);
+ type = rman_get_type(r);
if ((rman_get_flags(r) & RF_UNMAPPED) == 0 &&
(type == SYS_RES_MEMORY || type == SYS_RES_IOPORT)) {
error = BUS_MAP_RESOURCE(dev, child, r, NULL, &map);
@@ -2488,21 +2487,20 @@ pcib_activate_resource(device_t dev, device_t child, int type, int rid,
}
static int
-pcib_deactivate_resource(device_t dev, device_t child, int type, int rid,
- struct resource *r)
+pcib_deactivate_resource(device_t dev, device_t child, struct resource *r)
{
struct pcib_softc *sc = device_get_softc(dev);
struct resource_map map;
- int error;
+ int error, type;
if (!pcib_is_resource_managed(sc, r))
- return (bus_generic_deactivate_resource(dev, child, type, rid,
- r));
+ return (bus_generic_deactivate_resource(dev, child, r));
error = rman_deactivate_resource(r);
if (error != 0)
return (error);
+ type = rman_get_type(r);
if ((rman_get_flags(r) & RF_UNMAPPED) == 0 &&
(type == SYS_RES_MEMORY || type == SYS_RES_IOPORT)) {
rman_get_mapping(r, &map);
diff --git a/sys/dev/pci/pci_private.h b/sys/dev/pci/pci_private.h
index b634c7b61260..6bec699bff2b 100644
--- a/sys/dev/pci/pci_private.h
+++ b/sys/dev/pci/pci_private.h
@@ -119,10 +119,10 @@ struct resource *pci_alloc_resource(device_t dev, device_t child,
rman_res_t count, u_int flags);
int pci_release_resource(device_t dev, device_t child, int type,
int rid, struct resource *r);
-int pci_activate_resource(device_t dev, device_t child, int type,
- int rid, struct resource *r);
-int pci_deactivate_resource(device_t dev, device_t child, int type,
- int rid, struct resource *r);
+int pci_activate_resource(device_t dev, device_t child,
+ struct resource *r);
+int pci_deactivate_resource(device_t dev, device_t child,
+ struct resource *r);
void pci_delete_resource(device_t dev, device_t child,
int type, int rid);
struct resource_list *pci_get_resource_list (device_t dev, device_t child);
diff --git a/sys/dev/pci/pci_subr.c b/sys/dev/pci/pci_subr.c
index 4be3e3f166eb..19081a33f159 100644
--- a/sys/dev/pci/pci_subr.c
+++ b/sys/dev/pci/pci_subr.c
@@ -382,7 +382,7 @@ pci_domain_release_bus(int domain, device_t dev, int rid, struct resource *r)
}
int
-pci_domain_activate_bus(int domain, device_t dev, int rid, struct resource *r)
+pci_domain_activate_bus(int domain, device_t dev, struct resource *r)
{
#ifdef INVARIANTS
struct pci_domain *d;
@@ -398,7 +398,7 @@ pci_domain_activate_bus(int domain, device_t dev, int rid, struct resource *r)
}
int
-pci_domain_deactivate_bus(int domain, device_t dev, int rid, struct resource *r)
+pci_domain_deactivate_bus(int domain, device_t dev, struct resource *r)
{
#ifdef INVARIANTS
struct pci_domain *d;
diff --git a/sys/dev/pci/pcib_private.h b/sys/dev/pci/pcib_private.h
index 1f4f18d921e5..c95321586ac2 100644
--- a/sys/dev/pci/pcib_private.h
+++ b/sys/dev/pci/pcib_private.h
@@ -160,9 +160,9 @@ int pci_domain_adjust_bus(int domain, device_t dev,
struct resource *r, rman_res_t start, rman_res_t end);
int pci_domain_release_bus(int domain, device_t dev, int rid,
struct resource *r);
-int pci_domain_activate_bus(int domain, device_t dev, int rid,
+int pci_domain_activate_bus(int domain, device_t dev,
struct resource *r);
-int pci_domain_deactivate_bus(int domain, device_t dev, int rid,
+int pci_domain_deactivate_bus(int domain, device_t dev,
struct resource *r);
struct resource *pcib_alloc_subbus(struct pcib_secbus *bus, device_t child,
int *rid, rman_res_t start, rman_res_t end, rman_res_t count,
diff --git a/sys/dev/vmd/vmd.c b/sys/dev/vmd/vmd.c
index a0a021c7d367..904e615258a6 100644
--- a/sys/dev/vmd/vmd.c
+++ b/sys/dev/vmd/vmd.c
@@ -492,25 +492,21 @@ vmd_release_resource(device_t dev, device_t child, int type, int rid,
}
static int
-vmd_activate_resource(device_t dev, device_t child, int type, int rid,
- struct resource *r)
+vmd_activate_resource(device_t dev, device_t child, struct resource *r)
{
- if (type == SYS_RES_IRQ) {
- return (bus_generic_activate_resource(dev, child, type, rid,
- r));
+ if (rman_get_type(r) == SYS_RES_IRQ) {
+ return (bus_generic_activate_resource(dev, child, r));
}
- return (bus_generic_rman_activate_resource(dev, child, type, rid, r));
+ return (bus_generic_rman_activate_resource(dev, child, r));
}
static int
-vmd_deactivate_resource(device_t dev, device_t child, int type, int rid,
- struct resource *r)
+vmd_deactivate_resource(device_t dev, device_t child, struct resource *r)
{
- if (type == SYS_RES_IRQ) {
- return (bus_generic_deactivate_resource(dev, child, type, rid,
- r));
+ if (rman_get_type(r) == SYS_RES_IRQ) {
+ return (bus_generic_deactivate_resource(dev, child, r));
}
- return (bus_generic_rman_deactivate_resource(dev, child, type, rid, r));
+ return (bus_generic_rman_deactivate_resource(dev, child, r));
}
static struct resource *
diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m
index 375aeebd1835..26745be6eb34 100644
--- a/sys/kern/bus_if.m
+++ b/sys/kern/bus_if.m
@@ -310,15 +310,11 @@ METHOD struct resource * alloc_resource {
*
* @param _dev the parent device of @p _child
* @param _child the device which allocated the resource
- * @param _type the type of resource
- * @param _rid the resource identifier
* @param _r the resource to activate
*/
METHOD int activate_resource {
device_t _dev;
device_t _child;
- int _type;
- int _rid;
struct resource *_r;
};
@@ -373,15 +369,11 @@ METHOD int unmap_resource {
*
* @param _dev the parent device of @p _child
* @param _child the device which allocated the resource
- * @param _type the type of resource
- * @param _rid the resource identifier
* @param _r the resource to deactivate
*/
METHOD int deactivate_resource {
device_t _dev;
device_t _child;
- int _type;
- int _rid;
struct resource *_r;
};
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 34712ae511e5..450fc2742dad 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -3945,13 +3945,11 @@ bus_generic_release_resource(device_t dev, device_t child, int type, int rid,
* BUS_ACTIVATE_RESOURCE() method of the parent of @p dev.
*/
int
-bus_generic_activate_resource(device_t dev, device_t child, int type, int rid,
- struct resource *r)
+bus_generic_activate_resource(device_t dev, device_t child, struct resource *r)
{
/* Propagate up the bus hierarchy until someone handles it. */
if (dev->parent)
- return (BUS_ACTIVATE_RESOURCE(dev->parent, child, type, rid,
- r));
+ return (BUS_ACTIVATE_RESOURCE(dev->parent, child, r));
return (EINVAL);
}
@@ -3962,13 +3960,12 @@ bus_generic_activate_resource(device_t dev, device_t child, int type, int rid,
* BUS_DEACTIVATE_RESOURCE() method of the parent of @p dev.
*/
int
-bus_generic_deactivate_resource(device_t dev, device_t child, int type,
- int rid, struct resource *r)
+bus_generic_deactivate_resource(device_t dev, device_t child,
+ struct resource *r)
{
/* Propagate up the bus hierarchy until someone handles it. */
if (dev->parent)
- return (BUS_DEACTIVATE_RESOURCE(dev->parent, child, type, rid,
- r));
+ return (BUS_DEACTIVATE_RESOURCE(dev->parent, child, r));
return (EINVAL);
}
@@ -4316,15 +4313,16 @@ bus_generic_rman_release_resource(device_t dev, device_t child, int type,
* allocated by bus_generic_rman_alloc_resource.
*/
int
-bus_generic_rman_activate_resource(device_t dev, device_t child, int type,
- int rid, struct resource *r)
+bus_generic_rman_activate_resource(device_t dev, device_t child,
+ struct resource *r)
{
struct resource_map map;
#ifdef INVARIANTS
struct rman *rm;
#endif
- int error;
+ int error, type;
+ type = rman_get_type(r);
#ifdef INVARIANTS
rm = BUS_GET_RMAN(dev, type, rman_get_flags(r));
KASSERT(rman_is_region_manager(r, rm),
@@ -4355,15 +4353,16 @@ bus_generic_rman_activate_resource(device_t dev, device_t child, int type,
* resources allocated by bus_generic_rman_alloc_resource.
*/
int
-bus_generic_rman_deactivate_resource(device_t dev, device_t child, int type,
- int rid, struct resource *r)
+bus_generic_rman_deactivate_resource(device_t dev, device_t child,
+ struct resource *r)
{
struct resource_map map;
#ifdef INVARIANTS
struct rman *rm;
#endif
- int error;
+ int error, type;
+ type = rman_get_type(r);
#ifdef INVARIANTS
rm = BUS_GET_RMAN(dev, type, rman_get_flags(r));
KASSERT(rman_is_region_manager(r, rm),
@@ -4571,18 +4570,17 @@ bus_translate_resource(device_t dev, int type, rman_res_t start,
* parent of @p dev.
*/
int
-bus_activate_resource(device_t dev, int type, int rid, struct resource *r)
+bus_activate_resource(device_t dev, struct resource *r)
{
if (dev->parent == NULL)
return (EINVAL);
- return (BUS_ACTIVATE_RESOURCE(dev->parent, dev, type, rid, r));
+ return (BUS_ACTIVATE_RESOURCE(dev->parent, dev, r));
}
int
-bus_activate_resource_new(device_t dev, struct resource *r)
+bus_activate_resource_old(device_t dev, int type, int rid, struct resource *r)
{
- return (bus_activate_resource(dev, rman_get_type(r), rman_get_rid(r),
- r));
+ return (bus_activate_resource(dev, r));
}
/**
@@ -4592,18 +4590,17 @@ bus_activate_resource_new(device_t dev, struct resource *r)
* parent of @p dev.
*/
int
-bus_deactivate_resource(device_t dev, int type, int rid, struct resource *r)
+bus_deactivate_resource(device_t dev, struct resource *r)
{
if (dev->parent == NULL)
return (EINVAL);
- return (BUS_DEACTIVATE_RESOURCE(dev->parent, dev, type, rid, r));
+ return (BUS_DEACTIVATE_RESOURCE(dev->parent, dev, r));
}
int
-bus_deactivate_resource_new(device_t dev, struct resource *r)
+bus_deactivate_resource_old(device_t dev, int type, int rid, struct resource *r)
{
- return (bus_deactivate_resource(dev, rman_get_type(r), rman_get_rid(r),
- r));
+ return (bus_deactivate_resource(dev, r));
}
/**
diff --git a/sys/powerpc/mpc85xx/lbc.c b/sys/powerpc/mpc85xx/lbc.c
index 20f0baf8c395..6884df611494 100644
--- a/sys/powerpc/mpc85xx/lbc.c
+++ b/sys/powerpc/mpc85xx/lbc.c
@@ -74,9 +74,8 @@ static int lbc_map_resource(device_t, device_t, struct resource *,
static int lbc_unmap_resource(device_t, device_t, struct resource *,
struct resource_map *map);
static int lbc_activate_resource(device_t bus, device_t child,
- int type, int rid, struct resource *r);
-static int lbc_deactivate_resource(device_t bus,
- device_t child, int type __unused, int rid,
+ struct resource *r);
+static int lbc_deactivate_resource(device_t bus, device_t child,
struct resource *r);
static struct rman *lbc_get_rman(device_t, int, u_int);
static struct resource *lbc_alloc_resource(device_t, device_t, int, int *,
@@ -795,36 +794,26 @@ lbc_release_resource(device_t dev, device_t child, int type, int rid,
}
static int
-lbc_activate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
+lbc_activate_resource(device_t bus, device_t child, struct resource *r)
{
- switch (type) {
- case SYS_RES_IOPORT:
- type = SYS_RES_MEMORY;
- /* FALLTHROUGH */
+ switch (rman_get_type(r)) {
case SYS_RES_MEMORY:
- return (bus_generic_rman_activate_resource(bus, child, type,
- rid, r));
+ return (bus_generic_rman_activate_resource(bus, child, r));
case SYS_RES_IRQ:
- return (bus_generic_activate_resource(bus, child, type, rid, r));
+ return (bus_generic_activate_resource(bus, child, r));
default:
return (EINVAL);
}
}
static int
-lbc_deactivate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
+lbc_deactivate_resource(device_t bus, device_t child, struct resource *r)
{
- switch (type) {
- case SYS_RES_IOPORT:
- type = SYS_RES_MEMORY;
- /* FALLTHROUGH */
+ switch (rman_get_type(r)) {
case SYS_RES_MEMORY:
- return (bus_generic_rman_deactivate_resource(bus, child, type,
- rid, r));
+ return (bus_generic_rman_deactivate_resource(bus, child, r));
case SYS_RES_IRQ:
- return (bus_generic_deactivate_resource(bus, child, type, rid, r));
+ return (bus_generic_deactivate_resource(bus, child, r));
default:
return (EINVAL);
}
diff --git a/sys/powerpc/powermac/macgpio.c b/sys/powerpc/powermac/macgpio.c
index d76b5abe79e1..37bd63392449 100644
--- a/sys/powerpc/powermac/macgpio.c
+++ b/sys/powerpc/powermac/macgpio.c
@@ -71,9 +71,9 @@ static int macgpio_print_child(device_t dev, device_t child);
static void macgpio_probe_nomatch(device_t, device_t);
static struct resource *macgpio_alloc_resource(device_t, device_t, int, int *,
rman_res_t, rman_res_t, rman_res_t, u_int);
-static int macgpio_activate_resource(device_t, device_t, int, int,
+static int macgpio_activate_resource(device_t, device_t,
struct resource *);
-static int macgpio_deactivate_resource(device_t, device_t, int, int,
+static int macgpio_deactivate_resource(device_t, device_t,
struct resource *);
static ofw_bus_get_devinfo_t macgpio_get_devinfo;
static int macgpio_suspend(device_t dev);
@@ -275,8 +275,7 @@ macgpio_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
static int
-macgpio_activate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *res)
+macgpio_activate_resource(device_t bus, device_t child, struct resource *res)
{
struct macgpio_softc *sc;
struct macgpio_devinfo *dinfo;
@@ -285,7 +284,7 @@ macgpio_activate_resource(device_t bus, device_t child, int type, int rid,
sc = device_get_softc(bus);
dinfo = device_get_ivars(child);
- if (type != SYS_RES_IRQ)
+ if (rman_get_type(res) != SYS_RES_IRQ)
return ENXIO;
if (dinfo->gpio_num >= 0) {
@@ -294,12 +293,11 @@ macgpio_activate_resource(device_t bus, device_t child, int type, int rid,
bus_write_1(sc->sc_gpios,dinfo->gpio_num,val);
}
- return (bus_activate_resource(bus, type, rid, res));
+ return (bus_generic_activate_resource(bus, child, res));
}
static int
-macgpio_deactivate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *res)
+macgpio_deactivate_resource(device_t bus, device_t child, struct resource *res)
{
struct macgpio_softc *sc;
struct macgpio_devinfo *dinfo;
@@ -308,7 +306,7 @@ macgpio_deactivate_resource(device_t bus, device_t child, int type, int rid,
sc = device_get_softc(bus);
dinfo = device_get_ivars(child);
- if (type != SYS_RES_IRQ)
+ if (rman_get_type(res) != SYS_RES_IRQ)
return ENXIO;
if (dinfo->gpio_num >= 0) {
@@ -317,7 +315,7 @@ macgpio_deactivate_resource(device_t bus, device_t child, int type, int rid,
bus_write_1(sc->sc_gpios,dinfo->gpio_num,val);
}
- return (bus_deactivate_resource(bus, type, rid, res));
+ return (bus_generic_deactivate_resource(bus, child, res));
}
uint8_t
diff --git a/sys/powerpc/powermac/macio.c b/sys/powerpc/powermac/macio.c
index cb4471bbcca1..eb6980005904 100644
--- a/sys/powerpc/powermac/macio.c
+++ b/sys/powerpc/powermac/macio.c
@@ -86,10 +86,8 @@ static struct resource *macio_alloc_resource(device_t, device_t, int, int *,
u_int);
static int macio_adjust_resource(device_t, device_t, struct resource *,
rman_res_t, rman_res_t);
-static int macio_activate_resource(device_t, device_t, int, int,
- struct resource *);
-static int macio_deactivate_resource(device_t, device_t, int, int,
- struct resource *);
+static int macio_activate_resource(device_t, device_t, struct resource *);
+static int macio_deactivate_resource(device_t, device_t, struct resource *);
static int macio_release_resource(device_t, device_t, int, int,
struct resource *);
static int macio_map_resource(device_t, device_t, struct resource *,
@@ -629,34 +627,28 @@ macio_release_resource(device_t bus, device_t child, int type, int rid,
}
static int
-macio_activate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *res)
+macio_activate_resource(device_t bus, device_t child, struct resource *res)
{
- switch (type) {
+ switch (rman_get_type(res)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
- return (bus_generic_rman_activate_resource(bus, child, type,
- rid, res));
+ return (bus_generic_rman_activate_resource(bus, child, res));
case SYS_RES_IRQ:
- return (bus_generic_activate_resource(bus, child, type, rid,
- res));
+ return (bus_generic_activate_resource(bus, child, res));
default:
return (EINVAL);
}
}
static int
-macio_deactivate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *res)
+macio_deactivate_resource(device_t bus, device_t child, struct resource *res)
{
- switch (type) {
+ switch (rman_get_type(res)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
- return (bus_generic_rman_deactivate_resource(bus, child, type,
- rid, res));
+ return (bus_generic_rman_deactivate_resource(bus, child, res));
case SYS_RES_IRQ:
- return (bus_generic_deactivate_resource(bus, child, type, rid,
- res));
+ return (bus_generic_deactivate_resource(bus, child, res));
default:
return (EINVAL);
}
diff --git a/sys/powerpc/powermac/uninorth.c b/sys/powerpc/powermac/uninorth.c
index c7842311d730..96caf4f34530 100644
--- a/sys/powerpc/powermac/uninorth.c
+++ b/sys/powerpc/powermac/uninorth.c
@@ -78,9 +78,9 @@ static struct resource *unin_chip_alloc_resource(device_t, device_t, int, int *,
static int unin_chip_adjust_resource(device_t, device_t,
struct resource *, rman_res_t,
rman_res_t);
-static int unin_chip_activate_resource(device_t, device_t, int, int,
+static int unin_chip_activate_resource(device_t, device_t,
struct resource *);
-static int unin_chip_deactivate_resource(device_t, device_t, int, int,
+static int unin_chip_deactivate_resource(device_t, device_t,
struct resource *);
static int unin_chip_map_resource(device_t, device_t, struct resource *,
struct resource_map_request *,
@@ -587,34 +587,29 @@ unin_chip_release_resource(device_t bus, device_t child, int type, int rid,
}
static int
-unin_chip_activate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *res)
+unin_chip_activate_resource(device_t bus, device_t child, struct resource *res)
{
- switch (type) {
+ switch (rman_get_type(res)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
- return (bus_generic_rman_activate_resource(bus, child, type,
- rid, res));
+ return (bus_generic_rman_activate_resource(bus, child, res));
case SYS_RES_IRQ:
- return (bus_generic_activate_resource(bus, child, type, rid,
- res));
+ return (bus_generic_activate_resource(bus, child, res));
default:
return (EINVAL);
}
}
static int
-unin_chip_deactivate_resource(device_t bus, device_t child, int type, int rid,
+unin_chip_deactivate_resource(device_t bus, device_t child,
struct resource *res)
{
- switch (type) {
+ switch (rman_get_type(res)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
- return (bus_generic_rman_deactivate_resource(bus, child, type,
- rid, res));
+ return (bus_generic_rman_deactivate_resource(bus, child, res));
case SYS_RES_IRQ:
- return (bus_generic_deactivate_resource(bus, child, type, rid,
- res));
+ return (bus_generic_deactivate_resource(bus, child, res));
default:
return (EINVAL);
}
diff --git a/sys/powerpc/psim/iobus.c b/sys/powerpc/psim/iobus.c
index 8f348f0f0614..cea6fc5fb15e 100644
--- a/sys/powerpc/psim/iobus.c
+++ b/sys/powerpc/psim/iobus.c
@@ -76,10 +76,8 @@ static struct resource *iobus_alloc_resource(device_t, device_t, int, int *,
u_int);
static int iobus_adjust_resource(device_t, device_t, struct resource *,
rman_res_t, rman_res_t);
-static int iobus_activate_resource(device_t, device_t, int, int,
- struct resource *);
-static int iobus_deactivate_resource(device_t, device_t, int, int,
- struct resource *);
+static int iobus_activate_resource(device_t, device_t, struct resource *);
+static int iobus_deactivate_resource(device_t, device_t, struct resource *);
static int iobus_map_resource(device_t, device_t, struct resource *,
struct resource_map_request *,
struct resource_map *);
@@ -376,34 +374,30 @@ iobus_release_resource(device_t bus, device_t child, int type, int rid,
}
static int
-iobus_activate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *res)
+iobus_activate_resource(device_t bus, device_t child, struct resource *res)
{
- switch (type) {
+ switch (rman_get_type(res)) {
case SYS_RES_IRQ:
- return (bus_generic_activate_resource(bus, child, type, rid, res));
+ return (bus_generic_activate_resource(bus, child, res));
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
- return (bus_generic_rman_activate_resource(bus, child, type,
- rid, res));
+ return (bus_generic_rman_activate_resource(bus, child, res));
default:
return (EINVAL);
}
}
static int
-iobus_deactivate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *res)
+iobus_deactivate_resource(device_t bus, device_t child, struct resource *res)
{
- switch (type) {
+ switch (rman_get_type(res)) {
case SYS_RES_IRQ:
- return (bus_generic_deactivate_resource(bus, child, type, rid, res));
+ return (bus_generic_deactivate_resource(bus, child, res));
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
- return (bus_generic_rman_deactivate_resource(bus, child, type,
- rid, res));
+ return (bus_generic_rman_deactivate_resource(bus, child, res));
default:
return (EINVAL);
}
diff --git a/sys/riscv/riscv/nexus.c b/sys/riscv/riscv/nexus.c
index eb8126ba1e2f..b8b4eb6604ae 100644
--- a/sys/riscv/riscv/nexus.c
+++ b/sys/riscv/riscv/nexus.c
@@ -303,16 +303,14 @@ nexus_get_bus_tag(device_t bus __unused, device_t child __unused)
}
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 error;
- switch (type) {
+ switch (rman_get_type(r)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
- error = bus_generic_rman_activate_resource(bus, child, type,
- rid, r);
+ error = bus_generic_rman_activate_resource(bus, child, r);
break;
case SYS_RES_IRQ:
error = rman_activate_resource(r);
@@ -340,16 +338,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_IOPORT:
case SYS_RES_MEMORY:
- error = bus_generic_rman_deactivate_resource(bus, child, type,
- rid, r);
+ error = bus_generic_rman_deactivate_resource(bus, child, r);
break;
case SYS_RES_IRQ:
error = rman_deactivate_resource(r);
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index c74553f2ba54..76b1aa4ad2f5 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -427,8 +427,8 @@ void root_bus_configure(void);
struct _cpuset;
-int bus_generic_activate_resource(device_t dev, device_t child, int type,
- int rid, struct resource *r);
+int bus_generic_activate_resource(device_t dev, device_t child,
+ struct resource *r);
device_t
bus_generic_add_child(device_t dev, u_int order, const char *name,
int unit);
@@ -452,8 +452,8 @@ int bus_generic_config_intr(device_t, int, enum intr_trigger,
int bus_generic_describe_intr(device_t dev, device_t child,
struct resource *irq, void *cookie,
const char *descr);
-int bus_generic_deactivate_resource(device_t dev, device_t child, int type,
- int rid, struct resource *r);
+int bus_generic_deactivate_resource(device_t dev, device_t child,
+ struct resource *r);
int bus_generic_detach(device_t dev);
void bus_generic_driver_added(device_t dev, driver_t *driver);
int bus_generic_get_cpus(device_t dev, device_t child, enum cpu_sets op,
@@ -511,10 +511,8 @@ int bus_generic_rman_release_resource(device_t dev, device_t child,
int type, int rid,
struct resource *r);
int bus_generic_rman_activate_resource(device_t dev, device_t child,
- int type, int rid,
struct resource *r);
int bus_generic_rman_deactivate_resource(device_t dev, device_t child,
- int type, int rid,
struct resource *r);
int bus_generic_shutdown(device_t dev);
@@ -561,10 +559,8 @@ int bus_translate_resource(device_t child, int type, rman_res_t start,
struct resource *bus_alloc_resource(device_t dev, int type, int *rid,
rman_res_t start, rman_res_t end,
rman_res_t count, u_int flags);
-int bus_activate_resource(device_t dev, int type, int rid,
- struct resource *r);
-int bus_deactivate_resource(device_t dev, int type, int rid,
- struct resource *r);
+int bus_activate_resource(device_t dev, struct resource *r);
+int bus_deactivate_resource(device_t dev, struct resource *r);
int bus_map_resource(device_t dev, struct resource *r,
struct resource_map_request *args,
struct resource_map *map);
@@ -616,8 +612,10 @@ bus_alloc_resource_anywhere(device_t dev, int type, int *rid,
/* Compat shims for simpler bus resource API. */
int bus_adjust_resource_old(device_t child, int type, struct resource *r,
rman_res_t start, rman_res_t end);
-int bus_activate_resource_new(device_t dev, struct resource *r);
-int bus_deactivate_resource_new(device_t dev, struct resource *r);
+int bus_activate_resource_old(device_t dev, int type, int rid,
+ struct resource *r);
+int bus_deactivate_resource_old(device_t dev, int type, int rid,
+ struct resource *r);
int bus_map_resource_old(device_t dev, int type, struct resource *r,
struct resource_map_request *args,
struct resource_map *map);
@@ -632,12 +630,12 @@ int bus_release_resource_new(device_t dev, struct resource *r);
bus_adjust_resource)(__VA_ARGS__)
#define bus_activate_resource(...) \
- _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_activate_resource, \
- INVALID, bus_activate_resource_new)(__VA_ARGS__)
+ _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_activate_resource_old, \
+ INVALID, bus_activate_resource)(__VA_ARGS__)
#define bus_deactivate_resource(...) \
- _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_deactivate_resource, \
- INVALID, bus_deactivate_resource_new)(__VA_ARGS__)
+ _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_deactivate_resource_old, \
+ INVALID, bus_deactivate_resource)(__VA_ARGS__)
#define bus_map_resource(...) \
_BUS_API_MACRO(__VA_ARGS__, bus_map_resource_old, \
diff --git a/sys/x86/include/legacyvar.h b/sys/x86/include/legacyvar.h
index 789c6c55f198..4f05315c3949 100644
--- a/sys/x86/include/legacyvar.h
+++ b/sys/x86/include/legacyvar.h
@@ -62,10 +62,10 @@ int legacy_pcib_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end);
int legacy_pcib_release_resource(device_t dev, device_t child, int type,
int rid, struct resource *r);
-int legacy_pcib_activate_resource(device_t dev, device_t child, int type,
- int rid, struct resource *r);
-int legacy_pcib_deactivate_resource(device_t dev, device_t child, int type,
- int rid, struct resource *r);
+int legacy_pcib_activate_resource(device_t dev, device_t child,
+ struct resource *r);
+int legacy_pcib_deactivate_resource(device_t dev, device_t child,
+ struct resource *r);
int legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count,
int maxcount, int *irqs);
int legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq);
diff --git a/sys/x86/pci/pci_bus.c b/sys/x86/pci/pci_bus.c
index c7715c47d3c8..67be4d61fa4a 100644
--- a/sys/x86/pci/pci_bus.c
+++ b/sys/x86/pci/pci_bus.c
@@ -627,21 +627,20 @@ legacy_pcib_release_resource(device_t dev, device_t child, int type, int rid,
}
int
-legacy_pcib_activate_resource(device_t dev, device_t child, int type, int rid,
- struct resource *r)
+legacy_pcib_activate_resource(device_t dev, device_t child, struct resource *r)
{
- if (type == PCI_RES_BUS)
- return (pci_domain_activate_bus(0, 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(0, child, r));
+ return (bus_generic_activate_resource(dev, child, r));
}
int
-legacy_pcib_deactivate_resource(device_t dev, device_t child, int type, int rid,
+legacy_pcib_deactivate_resource(device_t dev, device_t child,
struct resource *r)
{
- if (type == PCI_RES_BUS)
- return (pci_domain_deactivate_bus(0, 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(0, child, r));
+ return (bus_generic_deactivate_resource(dev, child, r));
}
#endif