diff --git a/share/man/man9/bus_adjust_resource.9 b/share/man/man9/bus_adjust_resource.9 --- a/share/man/man9/bus_adjust_resource.9 +++ b/share/man/man9/bus_adjust_resource.9 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd April 23, 2016 +.Dd March 13, 2024 .Dt BUS_ADJUST_RESOURCE 9 .Os .Sh NAME @@ -40,7 +40,7 @@ .In machine/resource.h .Ft int .Fo bus_adjust_resource -.Fa "device_t dev" "int type" "struct resource *r" +.Fa "device_t dev" "struct resource *r" .Fa "rman_res_t start" "rman_res_t end" .Fc .Sh DESCRIPTION @@ -52,13 +52,6 @@ .Xr bus_alloc_resource 9 . The new resource range must overlap the existing range of .Fa r . -The -.Fa type -argument should match the -.Fa type -argument passed to -.Xr bus_alloc_resource 9 -when the resource was initially allocated. .Pp Note that none of the constraints of the original allocation request such as alignment or boundary restrictions are checked by @@ -74,8 +67,8 @@ struct resource *res; int error; - error = bus_adjust_resource(dev, SYS_RES_MEMORY, res, - rman_get_start(res), rman_get_end(res) + 0x1000); + error = bus_adjust_resource(dev, res, rman_get_start(res), + rman_get_end(res) + 0x1000); .Ed .Sh ERRORS .Fn bus_adjust_resource 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 @@ -345,7 +345,7 @@ static struct rman *mv_pcib_get_rman(device_t, int, u_int); static struct resource *mv_pcib_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); -static int mv_pcib_adjust_resource(device_t, device_t, int, struct resource *, +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 *); @@ -941,26 +941,25 @@ } static int -mv_pcib_adjust_resource(device_t dev, device_t child, int type, +mv_pcib_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { #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_adjust_resource(dev, child, type, r, - start, end)); + return (bus_generic_rman_adjust_resource(dev, child, r, start, + end)); #ifdef PCI_RES_BUS case PCI_RES_BUS: return (pci_domain_adjust_bus(sc->ap_segment, child, r, start, end)); #endif default: - return (bus_generic_adjust_resource(dev, child, type, r, - start, end)); + return (bus_generic_adjust_resource(dev, child, r, start, end)); } } 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 @@ -122,7 +122,7 @@ static int thunder_pem_activate_resource(device_t, device_t, int, int, struct resource *); -static int thunder_pem_adjust_resource(device_t, device_t, int, +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, int *, rman_res_t, rman_res_t, rman_res_t, u_int); @@ -355,26 +355,26 @@ } static int -thunder_pem_adjust_resource(device_t dev, device_t child, int type, - struct resource *res, rman_res_t start, rman_res_t end) +thunder_pem_adjust_resource(device_t dev, device_t child, struct resource *res, + rman_res_t start, rman_res_t end) { #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(res)) { #if defined(NEW_PCIB) && defined(PCI_RES_BUS) case PCI_RES_BUS: return (pci_domain_adjust_bus(sc->id, child, res, start, end)); #endif case SYS_RES_MEMORY: case SYS_RES_IOPORT: - return (bus_generic_rman_adjust_resource(dev, child, type, res, - start, end)); + return (bus_generic_rman_adjust_resource(dev, child, res, start, + end)); default: - return (bus_generic_adjust_resource(dev, child, type, res, - start, end)); + return (bus_generic_adjust_resource(dev, child, res, start, + end)); } } 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 @@ -1570,13 +1570,13 @@ } static int -acpi_adjust_resource(device_t bus, device_t child, int type, struct resource *r, +acpi_adjust_resource(device_t bus, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { if (acpi_is_resource_managed(bus, r)) return (rman_adjust_resource(r, start, end)); - return (bus_generic_adjust_resource(bus, child, type, r, start, end)); + return (bus_generic_adjust_resource(bus, child, r, start, end)); } 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 @@ -97,7 +97,7 @@ u_int flags); #ifdef NEW_PCIB static int acpi_pcib_acpi_adjust_resource(device_t dev, - device_t child, int type, struct resource *r, + device_t child, struct resource *r, rman_res_t start, rman_res_t end); #ifdef PCI_RES_BUS static int acpi_pcib_acpi_release_resource(device_t dev, @@ -745,19 +745,18 @@ #ifdef NEW_PCIB int -acpi_pcib_acpi_adjust_resource(device_t dev, device_t child, int type, +acpi_pcib_acpi_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { struct acpi_hpcib_softc *sc; sc = device_get_softc(dev); #ifdef PCI_RES_BUS - if (type == PCI_RES_BUS) + if (rman_get_type(r) == PCI_RES_BUS) return (pci_domain_adjust_bus(sc->ap_segment, child, r, start, end)); #endif - return (pcib_host_res_adjust(&sc->ap_host_res, child, type, r, start, - end)); + return (pcib_host_res_adjust(&sc->ap_host_res, child, r, start, end)); } #ifdef PCI_RES_BUS 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 @@ -1080,7 +1080,7 @@ * Default bhndb(4) implementation of BUS_ADJUST_RESOURCE(). */ static int -bhndb_adjust_resource(device_t dev, device_t child, int type, +bhndb_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { struct bhndb_softc *sc; @@ -1093,10 +1093,10 @@ /* Delegate to our parent device's bus if the requested resource type * isn't handled locally. */ - rm = bhndb_get_rman(sc, child, type); + rm = bhndb_get_rman(sc, child, rman_get_type(r)); if (rm == NULL) { return (BUS_ADJUST_RESOURCE(device_get_parent(sc->parent_dev), - child, type, r, start, end)); + child, r, start, end)); } /* Verify basic constraints */ 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 @@ -913,7 +913,7 @@ } static int -chipc_adjust_resource(device_t dev, device_t child, int type, +chipc_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { struct chipc_softc *sc; @@ -923,10 +923,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_adjust_resource(dev, child, type, r, start, - end)); + return (bus_generic_adjust_resource(dev, child, r, start, end)); } /* The range is limited to the existing region mapping */ 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 @@ -183,7 +183,7 @@ struct resource * dpaa2_mc_alloc_resource(device_t mcdev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); -int dpaa2_mc_adjust_resource(device_t mcdev, device_t child, int type, +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); 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 @@ -343,16 +343,16 @@ } int -dpaa2_mc_adjust_resource(device_t mcdev, device_t child, int type, +dpaa2_mc_adjust_resource(device_t mcdev, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { 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_adjust_resource(mcdev, child, type, r, + return (bus_generic_rman_adjust_resource(mcdev, child, r, start, end)); - return (bus_generic_adjust_resource(mcdev, child, type, r, start, end)); + return (bus_generic_adjust_resource(mcdev, child, r, start, end)); } int 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 @@ -46,8 +46,6 @@ static int simplebus_probe(device_t dev); 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_adjust_resource(device_t bus, device_t child, - int type, struct resource *r, rman_res_t start, rman_res_t end); 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, @@ -99,7 +97,7 @@ DEVMETHOD(bus_release_resource, simplebus_release_resource), DEVMETHOD(bus_activate_resource, simplebus_activate_resource), DEVMETHOD(bus_deactivate_resource, simplebus_deactivate_resource), - DEVMETHOD(bus_adjust_resource, simplebus_adjust_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), DEVMETHOD(bus_map_resource, simplebus_map_resource), DEVMETHOD(bus_unmap_resource, simplebus_unmap_resource), DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), @@ -496,16 +494,6 @@ count, flags)); } -static int -simplebus_adjust_resource(device_t bus, device_t child, int type, - struct resource *r, rman_res_t start, rman_res_t end) -{ - - if (type == SYS_RES_IOPORT) - type = SYS_RES_MEMORY; - return (bus_generic_adjust_resource(bus, child, type, r, start, end)); -} - static int simplebus_release_resource(device_t bus, device_t child, int type, int rid, struct resource *r) 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 @@ -1713,15 +1713,15 @@ } static int -vmbus_pcib_adjust_resource(device_t dev, device_t child, int type, +vmbus_pcib_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { 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_adjust_bus(sc->hbus->pci_domain, child, r, start, end)); - return (bus_generic_adjust_resource(dev, child, type, r, start, end)); + return (bus_generic_adjust_resource(dev, child, r, start, end)); } 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 @@ -73,7 +73,7 @@ struct resource *); static int ofw_pcib_deactivate_resource(device_t, device_t, int, int, struct resource *); -static int ofw_pcib_adjust_resource(device_t, device_t, int, +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, int, struct resource *, struct resource_map_request *, struct resource_map *); @@ -656,7 +656,7 @@ } static int -ofw_pcib_adjust_resource(device_t bus, device_t child, int type, +ofw_pcib_adjust_resource(device_t bus, device_t child, struct resource *res, rman_res_t start, rman_res_t end) { #if defined(NEW_PCIB) && defined(PCI_RES_BUS) @@ -664,7 +664,7 @@ 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_adjust_bus(sc->sc_pci_domain, child, res, @@ -672,11 +672,11 @@ #endif case SYS_RES_MEMORY: case SYS_RES_IOPORT: - return (bus_generic_rman_adjust_resource(bus, child, type, res, + return (bus_generic_rman_adjust_resource(bus, child, res, start, end)); default: - return (bus_generic_adjust_resource(bus, child, type, res, - start, end)); + return (bus_generic_adjust_resource(bus, child, res, start, + end)); } } diff --git a/sys/dev/pccbb/pccbb_pci.c b/sys/dev/pccbb/pccbb_pci.c --- a/sys/dev/pccbb/pccbb_pci.c +++ b/sys/dev/pccbb/pccbb_pci.c @@ -803,18 +803,18 @@ } static int -cbb_pci_adjust_resource(device_t bus, device_t child, int type, +cbb_pci_adjust_resource(device_t bus, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { struct cbb_softc *sc; sc = device_get_softc(bus); - if (type == PCI_RES_BUS) { + if (rman_get_type(r) == PCI_RES_BUS) { if (!rman_is_region_manager(r, &sc->bus.rman)) return (EINVAL); return (rman_adjust_resource(r, start, end)); } - return (bus_generic_adjust_resource(bus, child, type, r, start, end)); + return (bus_generic_adjust_resource(bus, child, r, start, end)); } static int 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 @@ -614,7 +614,7 @@ } static int -generic_pcie_adjust_resource(device_t dev, device_t child, int type, +generic_pcie_adjust_resource(device_t dev, device_t child, struct resource *res, rman_res_t start, rman_res_t end) { #if defined(NEW_PCIB) && defined(PCI_RES_BUS) @@ -622,7 +622,7 @@ sc = device_get_softc(dev); #endif - switch (type) { + switch (rman_get_type(res)) { #if defined(NEW_PCIB) && defined(PCI_RES_BUS) case PCI_RES_BUS: return (pci_domain_adjust_bus(sc->ecam, child, res, start, @@ -630,11 +630,11 @@ #endif case SYS_RES_IOPORT: case SYS_RES_MEMORY: - return (bus_generic_rman_adjust_resource(dev, child, type, res, + return (bus_generic_rman_adjust_resource(dev, child, res, start, end)); default: - return (bus_generic_adjust_resource(dev, child, type, res, - start, end)); + return (bus_generic_adjust_resource(dev, child, res, start, + end)); } } 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 @@ -2372,23 +2372,23 @@ } static int -pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *r, +pcib_adjust_resource(device_t bus, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { struct pcib_softc *sc; struct pcib_window *w; rman_res_t wmask; - int error; + int error, type; sc = device_get_softc(bus); + type = rman_get_type(r); /* * If the resource wasn't sub-allocated from one of our region * managers then just pass the request up. */ if (!pcib_is_resource_managed(sc, r)) - return (bus_generic_adjust_resource(bus, child, type, r, - start, end)); + return (bus_generic_adjust_resource(bus, child, r, start, end)); #ifdef PCI_RES_BUS if (type == PCI_RES_BUS) { 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 @@ -260,26 +260,26 @@ } int -pcib_host_res_adjust(struct pcib_host_resources *hr, device_t dev, int type, +pcib_host_res_adjust(struct pcib_host_resources *hr, device_t dev, struct resource *r, rman_res_t start, rman_res_t end) { struct resource_list_entry *rle; - rle = resource_list_find(&hr->hr_rl, type, 0); + rle = resource_list_find(&hr->hr_rl, rman_get_type(r), 0); if (rle == NULL) { /* * No decoding ranges for this resource type, just pass * the request up to the parent. */ - return (bus_generic_adjust_resource(hr->hr_pcib, dev, type, r, - start, end)); + return (bus_generic_adjust_resource(hr->hr_pcib, dev, r, start, + end)); } /* Only allow adjustments that stay within a decoded range. */ for (; rle != NULL; rle = STAILQ_NEXT(rle, link)) { if (rle->start <= start && rle->end >= end) return (bus_generic_adjust_resource(hr->hr_pcib, dev, - type, r, start, end)); + r, start, end)); } return (ERANGE); } 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 @@ -56,7 +56,7 @@ device_t dev, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); int pcib_host_res_adjust(struct pcib_host_resources *hr, - device_t dev, int type, struct resource *r, rman_res_t start, + device_t dev, struct resource *r, rman_res_t start, rman_res_t end); #endif 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 @@ -469,16 +469,14 @@ } static int -vmd_adjust_resource(device_t dev, device_t child, int type, +vmd_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { - if (type == SYS_RES_IRQ) { - return (bus_generic_adjust_resource(dev, child, type, r, - start, end)); + if (rman_get_type(r) == SYS_RES_IRQ) { + return (bus_generic_adjust_resource(dev, child, r, start, end)); } - return (bus_generic_rman_adjust_resource(dev, child, type, r, start, - end)); + return (bus_generic_rman_adjust_resource(dev, child, r, start, end)); } static int 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 @@ -399,7 +399,6 @@ * * @param _dev the parent device of @p _child * @param _child the device which allocated the resource - * @param _type the type of resource * @param _res the resource to adjust * @param _start the new starting address of the resource range * @param _end the new ending address of the resource range @@ -407,7 +406,6 @@ METHOD int adjust_resource { device_t _dev; device_t _child; - int _type; struct resource *_res; rman_res_t _start; rman_res_t _end; 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 @@ -3877,13 +3877,12 @@ * BUS_ADJUST_RESOURCE() method of the parent of @p dev. */ int -bus_generic_adjust_resource(device_t dev, device_t child, int type, - struct resource *r, rman_res_t start, rman_res_t end) +bus_generic_adjust_resource(device_t dev, device_t child, struct resource *r, + rman_res_t start, rman_res_t end) { /* Propagate up the bus hierarchy until someone handles it. */ if (dev->parent) - return (BUS_ADJUST_RESOURCE(dev->parent, child, type, r, start, - end)); + return (BUS_ADJUST_RESOURCE(dev->parent, child, r, start, end)); return (EINVAL); } @@ -4270,12 +4269,12 @@ * BUS_GET_RMAN(). */ int -bus_generic_rman_adjust_resource(device_t dev, device_t child, int type, +bus_generic_rman_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { struct rman *rm; - rm = BUS_GET_RMAN(dev, type, rman_get_flags(r)); + rm = BUS_GET_RMAN(dev, rman_get_type(r), rman_get_flags(r)); if (rm == NULL) return (ENXIO); if (!rman_is_region_manager(r, rm)) @@ -4537,19 +4536,19 @@ * parent of @p dev. */ int -bus_adjust_resource(device_t dev, int type, struct resource *r, rman_res_t start, +bus_adjust_resource(device_t dev, struct resource *r, rman_res_t start, rman_res_t end) { if (dev->parent == NULL) return (EINVAL); - return (BUS_ADJUST_RESOURCE(dev->parent, dev, type, r, start, end)); + return (BUS_ADJUST_RESOURCE(dev->parent, dev, r, start, end)); } int -bus_adjust_resource_new(device_t dev, struct resource *r, rman_res_t start, - rman_res_t end) +bus_adjust_resource_old(device_t dev, int type __unused, struct resource *r, + rman_res_t start, rman_res_t end) { - return (bus_adjust_resource(dev, rman_get_type(r), r, start, end)); + return (bus_adjust_resource(dev, r, start, end)); } /** 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 @@ -81,7 +81,7 @@ static struct rman *lbc_get_rman(device_t, int, u_int); static struct resource *lbc_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); -static int lbc_adjust_resource(device_t, device_t, int, struct resource *, +static int lbc_adjust_resource(device_t, device_t, struct resource *, rman_res_t, rman_res_t); static int lbc_print_child(device_t, device_t); static int lbc_release_resource(device_t, device_t, int, int, @@ -762,19 +762,15 @@ } static int -lbc_adjust_resource(device_t dev, device_t child, int type, struct resource *r, +lbc_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { - switch (type) { - case SYS_RES_IOPORT: - type = SYS_RES_MEMORY; - /* FALLTHROUGH */ + switch (rman_get_type(r)) { case SYS_RES_MEMORY: - return (bus_generic_rman_adjust_resource(dev, child, type, r, - start, end)); - case SYS_RES_IRQ: - return (bus_generic_adjust_resource(dev, child, type, r, start, + return (bus_generic_rman_adjust_resource(dev, child, r, start, end)); + case SYS_RES_IRQ: + return (bus_generic_adjust_resource(dev, child, r, start, end)); default: return (EINVAL); } 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 @@ -84,7 +84,7 @@ static struct resource *macio_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); -static int macio_adjust_resource(device_t, device_t, int, struct resource *, +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 *); @@ -596,17 +596,16 @@ } static int -macio_adjust_resource(device_t bus, device_t child, int type, - struct resource *r, rman_res_t start, rman_res_t end) +macio_adjust_resource(device_t bus, device_t child, struct resource *r, + rman_res_t start, rman_res_t end) { - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: - return (bus_generic_rman_adjust_resource(bus, child, type, r, - start, end)); - case SYS_RES_IRQ: - return (bus_generic_adjust_resource(bus, child, type, r, start, + return (bus_generic_rman_adjust_resource(bus, child, r, start, end)); + case SYS_RES_IRQ: + return (bus_generic_adjust_resource(bus, child, r, start, end)); 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 @@ -75,7 +75,7 @@ static struct resource *unin_chip_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); -static int unin_chip_adjust_resource(device_t, device_t, 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, @@ -554,17 +554,16 @@ } static int -unin_chip_adjust_resource(device_t bus, device_t child, int type, - struct resource *r, rman_res_t start, rman_res_t end) +unin_chip_adjust_resource(device_t bus, device_t child, struct resource *r, + rman_res_t start, rman_res_t end) { - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: - return (bus_generic_rman_adjust_resource(bus, child, type, r, - start, end)); - case SYS_RES_IRQ: - return (bus_generic_adjust_resource(bus, child, type, r, start, + return (bus_generic_rman_adjust_resource(bus, child, r, start, end)); + case SYS_RES_IRQ: + return (bus_generic_adjust_resource(bus, child, r, start, end)); 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 @@ -74,7 +74,7 @@ static struct resource *iobus_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); -static int iobus_adjust_resource(device_t, device_t, int, struct resource *, +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 *); @@ -342,18 +342,17 @@ } static int -iobus_adjust_resource(device_t bus, device_t child, int type, - struct resource *r, rman_res_t start, rman_res_t end) +iobus_adjust_resource(device_t bus, device_t child, struct resource *r, + rman_res_t start, rman_res_t end) { - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_MEMORY: case SYS_RES_IOPORT: - return (bus_generic_rman_adjust_resource(bus, child, type, r, - start, end)); - case SYS_RES_IRQ: - return (bus_generic_adjust_resource(bus, child, type, r, start, + return (bus_generic_rman_adjust_resource(bus, child, r, start, end)); + case SYS_RES_IRQ: + return (bus_generic_adjust_resource(bus, child, r, start, end)); default: return (EINVAL); } diff --git a/sys/sys/bus.h b/sys/sys/bus.h --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -432,7 +432,7 @@ device_t bus_generic_add_child(device_t dev, u_int order, const char *name, int unit); -int bus_generic_adjust_resource(device_t bus, device_t child, int type, +int bus_generic_adjust_resource(device_t bus, device_t child, struct resource *r, rman_res_t start, rman_res_t end); struct resource * @@ -504,7 +504,7 @@ int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); -int bus_generic_rman_adjust_resource(device_t dev, device_t child, int type, +int bus_generic_rman_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end); int bus_generic_rman_release_resource(device_t dev, device_t child, @@ -554,7 +554,7 @@ void bus_release_resources(device_t dev, const struct resource_spec *rs, struct resource **res); -int bus_adjust_resource(device_t child, int type, struct resource *r, +int bus_adjust_resource(device_t child, struct resource *r, rman_res_t start, rman_res_t end); int bus_translate_resource(device_t child, int type, rman_res_t start, rman_res_t *newstart); @@ -614,7 +614,7 @@ } /* Compat shims for simpler bus resource API. */ -int bus_adjust_resource_new(device_t child, struct resource *r, +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); @@ -627,8 +627,8 @@ #define _BUS_API_MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME #define bus_adjust_resource(...) \ - _BUS_API_MACRO(__VA_ARGS__, bus_adjust_resource, \ - bus_adjust_resource_new)(__VA_ARGS__) + _BUS_API_MACRO(__VA_ARGS__, bus_adjust_resource_old, \ + bus_adjust_resource)(__VA_ARGS__) #define bus_activate_resource(...) \ _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_activate_resource, \ 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 @@ -58,7 +58,7 @@ struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); -int legacy_pcib_adjust_resource(device_t dev, device_t child, int type, +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); 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 @@ -607,13 +607,13 @@ #if defined(NEW_PCIB) && defined(PCI_RES_BUS) int -legacy_pcib_adjust_resource(device_t dev, device_t child, int type, +legacy_pcib_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { - if (type == PCI_RES_BUS) + if (rman_get_type(r) == PCI_RES_BUS) return (pci_domain_adjust_bus(0, child, r, start, end)); - return (bus_generic_adjust_resource(dev, child, type, r, start, end)); + return (bus_generic_adjust_resource(dev, child, r, start, end)); } int diff --git a/sys/x86/x86/mptable_pci.c b/sys/x86/x86/mptable_pci.c --- a/sys/x86/x86/mptable_pci.c +++ b/sys/x86/x86/mptable_pci.c @@ -139,18 +139,17 @@ } static int -mptable_hostb_adjust_resource(device_t dev, device_t child, int type, +mptable_hostb_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end) { struct mptable_hostb_softc *sc; #ifdef PCI_RES_BUS - if (type == PCI_RES_BUS) + if (rman_get_type(r) == PCI_RES_BUS) return (pci_domain_adjust_bus(0, child, r, start, end)); #endif sc = device_get_softc(dev); - return (pcib_host_res_adjust(&sc->sc_host_res, child, type, r, start, - end)); + return (pcib_host_res_adjust(&sc->sc_host_res, child, r, start, end)); } #endif