From nobody Wed Mar 13 22:13:41 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Tw4Xj218Pz5DXVW; Wed, 13 Mar 2024 22:13:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Tw4Xj1DyJz4qmj; Wed, 13 Mar 2024 22:13:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710368021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qEOvfBixTZxKATR8XJx7qnkPe6bIpy+hbOM6RMc6g3M=; b=DqEi+uIh5Y78ryuzm1eBLRcMPtZk0DgR9QyjNzJLySnTM5MsCm9jIQpCdEZmJGSCY3IVhf Ip4oMD78P4rlL59+Cq3qjUcioSFejL672Tdvxim0hjhpCiqDrzOYs8rgbNb3o7Z5MuRIlw VGg6TTp9lIX5ke3miJtcJl2TCSy8PG2jBaLzetzNmWrRqfmD/dh8sbdslVteZKU5azFlRv HW2AEmQ2O7+fJASAcCwjG2YNCejHlWeC1mP8aGmLqwWKEMmRnasRdu8BvLgDgGB6PmO6yt PYXgWBck0zZ8Tsl9WzvsiP8nuaCMKxhwQqShJfpGiTJD/ZsIzZB8BPyvfq/Frg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710368021; a=rsa-sha256; cv=none; b=cMyjQKXmTMILHl8Oge64RuEi53GPS8H1TK3PnyxeUC/v+Bi9GZZT4JCjFn0Sf+o32Akwa8 vHxsMTyjj9FkGDB+tGQDejglXzlb76BgTFXepxsSJY0Ht+0PX/3bekqGkIAZXpzYuHEGyP 3SEnSkIMSdniGhI5T3Iu6vJOx5DoTBfdOgPFcoErMlpfMAvYFpFWiKxvMs2UJy0AwR+ZnP rlOzNQuXvXrrFXA07k2sT4I8z0jy9GtM1w0RGla9Jg7w8Qirt6GgWftJwQWAdbKQviGJHx ieE8U4WeyPPNGhTCW2pLQcQz58m6/frs2kKMOkgfIRfpDz/fUTOVkYLHK+vIQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710368021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qEOvfBixTZxKATR8XJx7qnkPe6bIpy+hbOM6RMc6g3M=; b=cQaaCv+/pAu1rGnKEIuYE/m9uMH/7M3COVIgpvSW9pWdYxdMUc5VyazCLL+/FsWf7yOkUS zvzVVvdqd3b4IrUBxrxtAt+yXymoo0GKHfLAKjWCtqyPtjo1boaerpM1ZzIfUz5QC3Ici3 Vs2CdtZ3xlSIqgKWP2jPib/kH+SNoJeBxDFAuyv8bv7zjsHAcdRYoeWWeMs3g11SARAhsr VbCL5pPwyIQlxkolmvRASfhZdyPE6Ku+IqemwwfmX/pC3i1M9qm41EJqqdjdfTYwwPe6FL WgWE83blDG1Mz3atASmsbNcH4RBJSlLgIB1eZCP25raeh7fVpCtoYsXBV4jm2Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Tw4Xj0qNPz11hn; Wed, 13 Mar 2024 22:13:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 42DMDfAd075092; Wed, 13 Mar 2024 22:13:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42DMDfJc075089; Wed, 13 Mar 2024 22:13:41 GMT (envelope-from git) Date: Wed, 13 Mar 2024 22:13:41 GMT Message-Id: <202403132213.42DMDfJc075089@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: d77f2092ceeb - main - new-bus: Remove the 'type' argument from BUS_MAP/UNMAP_RESOURCE List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d77f2092ceebaba115e6be53410428f6f5f6ae83 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d77f2092ceebaba115e6be53410428f6f5f6ae83 commit d77f2092ceebaba115e6be53410428f6f5f6ae83 Author: John Baldwin AuthorDate: 2024-03-13 22:05:54 +0000 Commit: John Baldwin CommitDate: 2024-03-13 22:05:54 +0000 new-bus: Remove the 'type' argument from BUS_MAP/UNMAP_RESOURCE The public bus_map/unmap_resource() API still accepts both forms, but the internal kobj methods no longer pass 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/D44129 --- share/man/man9/bus_map_resource.9 | 16 +++------------- sys/arm/arm/nexus.c | 8 ++++---- sys/arm/mv/mv_pci.c | 14 +++++++------- sys/arm64/arm64/nexus.c | 11 +++++------ sys/arm64/cavium/thunder_pcie_pem.c | 19 +++++++++---------- sys/dev/acpica/acpi.c | 19 +++++++++---------- sys/dev/fdt/simplebus.c | 30 ++---------------------------- sys/dev/ofw/ofw_pcib.c | 19 +++++++++---------- sys/dev/pci/pci_host_generic.c | 22 +++++++++++----------- sys/dev/pci/pci_pci.c | 15 +++++++-------- sys/dev/vmd/vmd.c | 8 ++++---- sys/kern/bus_if.m | 4 ---- sys/kern/subr_bus.c | 35 ++++++++++++++++------------------- sys/powerpc/mpc85xx/lbc.c | 12 ++++++------ sys/powerpc/powermac/macio.c | 17 ++++++++--------- sys/powerpc/powermac/uninorth.c | 17 ++++++++--------- sys/powerpc/powerpc/nexus.c | 10 +++++----- sys/powerpc/ps3/ps3bus.c | 14 +++++++------- sys/powerpc/psim/iobus.c | 12 ++++++------ sys/riscv/riscv/nexus.c | 8 ++++---- sys/sys/bus.h | 25 +++++++++++++------------ sys/x86/x86/nexus.c | 9 +++++---- 22 files changed, 148 insertions(+), 196 deletions(-) diff --git a/share/man/man9/bus_map_resource.9 b/share/man/man9/bus_map_resource.9 index bf86e7805964..5cccb815b73b 100644 --- a/share/man/man9/bus_map_resource.9 +++ b/share/man/man9/bus_map_resource.9 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 5, 2018 +.Dd March 13, 2024 .Dt BUS_MAP_RESOURCE 9 .Os .Sh NAME @@ -38,12 +38,12 @@ .In machine/resource.h .Ft int .Fo bus_map_resource -.Fa "device_t dev" "int type" "struct resource *r" +.Fa "device_t dev" "struct resource *r" .Fa "struct resource_map_request *args" "struct resource_map *map" .Fc .Ft int .Fo bus_unmap_resource -.Fa "device_t dev" "int type" "struct resource *r" "struct resource_map *map" +.Fa "device_t dev" "struct resource *r" "struct resource_map *map" .Fc .Ft void .Fn resource_init_map_request "struct resource_map_request *args" @@ -58,16 +58,6 @@ The arguments are as follows: .Bl -tag -width indent .It Fa dev The device that owns the resource. -.It Fa type -The type of resource to map. -It is one of: -.Pp -.Bl -tag -width ".Dv SYS_RES_MEMORY" -compact -.It Dv SYS_RES_IOPORT -for I/O ports -.It Dv SYS_RES_MEMORY -for I/O memory -.El .It Fa r A pointer to the .Vt "struct resource" diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c index eb0d1a5b7ded..0cb896ce346e 100644 --- a/sys/arm/arm/nexus.c +++ b/sys/arm/arm/nexus.c @@ -331,7 +331,7 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid, } static int -nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, +nexus_map_resource(device_t bus, device_t child, struct resource *r, struct resource_map_request *argsp, struct resource_map *map) { struct resource_map_request args; @@ -342,7 +342,7 @@ nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, if (!(rman_get_flags(r) & RF_ACTIVE)) return (ENXIO); - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_MEMORY: case SYS_RES_IOPORT: break; @@ -374,11 +374,11 @@ nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, } static int -nexus_unmap_resource(device_t bus, device_t child, int type, struct resource *r, +nexus_unmap_resource(device_t bus, device_t child, struct resource *r, struct resource_map *map) { - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_MEMORY: case SYS_RES_IOPORT: #ifdef FDT diff --git a/sys/arm/mv/mv_pci.c b/sys/arm/mv/mv_pci.c index 42ee3180a942..a8a6d1d50002 100644 --- a/sys/arm/mv/mv_pci.c +++ b/sys/arm/mv/mv_pci.c @@ -353,9 +353,9 @@ 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_map_resource(device_t, device_t, int, 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, int, struct resource *, +static int mv_pcib_unmap_resource(device_t, device_t, struct resource *, struct resource_map *); static int mv_pcib_read_ivar(device_t, device_t, int, uintptr_t *); static int mv_pcib_write_ivar(device_t, device_t, int, uintptr_t); @@ -1034,7 +1034,7 @@ mv_pcib_deactivate_resource(device_t dev, device_t child, int type, int rid, } static int -mv_pcib_map_resource(device_t dev, device_t child, int type, struct resource *r, +mv_pcib_map_resource(device_t dev, device_t child, struct resource *r, struct resource_map_request *argsp, struct resource_map *map) { struct resource_map_request args; @@ -1046,7 +1046,7 @@ mv_pcib_map_resource(device_t dev, device_t child, int type, struct resource *r, return (ENXIO); /* Mappings are only supported on I/O and memory resources. */ - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: break; @@ -1066,10 +1066,10 @@ mv_pcib_map_resource(device_t dev, device_t child, int type, struct resource *r, } static int -mv_pcib_unmap_resource(device_t dev, device_t child, int type, - struct resource *r, struct resource_map *map) +mv_pcib_unmap_resource(device_t dev, device_t child, struct resource *r, + struct resource_map *map) { - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: return (0); diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c index d2081d40d26a..ed500ba5ea6d 100644 --- a/sys/arm64/arm64/nexus.c +++ b/sys/arm64/arm64/nexus.c @@ -350,8 +350,7 @@ nexus_activate_resource_flags(device_t bus, device_t child, int type, int rid, &use_np); if (use_np) args.memattr = VM_MEMATTR_DEVICE_NP; - err = nexus_map_resource(bus, child, type, r, &args, - &map); + err = nexus_map_resource(bus, child, r, &args, &map); if (err != 0) { rman_deactivate_resource(r); return (err); @@ -408,7 +407,7 @@ nexus_deactivate_resource(device_t bus, device_t child, int type, int rid, } static int -nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, +nexus_map_resource(device_t bus, device_t child, struct resource *r, struct resource_map_request *argsp, struct resource_map *map) { struct resource_map_request args; @@ -420,7 +419,7 @@ nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, return (ENXIO); /* Mappings are only supported on I/O and memory resources. */ - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: break; @@ -445,11 +444,11 @@ nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, } static int -nexus_unmap_resource(device_t bus, device_t child, int type, struct resource *r, +nexus_unmap_resource(device_t bus, device_t child, struct resource *r, struct resource_map *map) { - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_MEMORY: case SYS_RES_IOPORT: pmap_unmapdev(map->r_vaddr, map->r_size); diff --git a/sys/arm64/cavium/thunder_pcie_pem.c b/sys/arm64/cavium/thunder_pcie_pem.c index 78fcf333d825..b53f70696ff1 100644 --- a/sys/arm64/cavium/thunder_pcie_pem.c +++ b/sys/arm64/cavium/thunder_pcie_pem.c @@ -136,10 +136,10 @@ static int thunder_pem_get_id(device_t, device_t, enum pci_id_type, static int thunder_pem_attach(device_t); static int thunder_pem_deactivate_resource(device_t, device_t, int, int, struct resource *); -static int thunder_pem_map_resource(device_t, device_t, int, struct resource *, +static int thunder_pem_map_resource(device_t, device_t, struct resource *, struct resource_map_request *, struct resource_map *); -static int thunder_pem_unmap_resource(device_t, device_t, int, - struct resource *, struct resource_map *); +static int thunder_pem_unmap_resource(device_t, device_t, struct resource *, + struct resource_map *); static bus_dma_tag_t thunder_pem_get_dma_tag(device_t, device_t); static int thunder_pem_detach(device_t); static uint64_t thunder_pem_config_reg_read(struct thunder_pem_softc *, int); @@ -302,9 +302,8 @@ thunder_pem_deactivate_resource(device_t dev, device_t child, int type, int rid, } static int -thunder_pem_map_resource(device_t dev, device_t child, int type, - struct resource *r, struct resource_map_request *argsp, - struct resource_map *map) +thunder_pem_map_resource(device_t dev, device_t child, struct resource *r, + struct resource_map_request *argsp, struct resource_map *map) { struct resource_map_request args; struct thunder_pem_softc *sc; @@ -315,7 +314,7 @@ thunder_pem_map_resource(device_t dev, device_t child, int type, if (!(rman_get_flags(r) & RF_ACTIVE)) return (ENXIO); - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_MEMORY: case SYS_RES_IOPORT: break; @@ -340,11 +339,11 @@ thunder_pem_map_resource(device_t dev, device_t child, int type, } static int -thunder_pem_unmap_resource(device_t dev, device_t child, int type, - struct resource *r, struct resource_map *map) +thunder_pem_unmap_resource(device_t dev, device_t child, struct resource *r, + struct resource_map *map) { - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_MEMORY: case SYS_RES_IOPORT: bus_space_unmap(map->r_bustag, map->r_bushandle, map->r_size); diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 93bce7df70d5..ab34009bf654 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1551,7 +1551,7 @@ acpi_is_resource_managed(device_t bus, struct resource *r) } static struct resource * -acpi_managed_resource(device_t bus, int type, struct resource *r) +acpi_managed_resource(device_t bus, struct resource *r) { struct acpi_softc *sc = device_get_softc(bus); struct resource_list_entry *rle; @@ -1560,7 +1560,7 @@ acpi_managed_resource(device_t bus, int type, struct resource *r) ("resource %p is not suballocated", r)); STAILQ_FOREACH(rle, &sc->sysres_rl, link) { - if (rle->type != type || rle->res == NULL) + if (rle->type != rman_get_type(r) || rle->res == NULL) continue; if (rman_get_start(r) >= rman_get_start(rle->res) && rman_get_end(r) <= rman_get_end(rle->res)) @@ -1630,7 +1630,7 @@ acpi_deactivate_resource(device_t bus, device_t child, int type, int rid, } static int -acpi_map_resource(device_t bus, device_t child, int type, struct resource *r, +acpi_map_resource(device_t bus, device_t child, struct resource *r, struct resource_map_request *argsp, struct resource_map *map) { struct resource_map_request args; @@ -1639,8 +1639,7 @@ acpi_map_resource(device_t bus, device_t child, int type, struct resource *r, int error; if (!acpi_is_resource_managed(bus, r)) - return (bus_generic_map_resource(bus, child, type, r, argsp, - map)); + return (bus_generic_map_resource(bus, child, r, argsp, map)); /* Resources must be active to be mapped. */ if (!(rman_get_flags(r) & RF_ACTIVE)) @@ -1651,25 +1650,25 @@ acpi_map_resource(device_t bus, device_t child, int type, struct resource *r, if (error) return (error); - sysres = acpi_managed_resource(bus, type, r); + sysres = acpi_managed_resource(bus, r); if (sysres == NULL) return (ENOENT); args.offset = start - rman_get_start(sysres); args.length = length; - return (bus_generic_map_resource(bus, child, type, sysres, &args, map)); + return (bus_generic_map_resource(bus, child, sysres, &args, map)); } static int -acpi_unmap_resource(device_t bus, device_t child, int type, struct resource *r, +acpi_unmap_resource(device_t bus, device_t child, struct resource *r, struct resource_map *map) { if (acpi_is_resource_managed(bus, r)) { - r = acpi_managed_resource(bus, type, r); + r = acpi_managed_resource(bus, r); if (r == NULL) return (ENOENT); } - return (bus_generic_unmap_resource(bus, child, type, r, map)); + return (bus_generic_unmap_resource(bus, child, r, map)); } /* Allocate an IO port or memory resource, given its GAS. */ diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index 940f93f56274..2bd1a1402797 100644 --- a/sys/dev/fdt/simplebus.c +++ b/sys/dev/fdt/simplebus.c @@ -52,11 +52,6 @@ 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 int simplebus_map_resource(device_t bus, device_t child, - int type, struct resource *r, struct resource_map_request *args, - struct resource_map *map); -static int simplebus_unmap_resource(device_t bus, device_t child, - int type, struct resource *r, struct resource_map *map); 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, @@ -98,8 +93,8 @@ static device_method_t simplebus_methods[] = { DEVMETHOD(bus_activate_resource, simplebus_activate_resource), DEVMETHOD(bus_deactivate_resource, simplebus_deactivate_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_map_resource, bus_generic_map_resource), + DEVMETHOD(bus_unmap_resource, bus_generic_unmap_resource), DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), DEVMETHOD(bus_delete_resource, bus_generic_rl_delete_resource), @@ -524,27 +519,6 @@ simplebus_deactivate_resource(device_t bus, device_t child, int type, int rid, return (bus_generic_deactivate_resource(bus, child, type, rid, r)); } -static int -simplebus_map_resource(device_t bus, device_t child, int type, - struct resource *r, struct resource_map_request *args, - struct resource_map *map) -{ - - if (type == SYS_RES_IOPORT) - type = SYS_RES_MEMORY; - return (bus_generic_map_resource(bus, child, type, r, args, map)); -} - -static int -simplebus_unmap_resource(device_t bus, device_t child, int type, - struct resource *r, struct resource_map *map) -{ - - if (type == SYS_RES_IOPORT) - type = SYS_RES_MEMORY; - return (bus_generic_unmap_resource(bus, child, type, r, map)); -} - static int simplebus_print_res(struct simplebus_devinfo *di) { diff --git a/sys/dev/ofw/ofw_pcib.c b/sys/dev/ofw/ofw_pcib.c index e95a5f029140..4f373030dc33 100644 --- a/sys/dev/ofw/ofw_pcib.c +++ b/sys/dev/ofw/ofw_pcib.c @@ -75,9 +75,9 @@ static int ofw_pcib_deactivate_resource(device_t, device_t, int, int, 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, int, struct resource *, +static int ofw_pcib_map_resource(device_t, device_t, struct resource *, struct resource_map_request *, struct resource_map *); -static int ofw_pcib_unmap_resource(device_t, device_t, int, struct resource *, +static int ofw_pcib_unmap_resource(device_t, device_t, struct resource *, struct resource_map *); static int ofw_pcib_translate_resource(device_t bus, int type, rman_res_t start, rman_res_t *newstart); @@ -535,9 +535,8 @@ ofw_pcib_activate_resource(device_t bus, device_t child, int type, int rid, } static int -ofw_pcib_map_resource(device_t dev, device_t child, int type, - struct resource *r, struct resource_map_request *argsp, - struct resource_map *map) +ofw_pcib_map_resource(device_t dev, device_t child, struct resource *r, + struct resource_map_request *argsp, struct resource_map *map) { struct resource_map_request args; struct ofw_pci_softc *sc; @@ -549,7 +548,7 @@ ofw_pcib_map_resource(device_t dev, device_t child, int type, if (!(rman_get_flags(r) & RF_ACTIVE)) return (ENXIO); - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_MEMORY: case SYS_RES_IOPORT: break; @@ -583,7 +582,7 @@ ofw_pcib_map_resource(device_t dev, device_t child, int type, space = -1; } - if (type == space) { + if (rman_get_type(r) == space) { start += (rp->host - rp->pci); break; } @@ -608,10 +607,10 @@ ofw_pcib_map_resource(device_t dev, device_t child, int type, } static int -ofw_pcib_unmap_resource(device_t dev, device_t child, int type, - struct resource *r, struct resource_map *map) +ofw_pcib_unmap_resource(device_t dev, device_t child, struct resource *r, + struct resource_map *map) { - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_MEMORY: case SYS_RES_IOPORT: bus_space_unmap(map->r_bustag, map->r_bushandle, map->r_size); diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c index f4fccc7b8277..3657be018c99 100644 --- a/sys/dev/pci/pci_host_generic.c +++ b/sys/dev/pci/pci_host_generic.c @@ -639,15 +639,15 @@ generic_pcie_adjust_resource(device_t dev, device_t child, } static int -generic_pcie_map_resource(device_t dev, device_t child, int type, - struct resource *r, struct resource_map_request *argsp, - struct resource_map *map) +generic_pcie_map_resource(device_t dev, device_t child, struct resource *r, + struct resource_map_request *argsp, struct resource_map *map) { struct resource_map_request args; struct pcie_range *range; rman_res_t length, start; - int error; + int error, type; + type = rman_get_type(r); switch (type) { #if defined(NEW_PCIB) && defined(PCI_RES_BUS) case PCI_RES_BUS: @@ -657,8 +657,7 @@ generic_pcie_map_resource(device_t dev, device_t child, int type, case SYS_RES_MEMORY: break; default: - return (bus_generic_map_resource(dev, child, type, r, argsp, - map)); + return (bus_generic_map_resource(dev, child, r, argsp, map)); } /* Resources must be active to be mapped. */ @@ -677,16 +676,17 @@ generic_pcie_map_resource(device_t dev, device_t child, int type, args.offset = start - range->pci_base; args.length = length; - return (bus_generic_map_resource(dev, child, type, range->res, &args, - map)); + return (bus_generic_map_resource(dev, child, range->res, &args, map)); } static int -generic_pcie_unmap_resource(device_t dev, device_t child, int type, - struct resource *r, struct resource_map *map) +generic_pcie_unmap_resource(device_t dev, device_t child, struct resource *r, + struct resource_map *map) { struct pcie_range *range; + int type; + type = rman_get_type(r); switch (type) { #if defined(NEW_PCIB) && defined(PCI_RES_BUS) case PCI_RES_BUS: @@ -703,7 +703,7 @@ generic_pcie_unmap_resource(device_t dev, device_t child, int type, default: break; } - return (bus_generic_unmap_resource(dev, child, type, r, map)); + return (bus_generic_unmap_resource(dev, child, r, map)); } static bus_dma_tag_t diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index b4c02bfeca37..146b67c70801 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -2476,7 +2476,7 @@ pcib_activate_resource(device_t dev, device_t child, int type, int rid, if ((rman_get_flags(r) & RF_UNMAPPED) == 0 && (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT)) { - error = BUS_MAP_RESOURCE(dev, child, type, r, NULL, &map); + error = BUS_MAP_RESOURCE(dev, child, r, NULL, &map); if (error != 0) { rman_deactivate_resource(r); return (error); @@ -2506,7 +2506,7 @@ pcib_deactivate_resource(device_t dev, device_t child, int type, int rid, if ((rman_get_flags(r) & RF_UNMAPPED) == 0 && (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT)) { rman_get_mapping(r, &map); - BUS_UNMAP_RESOURCE(dev, child, type, r, &map); + BUS_UNMAP_RESOURCE(dev, child, r, &map); } return (0); } @@ -2523,7 +2523,7 @@ pcib_find_parent_resource(struct pcib_window *w, struct resource *r) } static int -pcib_map_resource(device_t dev, device_t child, int type, struct resource *r, +pcib_map_resource(device_t dev, device_t child, struct resource *r, struct resource_map_request *argsp, struct resource_map *map) { struct pcib_softc *sc = device_get_softc(dev); @@ -2535,8 +2535,7 @@ pcib_map_resource(device_t dev, device_t child, int type, struct resource *r, w = pcib_get_resource_window(sc, r); if (w == NULL) - return (bus_generic_map_resource(dev, child, type, r, argsp, - map)); + return (bus_generic_map_resource(dev, child, r, argsp, map)); /* Resources must be active to be mapped. */ if (!(rman_get_flags(r) & RF_ACTIVE)) @@ -2553,11 +2552,11 @@ pcib_map_resource(device_t dev, device_t child, int type, struct resource *r, args.offset = start - rman_get_start(pres); args.length = length; - return (bus_generic_map_resource(dev, child, type, pres, &args, map)); + return (bus_generic_map_resource(dev, child, pres, &args, map)); } static int -pcib_unmap_resource(device_t dev, device_t child, int type, struct resource *r, +pcib_unmap_resource(device_t dev, device_t child, struct resource *r, struct resource_map *map) { struct pcib_softc *sc = device_get_softc(dev); @@ -2569,7 +2568,7 @@ pcib_unmap_resource(device_t dev, device_t child, int type, struct resource *r, if (r == NULL) return (ENOENT); } - return (bus_generic_unmap_resource(dev, child, type, r, map)); + return (bus_generic_unmap_resource(dev, child, r, map)); } #else /* diff --git a/sys/dev/vmd/vmd.c b/sys/dev/vmd/vmd.c index c258ef7a7047..a0a021c7d367 100644 --- a/sys/dev/vmd/vmd.c +++ b/sys/dev/vmd/vmd.c @@ -525,7 +525,7 @@ vmd_find_parent_resource(struct vmd_softc *sc, struct resource *r) } static int -vmd_map_resource(device_t dev, device_t child, int type, struct resource *r, +vmd_map_resource(device_t dev, device_t child, struct resource *r, struct resource_map_request *argsp, struct resource_map *map) { struct vmd_softc *sc = device_get_softc(dev); @@ -549,11 +549,11 @@ vmd_map_resource(device_t dev, device_t child, int type, struct resource *r, args.offset = start - rman_get_start(pres); args.length = length; - return (bus_generic_map_resource(dev, child, type, pres, &args, map)); + return (bus_generic_map_resource(dev, child, pres, &args, map)); } static int -vmd_unmap_resource(device_t dev, device_t child, int type, struct resource *r, +vmd_unmap_resource(device_t dev, device_t child, struct resource *r, struct resource_map *map) { struct vmd_softc *sc = device_get_softc(dev); @@ -561,7 +561,7 @@ vmd_unmap_resource(device_t dev, device_t child, int type, struct resource *r, r = vmd_find_parent_resource(sc, r); if (r == NULL) return (ENOENT); - return (bus_generic_unmap_resource(dev, child, type, r, map)); + return (bus_generic_unmap_resource(dev, child, r, map)); } static int diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m index 497b98ca4601..375aeebd1835 100644 --- a/sys/kern/bus_if.m +++ b/sys/kern/bus_if.m @@ -332,7 +332,6 @@ METHOD int activate_resource { * * @param _dev the parent device of @p _child * @param _child the device which allocated the resource - * @param _type the type of resource * @param _r the resource to map * @param _args optional attributes of the mapping * @param _map the mapping @@ -340,7 +339,6 @@ METHOD int activate_resource { METHOD int map_resource { device_t _dev; device_t _child; - int _type; struct resource *_r; struct resource_map_request *_args; struct resource_map *_map; @@ -356,14 +354,12 @@ METHOD int map_resource { * * @param _dev the parent device of @p _child * @param _child the device which allocated the resource - * @param _type the type of resource * @param _r the resource * @param _map the mapping to release */ METHOD int unmap_resource { device_t _dev; device_t _child; - int _type; struct resource *_r; struct resource_map *_map; } DEFAULT bus_generic_unmap_resource; diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 33d7b1e4af88..34712ae511e5 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -3979,14 +3979,12 @@ bus_generic_deactivate_resource(device_t dev, device_t child, int type, * BUS_MAP_RESOURCE() method of the parent of @p dev. */ int -bus_generic_map_resource(device_t dev, device_t child, int type, - struct resource *r, struct resource_map_request *args, - struct resource_map *map) +bus_generic_map_resource(device_t dev, device_t child, struct resource *r, + struct resource_map_request *args, struct resource_map *map) { /* Propagate up the bus hierarchy until someone handles it. */ if (dev->parent) - return (BUS_MAP_RESOURCE(dev->parent, child, type, r, args, - map)); + return (BUS_MAP_RESOURCE(dev->parent, child, r, args, map)); return (EINVAL); } @@ -3997,12 +3995,12 @@ bus_generic_map_resource(device_t dev, device_t child, int type, * BUS_UNMAP_RESOURCE() method of the parent of @p dev. */ int -bus_generic_unmap_resource(device_t dev, device_t child, int type, - struct resource *r, struct resource_map *map) +bus_generic_unmap_resource(device_t dev, device_t child, struct resource *r, + struct resource_map *map) { /* Propagate up the bus hierarchy until someone handles it. */ if (dev->parent) - return (BUS_UNMAP_RESOURCE(dev->parent, child, type, r, map)); + return (BUS_UNMAP_RESOURCE(dev->parent, child, r, map)); return (EINVAL); } @@ -4339,7 +4337,7 @@ bus_generic_rman_activate_resource(device_t dev, device_t child, int type, if ((rman_get_flags(r) & RF_UNMAPPED) == 0 && (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT)) { - error = BUS_MAP_RESOURCE(dev, child, type, r, NULL, &map); + error = BUS_MAP_RESOURCE(dev, child, r, NULL, &map); if (error != 0) { rman_deactivate_resource(r); return (error); @@ -4379,7 +4377,7 @@ bus_generic_rman_deactivate_resource(device_t dev, device_t child, int type, if ((rman_get_flags(r) & RF_UNMAPPED) == 0 && (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT)) { rman_get_mapping(r, &map); - BUS_UNMAP_RESOURCE(dev, child, type, r, &map); + BUS_UNMAP_RESOURCE(dev, child, r, &map); } return (0); } @@ -4615,19 +4613,19 @@ bus_deactivate_resource_new(device_t dev, struct resource *r) * parent of @p dev. */ int -bus_map_resource(device_t dev, int type, struct resource *r, +bus_map_resource(device_t dev, struct resource *r, struct resource_map_request *args, struct resource_map *map) { if (dev->parent == NULL) return (EINVAL); - return (BUS_MAP_RESOURCE(dev->parent, dev, type, r, args, map)); + return (BUS_MAP_RESOURCE(dev->parent, dev, r, args, map)); } int -bus_map_resource_new(device_t dev, struct resource *r, +bus_map_resource_old(device_t dev, int type, struct resource *r, struct resource_map_request *args, struct resource_map *map) { - return (bus_map_resource(dev, rman_get_type(r), r, args, map)); + return (bus_map_resource(dev, r, args, map)); } /** @@ -4637,19 +4635,18 @@ bus_map_resource_new(device_t dev, struct resource *r, * parent of @p dev. */ int -bus_unmap_resource(device_t dev, int type, struct resource *r, - struct resource_map *map) +bus_unmap_resource(device_t dev, struct resource *r, struct resource_map *map) { if (dev->parent == NULL) return (EINVAL); - return (BUS_UNMAP_RESOURCE(dev->parent, dev, type, r, map)); + return (BUS_UNMAP_RESOURCE(dev->parent, dev, r, map)); } int -bus_unmap_resource_new(device_t dev, struct resource *r, +bus_unmap_resource_old(device_t dev, int type, struct resource *r, struct resource_map *map) { - return (bus_unmap_resource(dev, rman_get_type(r), r, map)); + return (bus_unmap_resource(dev, r, map)); } /** diff --git a/sys/powerpc/mpc85xx/lbc.c b/sys/powerpc/mpc85xx/lbc.c index afac89b7597a..20f0baf8c395 100644 --- a/sys/powerpc/mpc85xx/lbc.c +++ b/sys/powerpc/mpc85xx/lbc.c @@ -69,9 +69,9 @@ static MALLOC_DEFINE(M_LBC, "localbus", "localbus devices information"); static int lbc_probe(device_t); static int lbc_attach(device_t); static int lbc_shutdown(device_t); -static int lbc_map_resource(device_t, device_t, int, struct resource *, +static int lbc_map_resource(device_t, device_t, struct resource *, struct resource_map_request *, struct resource_map *); -static int lbc_unmap_resource(device_t, device_t, int, struct resource *, +static int lbc_unmap_resource(device_t, device_t, struct resource *, struct resource_map *map); static int lbc_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r); @@ -831,7 +831,7 @@ lbc_deactivate_resource(device_t bus, device_t child, int type, int rid, } static int -lbc_map_resource(device_t bus, device_t child, int type, struct resource *r, +lbc_map_resource(device_t bus, device_t child, struct resource *r, struct resource_map_request *argsp, struct resource_map *map) { struct resource_map_request args; @@ -843,7 +843,7 @@ lbc_map_resource(device_t bus, device_t child, int type, struct resource *r, return (ENXIO); /* Mappings are only supported on I/O and memory resources. */ - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: break; @@ -864,12 +864,12 @@ lbc_map_resource(device_t bus, device_t child, int type, struct resource *r, } static int -lbc_unmap_resource(device_t bus, device_t child, int type, struct resource *r, +lbc_unmap_resource(device_t bus, device_t child, struct resource *r, struct resource_map *map) { /* Mappings are only supported on I/O and memory resources. */ - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: break; diff --git a/sys/powerpc/powermac/macio.c b/sys/powerpc/powermac/macio.c index b443f277ec89..cb4471bbcca1 100644 --- a/sys/powerpc/powermac/macio.c +++ b/sys/powerpc/powermac/macio.c @@ -92,10 +92,10 @@ static int macio_deactivate_resource(device_t, device_t, int, int, struct resource *); static int macio_release_resource(device_t, device_t, int, int, struct resource *); -static int macio_map_resource(device_t, device_t, int, struct resource *, +static int macio_map_resource(device_t, device_t, struct resource *, struct resource_map_request *, struct resource_map *); -static int macio_unmap_resource(device_t, device_t, int, struct resource *, +static int macio_unmap_resource(device_t, device_t, struct resource *, struct resource_map *); static struct resource_list *macio_get_resource_list (device_t, device_t); static ofw_bus_get_devinfo_t macio_get_devinfo; @@ -663,9 +663,8 @@ macio_deactivate_resource(device_t bus, device_t child, int type, int rid, } static int -macio_map_resource(device_t bus, device_t child, int type, - struct resource *r, struct resource_map_request *argsp, - struct resource_map *map) +macio_map_resource(device_t bus, device_t child, struct resource *r, + struct resource_map_request *argsp, struct resource_map *map) { struct resource_map_request args; struct macio_softc *sc; @@ -677,7 +676,7 @@ macio_map_resource(device_t bus, device_t child, int type, return (ENXIO); /* Mappings are only supported on I/O and memory resources. */ - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: break; @@ -705,13 +704,13 @@ macio_map_resource(device_t bus, device_t child, int type, } static int -macio_unmap_resource(device_t bus, device_t child, int type, - struct resource *r, struct resource_map *map) +macio_unmap_resource(device_t bus, device_t child, struct resource *r, + struct resource_map *map) { /* * If this is a memory resource, unmap it. */ - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: pmap_unmapdev(map->r_vaddr, map->r_size); diff --git a/sys/powerpc/powermac/uninorth.c b/sys/powerpc/powermac/uninorth.c index b9cb4814b986..c7842311d730 100644 --- a/sys/powerpc/powermac/uninorth.c +++ b/sys/powerpc/powermac/uninorth.c @@ -82,10 +82,10 @@ static int unin_chip_activate_resource(device_t, device_t, int, int, struct resource *); static int unin_chip_deactivate_resource(device_t, device_t, int, int, struct resource *); -static int unin_chip_map_resource(device_t, device_t, int, struct resource *, +static int unin_chip_map_resource(device_t, device_t, struct resource *, struct resource_map_request *, struct resource_map *); -static int unin_chip_unmap_resource(device_t, device_t, int, struct resource *, +static int unin_chip_unmap_resource(device_t, device_t, struct resource *, struct resource_map *); static int unin_chip_release_resource(device_t, device_t, int, int, struct resource *); @@ -621,9 +621,8 @@ unin_chip_deactivate_resource(device_t bus, device_t child, int type, int rid, } static int -unin_chip_map_resource(device_t bus, device_t child, int type, - struct resource *r, struct resource_map_request *argsp, - struct resource_map *map) +unin_chip_map_resource(device_t bus, device_t child, struct resource *r, + struct resource_map_request *argsp, struct resource_map *map) { struct resource_map_request args; rman_res_t length, start; @@ -634,7 +633,7 @@ unin_chip_map_resource(device_t bus, device_t child, int type, return (ENXIO); /* Mappings are only supported on I/O and memory resources. */ - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: break; @@ -661,13 +660,13 @@ unin_chip_map_resource(device_t bus, device_t child, int type, } static int -unin_chip_unmap_resource(device_t bus, device_t child, int type, - struct resource *r, struct resource_map *map) +unin_chip_unmap_resource(device_t bus, device_t child, struct resource *r, + struct resource_map *map) { /* * If this is a memory resource, unmap it. */ - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: pmap_unmapdev(map->r_vaddr, map->r_size); diff --git a/sys/powerpc/powerpc/nexus.c b/sys/powerpc/powerpc/nexus.c index 55afadcb4e20..2f7b2ba055ff 100644 --- a/sys/powerpc/powerpc/nexus.c +++ b/sys/powerpc/powerpc/nexus.c @@ -242,7 +242,7 @@ nexus_get_rman(device_t bus, int type, u_int flags) } static int -nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, +nexus_map_resource(device_t bus, device_t child, struct resource *r, struct resource_map_request *argsp, struct resource_map *map) { struct resource_map_request args; @@ -254,7 +254,7 @@ nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, return (ENXIO); /* Mappings are only supported on I/O and memory resources. */ - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: break; @@ -270,7 +270,7 @@ nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, /* * If this is a memory resource, map it into the kernel. */ - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_IOPORT: panic("%s:%d SYS_RES_IOPORT handling not implemented", __func__, __LINE__); /* XXX: untested @@ -299,14 +299,14 @@ nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, } static int -nexus_unmap_resource(device_t bus, device_t child, int type, struct resource *r, +nexus_unmap_resource(device_t bus, device_t child, struct resource *r, struct resource_map *map) { /* * If this is a memory resource, unmap it. */ - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_MEMORY: pmap_unmapdev(map->r_vaddr, map->r_size); /* FALLTHROUGH */ diff --git a/sys/powerpc/ps3/ps3bus.c b/sys/powerpc/ps3/ps3bus.c index c3f46d4942ad..62687aa5b6ff 100644 --- a/sys/powerpc/ps3/ps3bus.c +++ b/sys/powerpc/ps3/ps3bus.c @@ -61,10 +61,10 @@ static struct rman *ps3bus_get_rman(device_t bus, int type, u_int flags); static struct resource *ps3bus_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); -static int ps3bus_map_resource(device_t bus, device_t child, int type, +static int ps3bus_map_resource(device_t bus, device_t child, struct resource *r, struct resource_map_request *argsp, struct resource_map *map); -static int ps3bus_unmap_resource(device_t bus, device_t child, int type, +static int ps3bus_unmap_resource(device_t bus, device_t child, struct resource *r, struct resource_map *map); *** 230 LINES SKIPPED ***