diff --git a/share/man/man9/bus_activate_resource.9 b/share/man/man9/bus_activate_resource.9 --- a/share/man/man9/bus_activate_resource.9 +++ b/share/man/man9/bus_activate_resource.9 @@ -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 @@ .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 --- a/sys/arm/arm/nexus.c +++ b/sys/arm/arm/nexus.c @@ -305,16 +305,14 @@ #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 @@ } 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 --- a/sys/arm/mv/mv_pci.c +++ b/sys/arm/mv/mv_pci.c @@ -349,10 +349,8 @@ 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 @@ } 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 --- a/sys/arm64/arm64/nexus.c +++ b/sys/arm64/arm64/nexus.c @@ -324,8 +324,8 @@ } 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 @@ /* * 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 @@ } 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 @@ } 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 @@ } 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 @@ 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 --- 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_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 @@ } 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 @@ 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 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1610,23 +1610,19 @@ } 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 --- a/sys/dev/acpica/acpi_pcib_acpi.c +++ b/sys/dev/acpica/acpi_pcib_acpi.c @@ -104,11 +104,9 @@ 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 @@ } 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 --- a/sys/dev/agp/agp_i810.c +++ b/sys/dev/agp/agp_i810.c @@ -2051,8 +2051,8 @@ 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 --- a/sys/dev/bhnd/bhndb/bhndb.c +++ b/sys/dev/bhnd/bhndb/bhndb.c @@ -104,13 +104,11 @@ 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 @@ 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 @@ /* 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 @@ */ 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 @@ * * @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 @@ * @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 @@ /* 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 @@ * 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 @@ /* 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 @@ } /* 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 @@ ("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 --- a/sys/dev/bhnd/cores/chipc/chipc.c +++ b/sys/dev/bhnd/cores/chipc/chipc.c @@ -124,8 +124,8 @@ 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 @@ * * @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 @@ 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 @@ } /* 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 @@ } 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 @@ 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 --- a/sys/dev/bhnd/cores/usb/bhnd_usb.c +++ b/sys/dev/bhnd/cores/usb/bhnd_usb.c @@ -345,23 +345,19 @@ } 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.h b/sys/dev/dpaa/fman.h --- a/sys/dev/dpaa/fman.h +++ b/sys/dev/dpaa/fman.h @@ -56,7 +56,7 @@ 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/dpaa/fman.c b/sys/dev/dpaa/fman.c --- a/sys/dev/dpaa/fman.c +++ b/sys/dev/dpaa/fman.c @@ -86,8 +86,7 @@ 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 @@ 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 @@ } 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/dpaa2/dpaa2_mc.h b/sys/dev/dpaa2/dpaa2_mc.h --- a/sys/dev/dpaa2/dpaa2_mc.h +++ b/sys/dev/dpaa2/dpaa2_mc.h @@ -187,10 +187,10 @@ 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/dpaa2/dpaa2_mc.c b/sys/dev/dpaa2/dpaa2_mc.c --- a/sys/dev/dpaa2/dpaa2_mc.c +++ b/sys/dev/dpaa2/dpaa2_mc.c @@ -369,29 +369,25 @@ } 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/exca/exca.c b/sys/dev/exca/exca.c --- a/sys/dev/exca/exca.c +++ b/sys/dev/exca/exca.c @@ -811,18 +811,18 @@ } 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 @@ } 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 @@ } } 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 --- a/sys/dev/exca/excavar.h +++ b/sys/dev/exca/excavar.h @@ -121,10 +121,10 @@ 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 --- a/sys/dev/fdt/simplebus.c +++ b/sys/dev/fdt/simplebus.c @@ -48,10 +48,6 @@ 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 @@ 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), @@ -499,26 +495,6 @@ return (bus_generic_release_resource(bus, child, type, rid, r)); } -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) { diff --git a/sys/dev/hyperv/pcib/vmbus_pcib.c b/sys/dev/hyperv/pcib/vmbus_pcib.c --- a/sys/dev/hyperv/pcib/vmbus_pcib.c +++ b/sys/dev/hyperv/pcib/vmbus_pcib.c @@ -1740,27 +1740,25 @@ } 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 --- a/sys/dev/ofw/ofw_pcib.c +++ b/sys/dev/ofw/ofw_pcib.c @@ -69,10 +69,8 @@ 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 @@ } 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 @@ #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 --- a/sys/dev/pccbb/pccbb.c +++ b/sys/dev/pccbb/pccbb.c @@ -155,9 +155,9 @@ 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 @@ } 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 @@ } 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 @@ /************************************************************************/ 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 --- a/sys/dev/pccbb/pccbbvar.h +++ b/sys/dev/pccbb/pccbbvar.h @@ -108,14 +108,14 @@ 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 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -5687,13 +5687,12 @@ } 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 @@ 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 @@ } 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 --- a/sys/dev/pci/pci_host_generic.c +++ b/sys/dev/pci/pci_host_generic.c @@ -572,50 +572,45 @@ } 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 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -2459,21 +2459,20 @@ } 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 @@ } 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 --- a/sys/dev/pci/pci_private.h +++ b/sys/dev/pci/pci_private.h @@ -119,10 +119,10 @@ 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 --- a/sys/dev/pci/pci_subr.c +++ b/sys/dev/pci/pci_subr.c @@ -382,7 +382,7 @@ } 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 @@ } 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 --- a/sys/dev/pci/pcib_private.h +++ b/sys/dev/pci/pcib_private.h @@ -160,9 +160,9 @@ 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 --- a/sys/dev/vmd/vmd.c +++ b/sys/dev/vmd/vmd.c @@ -492,25 +492,21 @@ } 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 --- a/sys/kern/bus_if.m +++ b/sys/kern/bus_if.m @@ -310,15 +310,11 @@ * * @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 @@ * * @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 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -3945,13 +3945,11 @@ * 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_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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 --- a/sys/powerpc/mpc85xx/lbc.c +++ b/sys/powerpc/mpc85xx/lbc.c @@ -74,9 +74,8 @@ 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 @@ } 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 --- a/sys/powerpc/powermac/macgpio.c +++ b/sys/powerpc/powermac/macgpio.c @@ -71,9 +71,9 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 --- a/sys/powerpc/powermac/macio.c +++ b/sys/powerpc/powermac/macio.c @@ -86,10 +86,8 @@ 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 @@ } 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 --- a/sys/powerpc/powermac/uninorth.c +++ b/sys/powerpc/powermac/uninorth.c @@ -78,9 +78,9 @@ 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 @@ } 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 --- a/sys/powerpc/psim/iobus.c +++ b/sys/powerpc/psim/iobus.c @@ -76,10 +76,8 @@ 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 @@ } 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 --- a/sys/riscv/riscv/nexus.c +++ b/sys/riscv/riscv/nexus.c @@ -303,16 +303,14 @@ } 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 @@ } 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 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -427,8 +427,8 @@ 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_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 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 @@ 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 @@ /* 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 @@ 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 --- a/sys/x86/include/legacyvar.h +++ b/sys/x86/include/legacyvar.h @@ -62,10 +62,10 @@ 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 --- a/sys/x86/pci/pci_bus.c +++ b/sys/x86/pci/pci_bus.c @@ -627,21 +627,20 @@ } 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