git: fef01f0498aa - main - new-bus: Remove the 'type' argument from BUS_ADJUST_RESOURCE
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 13 Mar 2024 22:13:39 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=fef01f0498aa7b256bc37bbf28ee0e8ac9b2536f commit fef01f0498aa7b256bc37bbf28ee0e8ac9b2536f Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2024-03-13 22:05:54 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-03-13 22:05:54 +0000 new-bus: Remove the 'type' argument from BUS_ADJUST_RESOURCE The public bus_adjust_resource() API still accepts both forms, but the internal kobj method no longer passes the argument. Implementations which need the type now use rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44128 --- share/man/man9/bus_adjust_resource.9 | 15 ++++----------- sys/arm/mv/mv_pci.c | 13 ++++++------- sys/arm64/cavium/thunder_pcie_pem.c | 16 ++++++++-------- sys/dev/acpica/acpi.c | 4 ++-- sys/dev/acpica/acpi_pcib_acpi.c | 9 ++++----- sys/dev/bhnd/bhndb/bhndb.c | 6 +++--- sys/dev/bhnd/cores/chipc/chipc.c | 7 +++---- sys/dev/dpaa2/dpaa2_mc.c | 8 ++++---- sys/dev/dpaa2/dpaa2_mc.h | 2 +- sys/dev/fdt/simplebus.c | 14 +------------- sys/dev/hyperv/pcib/vmbus_pcib.c | 6 +++--- sys/dev/ofw/ofw_pcib.c | 12 ++++++------ sys/dev/pccbb/pccbb_pci.c | 6 +++--- sys/dev/pci/pci_host_generic.c | 10 +++++----- sys/dev/pci/pci_pci.c | 8 ++++---- sys/dev/pci/pci_subr.c | 10 +++++----- sys/dev/pci/pcib_private.h | 2 +- sys/dev/vmd/vmd.c | 10 ++++------ sys/kern/bus_if.m | 2 -- sys/kern/subr_bus.c | 21 ++++++++++----------- sys/powerpc/mpc85xx/lbc.c | 16 ++++++---------- sys/powerpc/powermac/macio.c | 15 +++++++-------- sys/powerpc/powermac/uninorth.c | 15 +++++++-------- sys/powerpc/psim/iobus.c | 15 +++++++-------- sys/sys/bus.h | 12 ++++++------ sys/x86/include/legacyvar.h | 2 +- sys/x86/pci/pci_bus.c | 6 +++--- sys/x86/x86/mptable_pci.c | 7 +++---- 28 files changed, 117 insertions(+), 152 deletions(-) diff --git a/share/man/man9/bus_adjust_resource.9 b/share/man/man9/bus_adjust_resource.9 index 6afc31cfb35c..27173894e0ec 100644 --- 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 @@ should have been allocated by a previous call to .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 @@ Grow an existing memory resource by 4096 bytes. 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 index 76da1c4da7a7..42ee3180a942 100644 --- a/sys/arm/mv/mv_pci.c +++ b/sys/arm/mv/mv_pci.c @@ -345,7 +345,7 @@ static int mv_pcib_attach(device_t); 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 @@ mv_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, } 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 index 5060b6e79d97..78fcf333d825 100644 --- 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 @@ thunder_pem_unmap_resource(device_t dev, device_t child, int type, } 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 index 0ea9a32b1589..93bce7df70d5 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1570,13 +1570,13 @@ acpi_managed_resource(device_t bus, int type, struct resource *r) } 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 index 451a8d8b736d..235670076dae 100644 --- a/sys/dev/acpica/acpi_pcib_acpi.c +++ b/sys/dev/acpica/acpi_pcib_acpi.c @@ -97,7 +97,7 @@ static struct resource *acpi_pcib_acpi_alloc_resource(device_t dev, 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 @@ acpi_pcib_acpi_alloc_resource(device_t dev, device_t child, int type, int *rid, #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 index ea5230bf459b..f8a1467894d1 100644 --- a/sys/dev/bhnd/bhndb/bhndb.c +++ b/sys/dev/bhnd/bhndb/bhndb.c @@ -1080,7 +1080,7 @@ bhndb_release_resource(device_t dev, device_t child, int type, int rid, * 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 @@ bhndb_adjust_resource(device_t dev, device_t child, int type, /* 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 index f99f42fb3ac3..2d1440e5c987 100644 --- a/sys/dev/bhnd/cores/chipc/chipc.c +++ b/sys/dev/bhnd/cores/chipc/chipc.c @@ -913,7 +913,7 @@ chipc_release_resource(device_t dev, device_t child, int type, int rid, } 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 @@ chipc_adjust_resource(device_t dev, device_t child, int type, sc = device_get_softc(dev); /* Handled by parent bus? */ - rm = chipc_get_rman(dev, type, rman_get_flags(r)); + rm = chipc_get_rman(dev, rman_get_type(r), rman_get_flags(r)); if (rm == NULL || !rman_is_region_manager(r, rm)) { - return (bus_generic_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.c b/sys/dev/dpaa2/dpaa2_mc.c index 6d11e50b1f98..0dbb282399ae 100644 --- a/sys/dev/dpaa2/dpaa2_mc.c +++ b/sys/dev/dpaa2/dpaa2_mc.c @@ -343,16 +343,16 @@ dpaa2_mc_alloc_resource(device_t mcdev, device_t child, int type, int *rid, } 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/dpaa2/dpaa2_mc.h b/sys/dev/dpaa2/dpaa2_mc.h index 40b318c4c9e7..23b18f8d2ca6 100644 --- a/sys/dev/dpaa2/dpaa2_mc.h +++ b/sys/dev/dpaa2/dpaa2_mc.h @@ -183,7 +183,7 @@ struct rman *dpaa2_mc_rman(device_t mcdev, int type, u_int flags); 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/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index ceb5fdde4bb7..940f93f56274 100644 --- 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 @@ static device_method_t simplebus_methods[] = { 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 @@ simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid, 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 index 3fa349b0c0c5..3d3041ee76b3 100644 --- a/sys/dev/hyperv/pcib/vmbus_pcib.c +++ b/sys/dev/hyperv/pcib/vmbus_pcib.c @@ -1713,15 +1713,15 @@ vmbus_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, } 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 index f8d0fc8e7029..e95a5f029140 100644 --- a/sys/dev/ofw/ofw_pcib.c +++ b/sys/dev/ofw/ofw_pcib.c @@ -73,7 +73,7 @@ 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_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 @@ ofw_pcib_deactivate_resource(device_t bus, device_t child, int type, int rid, } 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 @@ ofw_pcib_adjust_resource(device_t bus, device_t child, int type, 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 @@ ofw_pcib_adjust_resource(device_t bus, device_t child, int type, #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 index 1a07ff8a4e98..08014fb210ed 100644 --- a/sys/dev/pccbb/pccbb_pci.c +++ b/sys/dev/pccbb/pccbb_pci.c @@ -803,18 +803,18 @@ cbb_pci_alloc_resource(device_t bus, device_t child, int type, int *rid, } 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 index da49edcf91f5..f4fccc7b8277 100644 --- a/sys/dev/pci/pci_host_generic.c +++ b/sys/dev/pci/pci_host_generic.c @@ -614,7 +614,7 @@ generic_pcie_deactivate_resource(device_t dev, device_t child, int type, } 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 @@ generic_pcie_adjust_resource(device_t dev, device_t child, int type, 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 @@ generic_pcie_adjust_resource(device_t dev, device_t child, int type, #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 index da09a917b9bc..b4c02bfeca37 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -2372,23 +2372,23 @@ pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, } 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 index e2583a75e303..4be3e3f166eb 100644 --- a/sys/dev/pci/pci_subr.c +++ b/sys/dev/pci/pci_subr.c @@ -260,26 +260,26 @@ restart: } 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 index bc0b48d9f031..1f4f18d921e5 100644 --- a/sys/dev/pci/pcib_private.h +++ b/sys/dev/pci/pcib_private.h @@ -56,7 +56,7 @@ struct resource *pcib_host_res_alloc(struct pcib_host_resources *hr, 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 index d885cd15ac26..c258ef7a7047 100644 --- a/sys/dev/vmd/vmd.c +++ b/sys/dev/vmd/vmd.c @@ -469,16 +469,14 @@ vmd_alloc_resource(device_t dev, device_t child, int type, int *rid, } 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 index 7078683911b8..497b98ca4601 100644 --- a/sys/kern/bus_if.m +++ b/sys/kern/bus_if.m @@ -399,7 +399,6 @@ METHOD int deactivate_resource { * * @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 deactivate_resource { 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 index 25cb5fba2108..33d7b1e4af88 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -3877,13 +3877,12 @@ bus_generic_resume_intr(device_t dev, device_t child, struct resource *irq) * 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_generic_rman_alloc_resource(device_t dev, device_t child, int type, * 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 @@ bus_alloc_resource(device_t dev, int type, int *rid, rman_res_t start, * 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 index f6f38f22beb6..afac89b7597a 100644 --- a/sys/powerpc/mpc85xx/lbc.c +++ b/sys/powerpc/mpc85xx/lbc.c @@ -81,7 +81,7 @@ static int lbc_deactivate_resource(device_t bus, 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 @@ lbc_print_child(device_t dev, device_t child) } 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 index f6ad815064e8..b443f277ec89 100644 --- a/sys/powerpc/powermac/macio.c +++ b/sys/powerpc/powermac/macio.c @@ -84,7 +84,7 @@ static struct rman *macio_get_rman(device_t, int, u_int); 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 @@ macio_alloc_resource(device_t bus, device_t child, int type, int *rid, } 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 index b64bbc8ade62..b9cb4814b986 100644 --- a/sys/powerpc/powermac/uninorth.c +++ b/sys/powerpc/powermac/uninorth.c @@ -75,7 +75,7 @@ static struct rman *unin_chip_get_rman(device_t, int, u_int); 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 @@ unin_chip_alloc_resource(device_t bus, device_t child, int type, int *rid, } 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 index eea0255aa21c..79befbc8bd86 100644 --- a/sys/powerpc/psim/iobus.c +++ b/sys/powerpc/psim/iobus.c @@ -74,7 +74,7 @@ static struct rman *iobus_get_rman(device_t, int, u_int); 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 @@ iobus_alloc_resource(device_t bus, device_t child, int type, int *rid, } 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 index 6fcd414dc7be..310b3646f49f 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -432,7 +432,7 @@ int bus_generic_activate_resource(device_t dev, device_t child, int type, 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 @@ struct resource * 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 @@ int bus_alloc_resources(device_t dev, struct resource_spec *rs, 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 @@ bus_alloc_resource_anywhere(device_t dev, int type, int *rid, } /* 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 @@ int bus_release_resource_new(device_t dev, struct resource *r); #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 index 5627e9b90306..789c6c55f198 100644 --- a/sys/x86/include/legacyvar.h +++ b/sys/x86/include/legacyvar.h @@ -58,7 +58,7 @@ int legacy_pcib_write_ivar(device_t dev, device_t child, int which, 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 index cfe0a3974187..c7715c47d3c8 100644 --- a/sys/x86/pci/pci_bus.c +++ b/sys/x86/pci/pci_bus.c @@ -607,13 +607,13 @@ legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, #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 index 5792b0cb7387..de659ca75163 100644 --- a/sys/x86/x86/mptable_pci.c +++ b/sys/x86/x86/mptable_pci.c @@ -139,18 +139,17 @@ mptable_hostb_alloc_resource(device_t dev, device_t child, int type, int *rid, } 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