ce_t child, int type, */ int bhnd_bus_generic_deactivate_resource(device_t dev, device_t child, - int type, int rid, struct bhnd_resource *r) + struct bhnd_resource *r) { if (device_get_parent(dev) != NULL) return (BHND_BUS_DEACTIVATE_RESOURCE(device_get_parent(dev), - child, type, rid, r)); + child, r)); return (EINVAL); } diff --git a/sys/dev/bhnd/bhndb/bhndb.c b/sys/dev/bhnd/bhndb/bhndb.c index 90ae719787dc..6ee5a698987d 100644 --- a/sys/dev/bhnd/bhndb/bhndb.c +++ b/sys/dev/bhnd/bhndb/bhndb.c @@ -1503,7 +1503,7 @@ bhndb_get_resource_list(device_t dev, device_t child) */ static int bhndb_activate_bhnd_resource(device_t dev, device_t child, - int type, int rid, struct bhnd_resource *r) + struct bhnd_resource *r) { struct bhndb_softc *sc; struct bhndb_region *region; @@ -1522,7 +1522,7 @@ bhndb_activate_bhnd_resource(device_t dev, device_t child, /* Delegate directly to BUS_ACTIVATE_RESOURCE() 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->res)) == NULL) { error = BUS_ACTIVATE_RESOURCE(dev, child, r->res); if (error == 0) r->direct = true; @@ -1535,7 +1535,7 @@ bhndb_activate_bhnd_resource(device_t dev, device_t child, /* Determine the resource priority of bridged resources, and skip direct * allocation if the priority is too low. */ if (bhndb_get_addrspace(sc, child) == BHNDB_ADDRSPACE_BRIDGED) { - switch (type) { + switch (rman_get_type(r->res)) { case SYS_RES_IRQ: /* IRQ resources are always direct */ break; @@ -1557,7 +1557,7 @@ bhndb_activate_bhnd_resource(device_t dev, device_t child, default: device_printf(dev, "unsupported resource type %d\n", - type); + rman_get_type(r->res)); return (ENXIO); } } @@ -1591,7 +1591,7 @@ bhndb_activate_bhnd_resource(device_t dev, device_t child, */ static int bhndb_deactivate_bhnd_resource(device_t dev, device_t child, - int type, int rid, struct bhnd_resource *r) + struct bhnd_resource *r) { int error; diff --git a/sys/dev/bhnd/cores/chipc/chipc.c b/sys/dev/bhnd/cores/chipc/chipc.c index 8d62bbcc4712..4863a1b4e270 100644 --- a/sys/dev/bhnd/cores/chipc/chipc.c +++ b/sys/dev/bhnd/cores/chipc/chipc.c @@ -1005,17 +1005,16 @@ cleanup: } static int -chipc_activate_bhnd_resource(device_t dev, device_t child, int type, - int rid, struct bhnd_resource *r) +chipc_activate_bhnd_resource(device_t dev, device_t child, + struct bhnd_resource *r) { struct rman *rm; int error; /* Delegate non-locally managed resources to parent */ - rm = chipc_get_rman(dev, type, rman_get_flags(r->res)); + rm = chipc_get_rman(dev, rman_get_type(r->res), rman_get_flags(r->res)); if (rm == NULL || !rman_is_region_manager(r->res, rm)) { - return (bhnd_bus_generic_activate_resource(dev, child, type, - rid, r)); + return (bhnd_bus_generic_activate_resource(dev, child, r)); } /* Try activating the chipc region resource */ diff --git a/sys/dev/bhnd/cores/chipc/chipc_gpio.c b/sys/dev/bhnd/cores/chipc/chipc_gpio.c index 8e4445155f7b..638c0b9dc592 100644 --- a/sys/dev/bhnd/cores/chipc/chipc_gpio.c +++ b/sys/dev/bhnd/cores/chipc/chipc_gpio.c @@ -138,8 +138,7 @@ chipc_gpio_attach(device_t dev) CC_GPIO_LOCK_INIT(sc); - sc->mem_rid = 0; - sc->mem_res = bhnd_alloc_resource_any(dev, SYS_RES_MEMORY, sc->mem_rid, + sc->mem_res = bhnd_alloc_resource_any(dev, SYS_RES_MEMORY, 0, RF_ACTIVE|RF_SHAREABLE); if (sc->mem_res == NULL) { device_printf(dev, "failed to allocate chipcommon registers\n"); @@ -195,8 +194,7 @@ failed: device_delete_children(dev); if (sc->mem_res != NULL) { - bhnd_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, - sc->mem_res); + bhnd_release_resource(dev, sc->mem_res); } CC_GPIO_LOCK_DESTROY(sc); @@ -218,7 +216,7 @@ chipc_gpio_detach(device_t dev) if ((error = bhnd_deregister_provider(dev, BHND_SERVICE_ANY))) return (error); - bhnd_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem_res); + bhnd_release_resource(dev, sc->mem_res); CC_GPIO_LOCK_DESTROY(sc); return (0); diff --git a/sys/dev/bhnd/cores/chipc/chipc_gpiovar.h b/sys/dev/bhnd/cores/chipc/chipc_gpiovar.h index a0fc2b9ce993..e49cd5c498dd 100644 --- a/sys/dev/bhnd/cores/chipc/chipc_gpiovar.h +++ b/sys/dev/bhnd/cores/chipc/chipc_gpiovar.h @@ -119,7 +119,6 @@ struct chipc_gpio_softc { device_t dev; device_t gpiobus; /**< attached gpiobus child */ struct bhnd_resource *mem_res; /**< chipcommon register block */ - int mem_rid; /**< resource ID of mem_res */ uint32_t quirks; /**< device quirks (see CC_GPIO_QUIRK_*) */ struct mtx mtx; /**< lock protecting RMW register access */ }; diff --git a/sys/dev/bhnd/cores/chipc/chipc_private.h b/sys/dev/bhnd/cores/chipc/chipc_private.h index f94f3a256771..9bf9463b0abb 100644 --- a/sys/dev/bhnd/cores/chipc/chipc_private.h +++ b/sys/dev/bhnd/cores/chipc/chipc_private.h @@ -101,7 +101,6 @@ struct chipc_region { resource ID */ struct bhnd_resource *cr_res; /**< bus resource, or NULL */ - int cr_res_rid; /**< cr_res RID, if any. */ u_int cr_refs; /**< RF_ALLOCATED refcount */ u_int cr_act_refs; /**< RF_ACTIVE refcount */ diff --git a/sys/dev/bhnd/cores/chipc/chipc_subr.c b/sys/dev/bhnd/cores/chipc/chipc_subr.c index bb5764af1ef3..9aa292e9e093 100644 --- a/sys/dev/bhnd/cores/chipc/chipc_subr.c +++ b/sys/dev/bhnd/cores/chipc/chipc_subr.c @@ -374,8 +374,7 @@ chipc_free_region(struct chipc_softc *sc, struct chipc_region *cr) cr->cr_region_num, cr->cr_refs)); if (cr->cr_res != NULL) { - bhnd_release_resource(sc->dev, SYS_RES_MEMORY, cr->cr_res_rid, - cr->cr_res); + bhnd_release_resource(sc->dev, cr->cr_res); } free(cr, M_BHND); @@ -462,14 +461,14 @@ chipc_retain_region(struct chipc_softc *sc, struct chipc_region *cr, int flags) ("non-NULL resource has refcount")); /* Fetch initial resource ID */ - if ((cr->cr_res_rid = cr->cr_rid) == -1) { + if (cr->cr_rid == -1) { CHIPC_UNLOCK(sc); return (EINVAL); } /* Allocate resource */ cr->cr_res = bhnd_alloc_resource(sc->dev, - SYS_RES_MEMORY, cr->cr_res_rid, cr->cr_addr, + SYS_RES_MEMORY, cr->cr_rid, cr->cr_addr, cr->cr_end, cr->cr_count, RF_SHAREABLE); if (cr->cr_res == NULL) { CHIPC_UNLOCK(sc); @@ -488,8 +487,7 @@ chipc_retain_region(struct chipc_softc *sc, struct chipc_region *cr, int flags) /* If this is the first reference, activate the resource */ if (cr->cr_act_refs == 0) { - error = bhnd_activate_resource(sc->dev, SYS_RES_MEMORY, - cr->cr_res_rid, cr->cr_res); + error = bhnd_activate_resource(sc->dev, cr->cr_res); if (error) { /* Drop any allocation reference acquired * above */ @@ -535,8 +533,7 @@ chipc_release_region(struct chipc_softc *sc, struct chipc_region *cr, /* If this is the last reference, deactivate the resource */ if (cr->cr_act_refs == 1) { - error = bhnd_deactivate_resource(sc->dev, - SYS_RES_MEMORY, cr->cr_res_rid, cr->cr_res); + error = bhnd_deactivate_resource(sc->dev, cr->cr_res); if (error) goto done; } @@ -549,8 +546,7 @@ chipc_release_region(struct chipc_softc *sc, struct chipc_region *cr, KASSERT(cr->cr_refs > 0, ("overrelease of refs")); /* If this is the last reference, release the resource */ if (cr->cr_refs == 1) { - error = bhnd_release_resource(sc->dev, SYS_RES_MEMORY, - cr->cr_res_rid, cr->cr_res); + error = bhnd_release_resource(sc->dev, cr->cr_res); if (error) goto done; diff --git a/sys/dev/bhnd/cores/pci/bhnd_pci.c b/sys/dev/bhnd/cores/pci/bhnd_pci.c index b8af7dd29fc5..3382f86bfb43 100644 --- a/sys/dev/bhnd/cores/pci/bhnd_pci.c +++ b/sys/dev/bhnd/cores/pci/bhnd_pci.c @@ -132,7 +132,7 @@ bhnd_pci_generic_attach(device_t dev) sizeof(bhnd_pci_devs[0])); /* Allocate bus resources */ - sc->mem_res = bhnd_alloc_resource_any(dev, SYS_RES_MEMORY, sc->mem_rid, + sc->mem_res = bhnd_alloc_resource_any(dev, SYS_RES_MEMORY, 0, RF_ACTIVE); if (sc->mem_res == NULL) return (ENXIO); @@ -156,7 +156,7 @@ bhnd_pci_generic_detach(device_t dev) if ((error = bus_generic_detach(dev))) return (error); - bhnd_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem_res); + bhnd_release_resource(dev, sc->mem_res); BHND_PCI_LOCK_DESTROY(sc); diff --git a/sys/dev/bhnd/cores/pci/bhnd_pcivar.h b/sys/dev/bhnd/cores/pci/bhnd_pcivar.h index 14026d1b8b44..ece08703df5b 100644 --- a/sys/dev/bhnd/cores/pci/bhnd_pcivar.h +++ b/sys/dev/bhnd/cores/pci/bhnd_pcivar.h @@ -99,7 +99,6 @@ struct bhnd_pci_softc { accesses. */ struct bhnd_resource *mem_res; /**< device register block. */ - int mem_rid; /**< register block RID */ }; #define BHND_PCI_LOCK_INIT(sc) \ diff --git a/sys/dev/bhnd/cores/pcie2/bhnd_pcie2.c b/sys/dev/bhnd/cores/pcie2/bhnd_pcie2.c index 01881aca3876..1af80d84f574 100644 --- a/sys/dev/bhnd/cores/pcie2/bhnd_pcie2.c +++ b/sys/dev/bhnd/cores/pcie2/bhnd_pcie2.c @@ -96,7 +96,7 @@ bhnd_pcie2_generic_attach(device_t dev) sizeof(bhnd_pcie2_devs[0])); /* Allocate bus resources */ - sc->mem_res = bhnd_alloc_resource_any(dev, SYS_RES_MEMORY, sc->mem_rid, + sc->mem_res = bhnd_alloc_resource_any(dev, SYS_RES_MEMORY, 0, RF_ACTIVE); if (sc->mem_res == NULL) return (ENXIO); @@ -120,7 +120,7 @@ bhnd_pcie2_generic_detach(device_t dev) if ((error = bus_generic_detach(dev))) return (error); - bhnd_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem_res); + bhnd_release_resource(dev, sc->mem_res); BHND_PCIE2_LOCK_DESTROY(sc); diff --git a/sys/dev/bhnd/cores/pcie2/bhnd_pcie2_var.h b/sys/dev/bhnd/cores/pcie2/bhnd_pcie2_var.h index 6930b29cc85d..fe8baf77efc3 100644 --- a/sys/dev/bhnd/cores/pcie2/bhnd_pcie2_var.h +++ b/sys/dev/bhnd/cores/pcie2/bhnd_pcie2_var.h @@ -83,7 +83,6 @@ struct bhnd_pcie2_softc { accesses. */ struct bhnd_resource *mem_res; /**< device register block. */ - int mem_rid; /**< register block RID */ }; #define BHND_PCIE2_LOCK_INIT(sc) \ diff --git a/sys/dev/bhnd/cores/pmu/bhnd_pmu_core.c b/sys/dev/bhnd/cores/pmu/bhnd_pmu_core.c index e4bb34cab5a8..12ceaee9b45d 100644 --- a/sys/dev/bhnd/cores/pmu/bhnd_pmu_core.c +++ b/sys/dev/bhnd/cores/pmu/bhnd_pmu_core.c @@ -81,13 +81,11 @@ bhnd_pmu_core_attach(device_t dev) struct bhnd_pmu_softc *sc; struct bhnd_resource *res; int error; - int rid; sc = device_get_softc(dev); /* Allocate register block */ - rid = 0; - res = bhnd_alloc_resource_any(dev, SYS_RES_MEMORY, rid, RF_ACTIVE); + res = bhnd_alloc_resource_any(dev, SYS_RES_MEMORY, 0, RF_ACTIVE); if (res == NULL) { device_printf(dev, "failed to allocate resources\n"); return (ENXIO); @@ -103,11 +101,10 @@ bhnd_pmu_core_attach(device_t dev) /* Delegate to common driver implementation */ if ((error = bhnd_pmu_attach(dev, res))) { - bhnd_release_resource(dev, SYS_RES_MEMORY, rid, res); + bhnd_release_resource(dev, res); return (error); } - sc->rid = rid; return (0); } @@ -123,7 +120,7 @@ bhnd_pmu_core_detach(device_t dev) if ((error = bhnd_pmu_detach(dev))) return (error); - bhnd_release_resource(dev, SYS_RES_MEMORY, sc->rid, sc->res); + bhnd_release_resource(dev, sc->res); return (0); } diff --git a/sys/dev/bhnd/cores/pmu/bhnd_pmuvar.h b/sys/dev/bhnd/cores/pmu/bhnd_pmuvar.h index 665d513aa60c..7ee13cc69ec5 100644 --- a/sys/dev/bhnd/cores/pmu/bhnd_pmuvar.h +++ b/sys/dev/bhnd/cores/pmu/bhnd_pmuvar.h @@ -105,7 +105,6 @@ struct bhnd_pmu_softc { device_t chipc_dev; /**< chipcommon device */ struct bhnd_resource *res; /**< pmu register block. */ - int rid; /**< pmu register RID */ struct bhnd_core_clkctl *clkctl; /**< pmu clkctl register */ struct mtx mtx; /**< state mutex */ diff --git a/sys/dev/bhnd/nvram/bhnd_sprom.c b/sys/dev/bhnd/nvram/bhnd_sprom.c index 9975b4525cdf..28d90113e464 100644 --- a/sys/dev/bhnd/nvram/bhnd_sprom.c +++ b/sys/dev/bhnd/nvram/bhnd_sprom.c @@ -96,7 +96,6 @@ bhnd_sprom_attach(device_t dev, bus_size_t offset) struct bhnd_nvram_io *io; struct bhnd_resource *r; bus_size_t r_size, sprom_size; - int rid; int error; sc = device_get_softc(dev); @@ -107,8 +106,7 @@ bhnd_sprom_attach(device_t dev, bus_size_t offset) r = NULL; /* Allocate SPROM resource */ - rid = 0; - r = bhnd_alloc_resource_any(dev, SYS_RES_MEMORY, rid, RF_ACTIVE); + r = bhnd_alloc_resource_any(dev, SYS_RES_MEMORY, 0, RF_ACTIVE); if (r == NULL) { device_printf(dev, "failed to allocate resources\n"); return (ENXIO); @@ -140,7 +138,7 @@ bhnd_sprom_attach(device_t dev, bus_size_t offset) /* Clean up our temporary I/O context and its backing resource */ bhnd_nvram_io_free(io); - bhnd_release_resource(dev, SYS_RES_MEMORY, rid, r); + bhnd_release_resource(dev, r); io = NULL; r = NULL; @@ -160,7 +158,7 @@ failed: bhnd_nvram_io_free(io); if (r != NULL) - bhnd_release_resource(dev, SYS_RES_MEMORY, rid, r); + bhnd_release_resource(dev, r); if (sc->store != NULL) bhnd_nvram_store_free(sc->store); diff --git a/sys/dev/bhnd/siba/siba.c b/sys/dev/bhnd/siba/siba.c index c4abf8b75765..baccf027578e 100644 --- a/sys/dev/bhnd/siba/siba.c +++ b/sys/dev/bhnd/siba/siba.c @@ -1182,7 +1182,7 @@ siba_map_cfg_resources(device_t dev, struct siba_devinfo *dinfo) struct siba_addrspace *addrspace; rman_res_t r_start, r_count, r_end; uint8_t num_cfg; - int rid; + int cfg_rid, rid; num_cfg = dinfo->core_id.num_cfg_blocks; if (num_cfg > SIBA_MAX_CFG) { @@ -1218,9 +1218,9 @@ siba_map_cfg_resources(device_t dev, struct siba_devinfo *dinfo) }); /* Map the config resource for bus-level access */ - dinfo->cfg_rid[i] = SIBA_CFG_RID(dinfo, i); + cfg_rid = SIBA_CFG_RID(dinfo, i); dinfo->cfg_res[i] = BHND_BUS_ALLOC_RESOURCE(dev, dev, - SYS_RES_MEMORY, dinfo->cfg_rid[i], r_start, r_end, + SYS_RES_MEMORY, cfg_rid, r_start, r_end, r_count, RF_ACTIVE|RF_SHAREABLE); if (dinfo->cfg_res[i] == NULL) { diff --git a/sys/dev/bhnd/siba/siba_subr.c b/sys/dev/bhnd/siba/siba_subr.c index fee874fea09f..6642185165cd 100644 --- a/sys/dev/bhnd/siba/siba_subr.c +++ b/sys/dev/bhnd/siba/siba_subr.c @@ -93,7 +93,6 @@ siba_alloc_dinfo(device_t bus) .cb_rid = -1, }); dinfo->cfg_res[i] = NULL; - dinfo->cfg_rid[i] = -1; } resource_list_init(&dinfo->resources); @@ -569,11 +568,9 @@ siba_free_dinfo(device_t dev, device_t child, struct siba_devinfo *dinfo) if (dinfo->cfg_res[i] == NULL) continue; - bhnd_release_resource(dev, SYS_RES_MEMORY, dinfo->cfg_rid[i], - dinfo->cfg_res[i]); + bhnd_release_resource(dev, dinfo->cfg_res[i]); dinfo->cfg_res[i] = NULL; - dinfo->cfg_rid[i] = -1; } /* Unmap the core's interrupt */ diff --git a/sys/dev/bhnd/siba/sibavar.h b/sys/dev/bhnd/siba/sibavar.h index 7fc1bcf228d9..2185c5b6b229 100644 --- a/sys/dev/bhnd/siba/sibavar.h +++ b/sys/dev/bhnd/siba/sibavar.h @@ -211,7 +211,6 @@ struct siba_devinfo { struct siba_intr intr; /**< interrupt flag mapping, if any */ struct bhnd_resource *cfg_res[SIBA_MAX_CFG]; /**< bus-mapped config block registers */ - int cfg_rid[SIBA_MAX_CFG]; /**< bus-mapped config block resource IDs */ siba_pmu_state pmu_state; /**< per-core PMU state */ union { void *bhnd_info; /**< if SIBA_PMU_BHND, bhnd(4)-managed per-core PMU info. */