Date: Wed, 13 Mar 2024 22:13:43 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 9dbf5b0e6876 - main - new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCE Message-ID: <202403132213.42DMDhcH075199@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=9dbf5b0e6876d8c93890754bcc9c748339de79c0 commit 9dbf5b0e6876d8c93890754bcc9c748339de79c0 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 'rid' and 'type' arguments from BUS_RELEASE_RESOURCE The public bus_release_resource() API still accepts both forms, but the internal kobj method no longer passes the arguments. Implementations which need the rid or type now use rman_get_rid() or rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44131 --- share/man/man9/bus_release_resource.9 | 24 +++-------------- sys/arm/mv/mv_pci.c | 16 +++++------ sys/arm64/cavium/thunder_pcie_fdt.c | 12 ++++----- sys/arm64/cavium/thunder_pcie_pem.c | 16 +++++------ sys/dev/acpica/acpi.c | 7 +++-- sys/dev/acpica/acpi_pcib_acpi.c | 13 +++++---- sys/dev/agp/agp_i810.c | 4 +-- sys/dev/ahci/ahci.c | 7 +++-- sys/dev/ahci/ahci.h | 3 +-- sys/dev/ata/ata-pci.c | 16 +++++------ sys/dev/ata/ata-pci.h | 2 +- sys/dev/atkbdc/atkbdc_isa.c | 9 +++---- sys/dev/bhnd/bhnd_subr.c | 4 +-- sys/dev/bhnd/bhndb/bhndb.c | 9 +++---- sys/dev/bhnd/cores/chipc/chipc.c | 13 +++++---- sys/dev/bhnd/cores/usb/bhnd_usb.c | 14 +++++----- sys/dev/dpaa/fman.c | 12 ++++----- sys/dev/dpaa/fman.h | 3 +-- sys/dev/dpaa2/dpaa2_mc.c | 10 +++---- sys/dev/dpaa2/dpaa2_mc.h | 4 +-- sys/dev/dpaa2/dpaa2_rc.c | 7 +++-- sys/dev/fdt/simplebus.c | 14 +--------- sys/dev/hyperv/pcib/vmbus_pcib.c | 17 ++++++------ sys/dev/mvs/mvs_pci.c | 7 +++-- sys/dev/mvs/mvs_soc.c | 5 ++-- sys/dev/ofw/ofw_pcib.c | 17 +++++------- sys/dev/ofw/ofwbus.c | 7 +++-- sys/dev/pccbb/pccbb.c | 27 +++++++++---------- sys/dev/pccbb/pccbb_pci.c | 9 +++---- sys/dev/pccbb/pccbbvar.h | 2 +- sys/dev/pci/hostb_pci.c | 5 ++-- sys/dev/pci/isa_pci.c | 16 +++++------ sys/dev/pci/pci.c | 21 +++++++-------- sys/dev/pci/pci_host_generic.c | 14 +++++----- sys/dev/pci/pci_host_generic.h | 2 +- sys/dev/pci/pci_iov.c | 16 +++++------ sys/dev/pci/pci_pci.c | 7 +++-- sys/dev/pci/pci_private.h | 6 ++--- sys/dev/pci/pci_subr.c | 2 +- sys/dev/pci/pcib_private.h | 2 +- sys/dev/pci/vga_pci.c | 24 +++++++---------- sys/dev/ppc/ppc.c | 16 +++-------- sys/dev/ppc/ppcvar.h | 3 +-- sys/dev/puc/puc.c | 14 +++------- sys/dev/puc/puc_bfe.h | 2 +- sys/dev/quicc/quicc_bfe.h | 2 +- sys/dev/quicc/quicc_core.c | 6 ++--- sys/dev/scc/scc_bfe.h | 2 +- sys/dev/scc/scc_core.c | 6 ++--- sys/dev/siis/siis.c | 7 +++-- sys/dev/sound/pci/csa.c | 6 ++--- sys/dev/sound/pci/fm801.c | 3 +-- sys/dev/vmd/vmd.c | 10 +++---- sys/isa/isa_common.c | 2 -- sys/isa/isa_common.h | 2 +- sys/kern/bus_if.m | 4 --- sys/kern/subr_bus.c | 51 +++++++++++++++-------------------- sys/powerpc/mpc85xx/isa.c | 5 ++-- sys/powerpc/mpc85xx/lbc.c | 16 ++++------- sys/powerpc/powermac/macio.c | 14 ++++------ sys/powerpc/powermac/uninorth.c | 14 ++++------ sys/powerpc/psim/ata_iobus.c | 6 ++--- sys/powerpc/psim/iobus.c | 13 ++++----- sys/sys/bus.h | 18 ++++++------- sys/x86/include/legacyvar.h | 4 +-- sys/x86/isa/isa.c | 5 ++-- sys/x86/pci/pci_bus.c | 9 +++---- 67 files changed, 260 insertions(+), 405 deletions(-) diff --git a/share/man/man9/bus_release_resource.9 b/share/man/man9/bus_release_resource.9 index 9abc9fca1e6f..5203295a7488 100644 --- a/share/man/man9/bus_release_resource.9 +++ b/share/man/man9/bus_release_resource.9 @@ -26,7 +26,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd May 18, 2000 +.Dd March 13, 2024 .Dt BUS_RELEASE_RESOURCE 9 .Os .Sh NAME @@ -40,7 +40,7 @@ .In sys/rman.h .In machine/resource.h .Ft int -.Fn bus_release_resource "device_t dev" "int type" "int rid" "struct resource *r" +.Fn bus_release_resource "device_t dev" "struct resource *r" .Sh DESCRIPTION Free a resource allocated by .Xr bus_alloc_resource 9 . @@ -53,20 +53,6 @@ for IRQs). .Fa dev is the device that owns the resource. .It -.Fa type -is the type of resource that is released. -It must be of the same type you allocated it as before. -See -.Xr bus_alloc_resource 9 -for valid types. -.It -.Fa rid -is the resource ID of the resource. -The -.Fa rid -value must be the same as the one returned by -.Xr bus_alloc_resource 9 . -.It .Fa r is the pointer to .Va struct resource , @@ -88,12 +74,10 @@ The kernel will panic, if it cannot release the resource. bus_teardown_intr(dev, foosoftc->irqres, foosoftc->irqid); /* release IRQ resource */ - bus_release_resource(dev, SYS_RES_IRQ, foosoftc->irqid, - foosoftc->irqres); + bus_release_resource(dev, foosoftc->irqres); /* release I/O port resource */ - bus_release_resource(dev, SYS_RES_IOPORT, foosoftc->portid, - foosoftc->portres); + bus_release_resource(dev, foosoftc->portres); .Ed .Sh SEE ALSO .Xr bus_alloc_resource 9 , diff --git a/sys/arm/mv/mv_pci.c b/sys/arm/mv/mv_pci.c index a24a71cd4ecf..eb1af5a4e237 100644 --- a/sys/arm/mv/mv_pci.c +++ b/sys/arm/mv/mv_pci.c @@ -347,8 +347,7 @@ 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, struct resource *, rman_res_t, rman_res_t); -static int mv_pcib_release_resource(device_t, device_t, int, int, - struct resource *); +static int mv_pcib_release_resource(device_t, device_t, struct resource *); static int mv_pcib_activate_resource(device_t, device_t, struct resource *); static int mv_pcib_deactivate_resource(device_t, device_t, struct resource *); static int mv_pcib_map_resource(device_t, device_t, struct resource *, @@ -962,25 +961,22 @@ mv_pcib_adjust_resource(device_t dev, device_t child, } static int -mv_pcib_release_resource(device_t dev, device_t child, int type, int rid, - struct resource *res) +mv_pcib_release_resource(device_t dev, device_t child, struct resource *res) { #ifdef PCI_RES_BUS struct mv_pcib_softc *sc = device_get_softc(dev); #endif - switch (type) { + switch (rman_get_type(res)) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: - return (bus_generic_rman_release_resource(dev, child, type, - rid, res)); + return (bus_generic_rman_release_resource(dev, child, res)); #ifdef PCI_RES_BUS case PCI_RES_BUS: - return (pci_domain_release_bus(sc->ap_segment, child, rid, res)); + return (pci_domain_release_bus(sc->ap_segment, child, res)); #endif default: - return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, - type, rid, res)); + return (bus_generic_release_resource(dev, child, res)); } } diff --git a/sys/arm64/cavium/thunder_pcie_fdt.c b/sys/arm64/cavium/thunder_pcie_fdt.c index bf00688fb041..f173a28b637d 100644 --- a/sys/arm64/cavium/thunder_pcie_fdt.c +++ b/sys/arm64/cavium/thunder_pcie_fdt.c @@ -57,7 +57,7 @@ static struct resource * thunder_pcie_fdt_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); static int thunder_pcie_fdt_release_resource(device_t, device_t, - int, int, struct resource*); + struct resource*); #endif static int thunder_pcie_fdt_attach(device_t); static int thunder_pcie_fdt_probe(device_t); @@ -288,14 +288,14 @@ thunder_pcie_fdt_alloc_resource(device_t dev, device_t child, int type, } static int -thunder_pcie_fdt_release_resource(device_t dev, device_t child, int type, - int rid, struct resource *res) +thunder_pcie_fdt_release_resource(device_t dev, device_t child, + struct resource *res) { if ((int)ofw_bus_get_node(child) <= 0) - return (pci_host_generic_core_release_resource(dev, child, type, - rid, res)); + return (pci_host_generic_core_release_resource(dev, child, + res)); - return (bus_generic_release_resource(dev, child, type, rid, res)); + return (bus_generic_release_resource(dev, child, res)); } #endif diff --git a/sys/arm64/cavium/thunder_pcie_pem.c b/sys/arm64/cavium/thunder_pcie_pem.c index f7c3c5ee1c0a..dd6ef14f1a6e 100644 --- a/sys/arm64/cavium/thunder_pcie_pem.c +++ b/sys/arm64/cavium/thunder_pcie_pem.c @@ -149,8 +149,7 @@ static uint32_t thunder_pem_read_config(device_t, u_int, u_int, u_int, u_int, int); static int thunder_pem_read_ivar(device_t, device_t, int, uintptr_t *); static void thunder_pem_release_all(device_t); -static int thunder_pem_release_resource(device_t, device_t, int, int, - struct resource *); +static int thunder_pem_release_resource(device_t, device_t, struct resource *); static struct rman * thunder_pem_get_rman(device_t, int, u_int); static void thunder_pem_slix_s2m_regx_acc_modify(struct thunder_pem_softc *, int, int); @@ -716,28 +715,25 @@ thunder_pem_alloc_resource(device_t dev, device_t child, int type, int *rid, } static int -thunder_pem_release_resource(device_t dev, device_t child, int type, int rid, - struct resource *res) +thunder_pem_release_resource(device_t dev, device_t child, struct resource *res) { device_t parent_dev; #if defined(NEW_PCIB) && defined(PCI_RES_BUS) struct thunder_pem_softc *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_release_bus(sc->id, child, rid, res)); + return (pci_domain_release_bus(sc->id, child, res)); #endif case SYS_RES_MEMORY: case SYS_RES_IOPORT: - return (bus_generic_rman_release_resource(dev, child, type, - rid, res)); + return (bus_generic_rman_release_resource(dev, child, res)); default: /* Find parent device. On ThunderX we know an exact path. */ parent_dev = device_get_parent(device_get_parent(dev)); - return (BUS_RELEASE_RESOURCE(parent_dev, child, - type, rid, res)); + return (BUS_RELEASE_RESOURCE(parent_dev, child, res)); } } diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index df2017e69a86..ad1af9373fb7 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1580,17 +1580,16 @@ acpi_adjust_resource(device_t bus, device_t child, struct resource *r, } static int -acpi_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) +acpi_release_resource(device_t bus, device_t child, struct resource *r) { /* * If this resource belongs to one of our internal managers, * deactivate it and release it to the local pool. */ if (acpi_is_resource_managed(bus, r)) - return (bus_generic_rman_release_resource(bus, child, type, rid, r)); + return (bus_generic_rman_release_resource(bus, child, r)); - return (bus_generic_rl_release_resource(bus, child, type, rid, r)); + return (bus_generic_rl_release_resource(bus, child, r)); } static void diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c index fdf8e84d14e0..4c3d62a66d58 100644 --- a/sys/dev/acpica/acpi_pcib_acpi.c +++ b/sys/dev/acpica/acpi_pcib_acpi.c @@ -101,8 +101,7 @@ static int acpi_pcib_acpi_adjust_resource(device_t dev, rman_res_t start, rman_res_t end); #ifdef PCI_RES_BUS static int acpi_pcib_acpi_release_resource(device_t dev, - device_t child, int type, int rid, - struct resource *r); + device_t child, struct resource *r); static int acpi_pcib_acpi_activate_resource(device_t dev, device_t child, struct resource *r); static int acpi_pcib_acpi_deactivate_resource(device_t dev, @@ -516,7 +515,7 @@ acpi_pcib_acpi_attach(device_t dev) return (ENXIO); } sc->ap_bus = rman_get_start(bus_res); - pci_domain_release_bus(sc->ap_segment, dev, rid, bus_res); + pci_domain_release_bus(sc->ap_segment, dev, bus_res); } } else { /* @@ -759,15 +758,15 @@ acpi_pcib_acpi_adjust_resource(device_t dev, device_t child, #ifdef PCI_RES_BUS int -acpi_pcib_acpi_release_resource(device_t dev, device_t child, int type, int rid, +acpi_pcib_acpi_release_resource(device_t dev, device_t child, struct resource *r) { struct acpi_hpcib_softc *sc; sc = device_get_softc(dev); - if (type == PCI_RES_BUS) - return (pci_domain_release_bus(sc->ap_segment, child, rid, r)); - return (bus_generic_release_resource(dev, child, type, rid, r)); + if (rman_get_type(r) == PCI_RES_BUS) + return (pci_domain_release_bus(sc->ap_segment, child, r)); + return (bus_generic_release_resource(dev, child, r)); } int diff --git a/sys/dev/agp/agp_i810.c b/sys/dev/agp/agp_i810.c index a83189ca7bc8..df977889a9c0 100644 --- a/sys/dev/agp/agp_i810.c +++ b/sys/dev/agp/agp_i810.c @@ -2053,8 +2053,8 @@ agp_i915_chipset_flush_free_page(device_t dev) return; BUS_DEACTIVATE_RESOURCE(device_get_parent(vga), dev, sc->sc_flush_page_res); - BUS_RELEASE_RESOURCE(device_get_parent(vga), dev, SYS_RES_MEMORY, - sc->sc_flush_page_rid, sc->sc_flush_page_res); + BUS_RELEASE_RESOURCE(device_get_parent(vga), dev, + sc->sc_flush_page_res); } static int diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c index 27860f9ee570..b1f9c85141bb 100644 --- a/sys/dev/ahci/ahci.c +++ b/sys/dev/ahci/ahci.c @@ -640,16 +640,15 @@ ahci_alloc_resource(device_t dev, device_t child, int type, int *rid, } int -ahci_release_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) +ahci_release_resource(device_t dev, device_t child, struct resource *r) { - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_MEMORY: rman_release_resource(r); return (0); case SYS_RES_IRQ: - if (rid != ATA_IRQ_RID) + if (rman_get_rid(r) != ATA_IRQ_RID) return (ENOENT); return (0); } diff --git a/sys/dev/ahci/ahci.h b/sys/dev/ahci/ahci.h index 04d0cccc31f9..8b51b1e0b3ae 100644 --- a/sys/dev/ahci/ahci.h +++ b/sys/dev/ahci/ahci.h @@ -656,8 +656,7 @@ int ahci_setup_interrupt(device_t dev); int ahci_print_child(device_t dev, device_t child); struct resource *ahci_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 ahci_release_resource(device_t dev, device_t child, int type, int rid, - struct resource *r); +int ahci_release_resource(device_t dev, device_t child, struct resource *r); int ahci_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, driver_filter_t *filter, driver_intr_t *function, void *argument, void **cookiep); diff --git a/sys/dev/ata/ata-pci.c b/sys/dev/ata/ata-pci.c index 3a2a0f640f62..9cc815150665 100644 --- a/sys/dev/ata/ata-pci.c +++ b/sys/dev/ata/ata-pci.c @@ -273,24 +273,20 @@ ata_pci_alloc_resource(device_t dev, device_t child, int type, int *rid, } int -ata_pci_release_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) +ata_pci_release_resource(device_t dev, device_t child, struct resource *r) { + int rid = rman_get_rid(r); + int type = rman_get_type(r); if (device_get_devclass(child) == ata_devclass) { struct ata_pci_controller *controller = device_get_softc(dev); - int unit = ((struct ata_channel *)device_get_softc(child))->unit; if (type == SYS_RES_IOPORT) { switch (rid) { case ATA_IOADDR_RID: - return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, - SYS_RES_IOPORT, - PCIR_BAR(0) + (unit << 3), r); case ATA_CTLADDR_RID: return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, - SYS_RES_IOPORT, - PCIR_BAR(1) + (unit << 3), r); + r); default: return ENOENT; } @@ -300,7 +296,7 @@ ata_pci_release_resource(device_t dev, device_t child, int type, int rid, return ENOENT; if (controller->legacy) { return BUS_RELEASE_RESOURCE(device_get_parent(dev), child, - SYS_RES_IRQ, rid, r); + r); } else return 0; } @@ -311,7 +307,7 @@ ata_pci_release_resource(device_t dev, device_t child, int type, int rid, return (0); } else { return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, - type, rid, r)); + r)); } } return (EINVAL); diff --git a/sys/dev/ata/ata-pci.h b/sys/dev/ata/ata-pci.h index 95e7dd113fec..cad9441a21ae 100644 --- a/sys/dev/ata/ata-pci.h +++ b/sys/dev/ata/ata-pci.h @@ -538,7 +538,7 @@ void ata_pci_write_config(device_t dev, device_t child, int reg, int ata_pci_print_child(device_t dev, device_t child); int ata_pci_child_location(device_t dev, device_t child, struct sbuf *sb); struct resource * ata_pci_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 ata_pci_release_resource(device_t dev, device_t child, int type, int rid, struct resource *r); +int ata_pci_release_resource(device_t dev, device_t child, struct resource *r); int ata_pci_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, driver_filter_t *filter, driver_intr_t *function, void *argument, void **cookiep); int ata_pci_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie); int ata_pci_ch_attach(device_t dev); diff --git a/sys/dev/atkbdc/atkbdc_isa.c b/sys/dev/atkbdc/atkbdc_isa.c index cb42c8bda40c..2f7b9eceda94 100644 --- a/sys/dev/atkbdc/atkbdc_isa.c +++ b/sys/dev/atkbdc/atkbdc_isa.c @@ -53,7 +53,7 @@ static struct resource *atkbdc_isa_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); static int atkbdc_isa_release_resource(device_t dev, device_t child, - int type, int rid, struct resource *r); + struct resource *r); static device_method_t atkbdc_isa_methods[] = { DEVMETHOD(device_probe, atkbdc_isa_probe), @@ -306,15 +306,14 @@ atkbdc_isa_alloc_resource(device_t dev, device_t child, int type, int *rid, } static int -atkbdc_isa_release_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) +atkbdc_isa_release_resource(device_t dev, device_t child, struct resource *r) { atkbdc_softc_t *sc; sc = *(atkbdc_softc_t **)device_get_softc(dev); - if (type == SYS_RES_IRQ && rid == KBDC_RID_KBD && r == sc->irq) + if (r == sc->irq) return (0); - return (bus_generic_rl_release_resource(dev, child, type, rid, r)); + return (bus_generic_rl_release_resource(dev, child, r)); } DRIVER_MODULE(atkbdc, isa, atkbdc_isa_driver, 0, 0); diff --git a/sys/dev/bhnd/bhnd_subr.c b/sys/dev/bhnd/bhnd_subr.c index 44f8ae9cc0a2..0d38c1ca8a24 100644 --- a/sys/dev/bhnd/bhnd_subr.c +++ b/sys/dev/bhnd/bhnd_subr.c @@ -2241,7 +2241,7 @@ bhnd_bus_generic_alloc_resource(device_t dev, device_t child, int type, failed: if (res != NULL) - BUS_RELEASE_RESOURCE(dev, child, type, *rid, res); + BUS_RELEASE_RESOURCE(dev, child, res); free(br, M_BHND); return (NULL); @@ -2259,7 +2259,7 @@ bhnd_bus_generic_release_resource(device_t dev, device_t child, int type, { int error; - if ((error = BUS_RELEASE_RESOURCE(dev, child, type, rid, r->res))) + if ((error = BUS_RELEASE_RESOURCE(dev, child, r->res))) return (error); free(r, M_BHND); diff --git a/sys/dev/bhnd/bhndb/bhndb.c b/sys/dev/bhnd/bhndb/bhndb.c index 5148c1c8452b..af62057690ac 100644 --- a/sys/dev/bhnd/bhndb/bhndb.c +++ b/sys/dev/bhnd/bhndb/bhndb.c @@ -1034,8 +1034,7 @@ bhndb_alloc_resource(device_t dev, device_t child, int type, * Default bhndb(4) implementation of BUS_RELEASE_RESOURCE(). */ static int -bhndb_release_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) +bhndb_release_resource(device_t dev, device_t child, struct resource *r) { struct bhndb_softc *sc; struct resource_list_entry *rle; @@ -1047,9 +1046,9 @@ bhndb_release_resource(device_t dev, device_t child, int type, int rid, /* Delegate to our parent device's bus if the requested resource type * isn't handled locally. */ - if (bhndb_get_rman(sc, child, type) == NULL) { + if (bhndb_get_rman(sc, child, rman_get_type(r)) == NULL) { return (BUS_RELEASE_RESOURCE(device_get_parent(sc->parent_dev), - child, type, rid, r)); + child, r)); } /* Deactivate resources */ @@ -1065,7 +1064,7 @@ bhndb_release_resource(device_t dev, device_t child, int type, int rid, if (!passthrough) { /* Clean resource list entry */ rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child), - type, rid); + rman_get_type(r), rman_get_rid(r)); if (rle != NULL) rle->res = NULL; } diff --git a/sys/dev/bhnd/cores/chipc/chipc.c b/sys/dev/bhnd/cores/chipc/chipc.c index bdba61a2b942..60cb04400cb0 100644 --- a/sys/dev/bhnd/cores/chipc/chipc.c +++ b/sys/dev/bhnd/cores/chipc/chipc.c @@ -873,8 +873,7 @@ chipc_alloc_resource(device_t dev, device_t child, int type, } static int -chipc_release_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) +chipc_release_resource(device_t dev, device_t child, struct resource *r) { struct chipc_softc *sc; struct chipc_region *cr; @@ -885,10 +884,9 @@ chipc_release_resource(device_t dev, device_t child, int type, int rid, 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_rl_release_resource(dev, child, type, rid, - r)); + return (bus_generic_rl_release_resource(dev, child, r)); } /* Locate the mapping region */ @@ -897,7 +895,7 @@ chipc_release_resource(device_t dev, device_t child, int type, int rid, return (EINVAL); /* Deactivate resources */ - error = bus_generic_rman_release_resource(dev, child, type, rid, r); + error = bus_generic_rman_release_resource(dev, child, r); if (error != 0) return (error); @@ -905,7 +903,8 @@ chipc_release_resource(device_t dev, device_t child, int type, int rid, chipc_release_region(sc, cr, RF_ALLOCATED); /* Clear reference from the resource list entry if exists */ - rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child), type, rid); + rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child), + rman_get_type(r), rman_get_rid(r)); if (rle != NULL) rle->res = NULL; diff --git a/sys/dev/bhnd/cores/usb/bhnd_usb.c b/sys/dev/bhnd/cores/usb/bhnd_usb.c index fa9e6d7ec31a..7a86db79731f 100644 --- a/sys/dev/bhnd/cores/usb/bhnd_usb.c +++ b/sys/dev/bhnd/cores/usb/bhnd_usb.c @@ -69,8 +69,7 @@ static struct resource * bhnd_usb_alloc_resource(device_t bus, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); static int bhnd_usb_release_resource(device_t dev, - device_t child, int type, int rid, - struct resource *r); + device_t child, struct resource *r); static struct resource_list * bhnd_usb_get_reslist(device_t dev, device_t child); @@ -311,8 +310,8 @@ bhnd_usb_get_reslist(device_t dev, device_t child) } static int -bhnd_usb_release_resource(device_t dev, device_t child, int type, - int rid, struct resource *r) +bhnd_usb_release_resource(device_t dev, device_t child, + struct resource *r) { struct bhnd_usb_softc *sc; struct resource_list_entry *rle; @@ -325,18 +324,17 @@ bhnd_usb_release_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. */ if (type != SYS_RES_MEMORY) { - return (bus_generic_rl_release_resource(dev, child, type, rid, - r)); + return (bus_generic_rl_release_resource(dev, child, r)); } - error = bus_generic_rman_release_resource(dev, child, type, rid, r); + error = bus_generic_rman_release_resource(dev, child, r); if (error != 0) return (error); if (!passthrough) { /* Clean resource list entry */ rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child), - type, rid); + rman_get_type(r), rman_get_rid(r)); if (rle != NULL) rle->res = NULL; } diff --git a/sys/dev/dpaa/fman.c b/sys/dev/dpaa/fman.c index 2364df0be801..9dc4ac151789 100644 --- a/sys/dev/dpaa/fman.c +++ b/sys/dev/dpaa/fman.c @@ -116,8 +116,7 @@ fman_activate_resource(device_t bus, device_t child, struct resource *res) } int -fman_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) +fman_release_resource(device_t bus, device_t child, struct resource *res) { struct resource_list *rl; struct resource_list_entry *rle; @@ -125,9 +124,9 @@ fman_release_resource(device_t bus, device_t child, int type, int rid, passthrough = (device_get_parent(child) != bus); rl = BUS_GET_RESOURCE_LIST(bus, child); - if (type != SYS_RES_IRQ) { + if (rman_get_type(res) != SYS_RES_IRQ) { if ((rman_get_flags(res) & RF_ACTIVE) != 0 ){ - rv = bus_deactivate_resource(child, type, rid, res); + rv = bus_deactivate_resource(child, res); if (rv != 0) return (rv); } @@ -135,7 +134,8 @@ fman_release_resource(device_t bus, device_t child, int type, int rid, if (rv != 0) return (rv); if (!passthrough) { - rle = resource_list_find(rl, type, rid); + rle = resource_list_find(rl, rman_get_type(res), + rman_get_rid(res)); KASSERT(rle != NULL, ("%s: resource entry not found!", __func__)); KASSERT(rle->res != NULL, @@ -144,7 +144,7 @@ fman_release_resource(device_t bus, device_t child, int type, int rid, } return (0); } - return (resource_list_release(rl, bus, child, type, rid, res)); + return (resource_list_release(rl, bus, child, res)); } struct resource * diff --git a/sys/dev/dpaa/fman.h b/sys/dev/dpaa/fman.h index b201b9fd9355..4c30a633ae3e 100644 --- a/sys/dev/dpaa/fman.h +++ b/sys/dev/dpaa/fman.h @@ -57,8 +57,7 @@ struct resource * fman_alloc_resource(device_t bus, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); int fman_activate_resource(device_t bus, device_t child, struct resource *res); -int fman_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *res); +int fman_release_resource(device_t bus, device_t child, struct resource *res); int fman_attach(device_t dev); int fman_detach(device_t dev); int fman_suspend(device_t dev); diff --git a/sys/dev/dpaa2/dpaa2_mc.c b/sys/dev/dpaa2/dpaa2_mc.c index 3e0920cbf8a5..66867a18068c 100644 --- a/sys/dev/dpaa2/dpaa2_mc.c +++ b/sys/dev/dpaa2/dpaa2_mc.c @@ -356,16 +356,14 @@ dpaa2_mc_adjust_resource(device_t mcdev, device_t child, } int -dpaa2_mc_release_resource(device_t mcdev, device_t child, int type, int rid, - struct resource *r) +dpaa2_mc_release_resource(device_t mcdev, device_t child, struct resource *r) { struct rman *rm; - rm = dpaa2_mc_rman(mcdev, type, rman_get_flags(r)); + rm = dpaa2_mc_rman(mcdev, rman_get_type(r), rman_get_flags(r)); if (rm) - return (bus_generic_rman_release_resource(mcdev, child, type, - rid, r)); - return (bus_generic_release_resource(mcdev, child, type, rid, r)); + return (bus_generic_rman_release_resource(mcdev, child, r)); + return (bus_generic_release_resource(mcdev, child, r)); } int diff --git a/sys/dev/dpaa2/dpaa2_mc.h b/sys/dev/dpaa2/dpaa2_mc.h index 7af3b2a4eb24..5ddac7aa2720 100644 --- a/sys/dev/dpaa2/dpaa2_mc.h +++ b/sys/dev/dpaa2/dpaa2_mc.h @@ -185,8 +185,8 @@ struct resource * dpaa2_mc_alloc_resource(device_t mcdev, device_t child, u_int flags); int dpaa2_mc_adjust_resource(device_t mcdev, device_t child, struct resource *r, rman_res_t start, rman_res_t end); -int dpaa2_mc_release_resource(device_t mcdev, device_t child, int type, - int rid, struct resource *r); +int dpaa2_mc_release_resource(device_t mcdev, device_t child, + struct resource *r); int dpaa2_mc_activate_resource(device_t mcdev, device_t child, struct resource *r); int dpaa2_mc_deactivate_resource(device_t mcdev, device_t child, diff --git a/sys/dev/dpaa2/dpaa2_rc.c b/sys/dev/dpaa2/dpaa2_rc.c index d14187e0c58f..49ed8944b64b 100644 --- a/sys/dev/dpaa2/dpaa2_rc.c +++ b/sys/dev/dpaa2/dpaa2_rc.c @@ -263,19 +263,18 @@ dpaa2_rc_alloc_resource(device_t rcdev, device_t child, int type, int *rid, } static int -dpaa2_rc_release_resource(device_t rcdev, device_t child, int type, int rid, - struct resource *r) +dpaa2_rc_release_resource(device_t rcdev, device_t child, struct resource *r) { struct resource_list *rl; struct dpaa2_devinfo *dinfo; if (device_get_parent(child) != rcdev) return (BUS_RELEASE_RESOURCE(device_get_parent(rcdev), child, - type, rid, r)); + r)); dinfo = device_get_ivars(child); rl = &dinfo->resources; - return (resource_list_release(rl, rcdev, child, type, rid, r)); + return (resource_list_release(rl, rcdev, child, r)); } static void diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index 8069d3af69cf..37db238f2108 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_release_resource(device_t bus, device_t child, - int type, int rid, struct resource *r); static void simplebus_probe_nomatch(device_t bus, device_t child); static int simplebus_print_child(device_t bus, device_t child); static device_t simplebus_add_child(device_t dev, u_int order, @@ -85,7 +83,7 @@ static device_method_t simplebus_methods[] = { DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), DEVMETHOD(bus_alloc_resource, simplebus_alloc_resource), - DEVMETHOD(bus_release_resource, simplebus_release_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), @@ -485,16 +483,6 @@ simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid, count, flags)); } -static int -simplebus_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - - if (type == SYS_RES_IOPORT) - type = SYS_RES_MEMORY; - return (bus_generic_release_resource(bus, child, type, rid, r)); -} - static int simplebus_print_res(struct simplebus_devinfo *di) { diff --git a/sys/dev/hyperv/pcib/vmbus_pcib.c b/sys/dev/hyperv/pcib/vmbus_pcib.c index fd8a7feae984..f6237535cce3 100644 --- a/sys/dev/hyperv/pcib/vmbus_pcib.c +++ b/sys/dev/hyperv/pcib/vmbus_pcib.c @@ -1725,19 +1725,18 @@ vmbus_pcib_adjust_resource(device_t dev, device_t child, } static int -vmbus_pcib_release_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) +vmbus_pcib_release_resource(device_t dev, device_t child, struct resource *r) { struct vmbus_pcib_softc *sc = device_get_softc(dev); - if (type == PCI_RES_BUS) - return (pci_domain_release_bus(sc->hbus->pci_domain, child, - rid, r)); - - if (type == SYS_RES_IOPORT) + switch (rman_get_type(r)) { + case PCI_RES_BUS: + return (pci_domain_release_bus(sc->hbus->pci_domain, child, r)); + case SYS_RES_IOPORT: return (EINVAL); - - return (bus_generic_release_resource(dev, child, type, rid, r)); + default: + return (bus_generic_release_resource(dev, child, r)); + } } static int diff --git a/sys/dev/mvs/mvs_pci.c b/sys/dev/mvs/mvs_pci.c index 9578c5ea5e7e..be9351403a0d 100644 --- a/sys/dev/mvs/mvs_pci.c +++ b/sys/dev/mvs/mvs_pci.c @@ -422,16 +422,15 @@ mvs_alloc_resource(device_t dev, device_t child, int type, int *rid, } static int -mvs_release_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) +mvs_release_resource(device_t dev, device_t child, struct resource *r) { - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_MEMORY: rman_release_resource(r); return (0); case SYS_RES_IRQ: - if (rid != ATA_IRQ_RID) + if (rman_get_rid(r) != ATA_IRQ_RID) return ENOENT; return (0); } diff --git a/sys/dev/mvs/mvs_soc.c b/sys/dev/mvs/mvs_soc.c index 36b3f5222cdc..696b65d54359 100644 --- a/sys/dev/mvs/mvs_soc.c +++ b/sys/dev/mvs/mvs_soc.c @@ -366,11 +366,10 @@ mvs_alloc_resource(device_t dev, device_t child, int type, int *rid, } static int -mvs_release_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) +mvs_release_resource(device_t dev, device_t child, struct resource *r) { - switch (type) { + switch (rman_get_type(r)) { case SYS_RES_MEMORY: rman_release_resource(r); return (0); diff --git a/sys/dev/ofw/ofw_pcib.c b/sys/dev/ofw/ofw_pcib.c index f9f17b21cdc2..ebc09fccd93e 100644 --- a/sys/dev/ofw/ofw_pcib.c +++ b/sys/dev/ofw/ofw_pcib.c @@ -67,8 +67,7 @@ static struct rman *ofw_pcib_get_rman(device_t, int, u_int); static struct resource * ofw_pcib_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); -static int ofw_pcib_release_resource(device_t, device_t, int, int, - struct resource *); +static int ofw_pcib_release_resource(device_t, device_t, struct resource *); static int ofw_pcib_activate_resource(device_t, device_t, struct resource *); static int ofw_pcib_deactivate_resource(device_t, device_t, struct resource *); static int ofw_pcib_adjust_resource(device_t, device_t, @@ -444,27 +443,23 @@ ofw_pcib_alloc_resource(device_t bus, device_t child, int type, int *rid, } static int -ofw_pcib_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) +ofw_pcib_release_resource(device_t bus, device_t child, struct resource *res) { #if defined(NEW_PCIB) && defined(PCI_RES_BUS) struct ofw_pci_softc *sc; sc = device_get_softc(bus); #endif - switch (type) { + switch (rman_get_type(res)) { #if defined(NEW_PCIB) && defined(PCI_RES_BUS) case PCI_RES_BUS: - return (pci_domain_release_bus(sc->sc_pci_domain, child, rid, - res)); + return (pci_domain_release_bus(sc->sc_pci_domain, child, res)); #endif case SYS_RES_MEMORY: case SYS_RES_IOPORT: - return (bus_generic_rman_release_resource(bus, child, type, rid, - res)); + return (bus_generic_rman_release_resource(bus, child, res)); default: - return (bus_generic_release_resource(bus, child, type, rid, - res)); + return (bus_generic_release_resource(bus, child, res)); } } diff --git a/sys/dev/ofw/ofwbus.c b/sys/dev/ofw/ofwbus.c index 48e865b5b52d..51e6072ad4ba 100644 --- a/sys/dev/ofw/ofwbus.c +++ b/sys/dev/ofw/ofwbus.c @@ -170,8 +170,7 @@ ofwbus_alloc_resource(device_t bus, device_t child, int type, int *rid, } static int -ofwbus_release_resource(device_t bus, device_t child, int type, - int rid, struct resource *r) +ofwbus_release_resource(device_t bus, device_t child, struct resource *r) { struct resource_list_entry *rle; bool passthrough; @@ -180,11 +179,11 @@ ofwbus_release_resource(device_t bus, device_t child, int type, if (!passthrough) { /* Clean resource list entry */ rle = resource_list_find(BUS_GET_RESOURCE_LIST(bus, child), - type, rid); + rman_get_type(r), rman_get_rid(r)); if (rle != NULL) rle->res = NULL; } /* Let nexus handle the release. */ - return (bus_generic_release_resource(bus, child, type, rid, r)); + return (bus_generic_release_resource(bus, child, r)); } diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c index 302b9d75c864..c40261be4724 100644 --- a/sys/dev/pccbb/pccbb.c +++ b/sys/dev/pccbb/pccbb.c @@ -162,7 +162,7 @@ static struct resource *cbb_cardbus_alloc_resource(device_t brdev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); static int cbb_cardbus_release_resource(device_t brdev, device_t child, - int type, int rid, struct resource *res); + struct resource *res); static int cbb_cardbus_power_enable_socket(device_t brdev, device_t child); static int cbb_cardbus_power_disable_socket(device_t brdev, @@ -1263,20 +1263,20 @@ cbb_cardbus_alloc_resource(device_t brdev, device_t child, int type, } static int -cbb_cardbus_release_resource(device_t brdev, device_t child, int type, - int rid, struct resource *res) +cbb_cardbus_release_resource(device_t brdev, device_t child, + struct resource *res) { struct cbb_softc *sc = device_get_softc(brdev); int error; if (rman_get_flags(res) & RF_ACTIVE) { - error = bus_deactivate_resource(child, type, rid, res); + error = bus_deactivate_resource(child, res); if (error != 0) return (error); } cbb_remove_res(sc, res); *** 1285 LINES SKIPPED ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202403132213.42DMDhcH075199>