The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ca942ab4b2b665e5375cc72afc4930d3b33b14f9

commit ca942ab4b2b665e5375cc72afc4930d3b33b14f9
Author:     John Baldwin <[email protected]>
AuthorDate: 2025-12-09 20:03:42 +0000
Commit:     John Baldwin <[email protected]>
CommitDate: 2025-12-09 20:03:42 +0000

    bhnd_bus_*_resource: Remove redundant type and rid arguments
    
    Remove type and rid arguments from
    bhnd_bus_(activate|deactivate|release)_resource.  This should have
    been done earlier to match the changes made to bus_release_resource,
    etc.
    
    While fixing up the callers, remove rid members from softc structures
    since the only time a value is needed is as a constant input to
    bhnd_bus_alloc_resource*.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D53410
---
 sys/dev/bhnd/bcma/bcma_subr.c             | 10 ++++------
 sys/dev/bhnd/bcma/bcmavar.h               |  1 -
 sys/dev/bhnd/bhnd.h                       | 33 +++++++++----------------------
 sys/dev/bhnd/bhnd_bus_if.m                |  6 ------
 sys/dev/bhnd/bhnd_erom.c                  | 14 +++----------
 sys/dev/bhnd/bhnd_subr.c                  | 20 +++++++++----------
 sys/dev/bhnd/bhndb/bhndb.c                | 10 +++++-----
 sys/dev/bhnd/cores/chipc/chipc.c          |  9 ++++-----
 sys/dev/bhnd/cores/chipc/chipc_gpio.c     |  8 +++-----
 sys/dev/bhnd/cores/chipc/chipc_gpiovar.h  |  1 -
 sys/dev/bhnd/cores/chipc/chipc_private.h  |  1 -
 sys/dev/bhnd/cores/chipc/chipc_subr.c     | 16 ++++++---------
 sys/dev/bhnd/cores/pci/bhnd_pci.c         |  4 ++--
 sys/dev/bhnd/cores/pci/bhnd_pcivar.h      |  1 -
 sys/dev/bhnd/cores/pcie2/bhnd_pcie2.c     |  4 ++--
 sys/dev/bhnd/cores/pcie2/bhnd_pcie2_var.h |  1 -
 sys/dev/bhnd/cores/pmu/bhnd_pmu_core.c    |  9 +++------
 sys/dev/bhnd/cores/pmu/bhnd_pmuvar.h      |  1 -
 sys/dev/bhnd/nvram/bhnd_sprom.c           |  8 +++-----
 sys/dev/bhnd/siba/siba.c                  |  6 +++---
 sys/dev/bhnd/siba/siba_subr.c             |  5 +----
 sys/dev/bhnd/siba/sibavar.h               |  1 -
 22 files changed, 58 insertions(+), 111 deletions(-)

diff --git a/sys/dev/bhnd/bcma/bcma_subr.c b/sys/dev/bhnd/bcma/bcma_subr.c
index 9e442ce911d4..fceca807df9c 100644
--- a/sys/dev/bhnd/bcma/bcma_subr.c
+++ b/sys/dev/bhnd/bcma/bcma_subr.c
@@ -214,7 +214,7 @@ bcma_dinfo_init_agent(device_t bus, device_t child, struct 
bcma_devinfo *dinfo)
        bhnd_addr_t     addr;
        bhnd_size_t     size;
        rman_res_t      r_start, r_count, r_end;
-       int             error;
+       int             error, rid_agent;
 
        KASSERT(dinfo->res_agent == NULL, ("double allocation of agent"));
 
@@ -237,9 +237,9 @@ bcma_dinfo_init_agent(device_t bus, device_t child, struct 
bcma_devinfo *dinfo)
        r_count = size;
        r_end = r_start + r_count - 1;
 
-       dinfo->rid_agent = BCMA_AGENT_RID(dinfo);
+       rid_agent = BCMA_AGENT_RID(dinfo);
        dinfo->res_agent = BHND_BUS_ALLOC_RESOURCE(bus, bus, SYS_RES_MEMORY,
-           dinfo->rid_agent, r_start, r_end, r_count, RF_ACTIVE|RF_SHAREABLE);
+           rid_agent, r_start, r_end, r_count, RF_ACTIVE|RF_SHAREABLE);
        if (dinfo->res_agent == NULL) {
                device_printf(bus, "failed allocating agent register block for "
                    "core %u\n", BCMA_DINFO_COREIDX(dinfo));
@@ -332,7 +332,6 @@ bcma_alloc_dinfo(device_t bus)
 
        dinfo->corecfg = NULL;
        dinfo->res_agent = NULL;
-       dinfo->rid_agent = -1;
 
        STAILQ_INIT(&dinfo->intrs);
        dinfo->num_intrs = 0;
@@ -434,8 +433,7 @@ bcma_free_dinfo(device_t bus, device_t child, struct 
bcma_devinfo *dinfo)
 
        /* Release agent resource, if any */
        if (dinfo->res_agent != NULL) {
-               bhnd_release_resource(bus, SYS_RES_MEMORY, dinfo->rid_agent,
-                   dinfo->res_agent);
+               bhnd_release_resource(bus, dinfo->res_agent);
        }
 
        /* Clean up interrupt descriptors */
diff --git a/sys/dev/bhnd/bcma/bcmavar.h b/sys/dev/bhnd/bcma/bcmavar.h
index 1a019b62970a..496a87946b3e 100644
--- a/sys/dev/bhnd/bcma/bcmavar.h
+++ b/sys/dev/bhnd/bcma/bcmavar.h
@@ -180,7 +180,6 @@ struct bcma_devinfo {
 
        struct bhnd_resource    *res_agent;     /**< Agent (wrapper) resource, 
or NULL. Not
                                                  *  all bcma(4) cores have or 
require an agent. */
-       int                      rid_agent;     /**< Agent resource ID, or -1 */
 
        u_int                    num_intrs;     /**< number of interrupt 
descriptors. */
        struct bcma_intr_list    intrs;         /**< interrupt descriptors */
diff --git a/sys/dev/bhnd/bhnd.h b/sys/dev/bhnd/bhnd.h
index da1686f4d6c9..1a29b922d491 100644
--- a/sys/dev/bhnd/bhnd.h
+++ b/sys/dev/bhnd/bhnd.h
@@ -621,14 +621,11 @@ struct bhnd_resource              
*bhnd_bus_generic_alloc_resource (device_t dev,
                                     rman_res_t start, rman_res_t end,
                                     rman_res_t count, u_int flags);
 int                             bhnd_bus_generic_release_resource (device_t 
dev,
-                                    device_t child, int type, int rid,
-                                    struct bhnd_resource *r);
+                                    device_t child, struct bhnd_resource *r);
 int                             bhnd_bus_generic_activate_resource (device_t 
dev,
-                                    device_t child, int type, int rid,
-                                    struct bhnd_resource *r);
+                                    device_t child, struct bhnd_resource *r);
 int                             bhnd_bus_generic_deactivate_resource (device_t 
dev,
-                                    device_t child, int type, int rid,
-                                    struct bhnd_resource *r);
+                                    device_t child, struct bhnd_resource *r);
 uintptr_t                       bhnd_bus_generic_get_intr_domain(device_t dev,
                                     device_t child, bool self);
 
@@ -1323,8 +1320,6 @@ bhnd_alloc_resource_any(device_t dev, int type, int rid, 
u_int flags)
  * Activate a previously allocated bhnd resource.
  *
  * @param dev The device holding ownership of the allocated resource.
- * @param type The type of the resource. 
- * @param rid The bus-specific handle identifying the resource.
  * @param r A pointer to the resource returned by bhnd_alloc_resource or
  * BHND_BUS_ALLOC_RESOURCE.
  * 
@@ -1332,19 +1327,15 @@ bhnd_alloc_resource_any(device_t dev, int type, int 
rid, u_int flags)
  * @retval non-zero an error occurred while activating the resource.
  */
 static inline int
-bhnd_activate_resource(device_t dev, int type, int rid,
-   struct bhnd_resource *r)
+bhnd_activate_resource(device_t dev, struct bhnd_resource *r)
 {
-       return BHND_BUS_ACTIVATE_RESOURCE(device_get_parent(dev), dev, type,
-           rid, r);
+       return BHND_BUS_ACTIVATE_RESOURCE(device_get_parent(dev), dev, r);
 }
 
 /**
  * Deactivate a previously activated bhnd resource.
  *
  * @param dev The device holding ownership of the activated resource.
- * @param type The type of the resource. 
- * @param rid The bus-specific handle identifying the resource.
  * @param r A pointer to the resource returned by bhnd_alloc_resource or
  * BHND_BUS_ALLOC_RESOURCE.
  * 
@@ -1352,19 +1343,15 @@ bhnd_activate_resource(device_t dev, int type, int rid,
  * @retval non-zero an error occurred while activating the resource.
  */
 static inline int
-bhnd_deactivate_resource(device_t dev, int type, int rid,
-   struct bhnd_resource *r)
+bhnd_deactivate_resource(device_t dev, struct bhnd_resource *r)
 {
-       return BHND_BUS_DEACTIVATE_RESOURCE(device_get_parent(dev), dev, type,
-           rid, r);
+       return BHND_BUS_DEACTIVATE_RESOURCE(device_get_parent(dev), dev, r);
 }
 
 /**
  * Free a resource allocated by bhnd_alloc_resource().
  *
  * @param dev The device holding ownership of the resource.
- * @param type The type of the resource. 
- * @param rid The bus-specific handle identifying the resource.
  * @param r A pointer to the resource returned by bhnd_alloc_resource or
  * BHND_ALLOC_RESOURCE.
  * 
@@ -1372,11 +1359,9 @@ bhnd_deactivate_resource(device_t dev, int type, int rid,
  * @retval non-zero an error occurred while activating the resource.
  */
 static inline int
-bhnd_release_resource(device_t dev, int type, int rid,
-   struct bhnd_resource *r)
+bhnd_release_resource(device_t dev, struct bhnd_resource *r)
 {
-       return BHND_BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, type,
-           rid, r);
+       return BHND_BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, r);
 }
 
 /**
diff --git a/sys/dev/bhnd/bhnd_bus_if.m b/sys/dev/bhnd/bhnd_bus_if.m
index 62c34404e87f..6ae56ceeb196 100644
--- a/sys/dev/bhnd/bhnd_bus_if.m
+++ b/sys/dev/bhnd/bhnd_bus_if.m
@@ -939,8 +939,6 @@ METHOD struct bhnd_resource * alloc_resource {
 METHOD int release_resource {
        device_t dev;
        device_t child;
-       int type;
-       int rid;
        struct bhnd_resource *res;
 } DEFAULT bhnd_bus_generic_release_resource;
 
@@ -953,8 +951,6 @@ METHOD int release_resource {
 METHOD int activate_resource {
        device_t dev;
         device_t child;
-       int type;
-        int rid;
         struct bhnd_resource *r;
 } DEFAULT bhnd_bus_generic_activate_resource;
 
@@ -967,8 +963,6 @@ METHOD int activate_resource {
 METHOD int deactivate_resource {
         device_t dev;
         device_t child;
-        int type;
-       int rid;
         struct bhnd_resource *r;
 } DEFAULT bhnd_bus_generic_deactivate_resource;
 
diff --git a/sys/dev/bhnd/bhnd_erom.c b/sys/dev/bhnd/bhnd_erom.c
index 2c4af61438fe..a8d6afe4b7f9 100644
--- a/sys/dev/bhnd/bhnd_erom.c
+++ b/sys/dev/bhnd/bhnd_erom.c
@@ -73,7 +73,6 @@ struct bhnd_erom_iores {
        device_t                 owner;         /**< device from which we'll 
allocate resources */
        int                      owner_rid;     /**< rid to use when allocating 
new mappings */
        struct bhnd_resource    *mapped;        /**< current mapping, or NULL */
-       int                      mapped_rid;    /**< resource ID of current 
mapping, or -1 */
 };
 
 /**
@@ -390,7 +389,6 @@ bhnd_erom_iores_new(device_t dev, int rid)
        iores->owner = dev;
        iores->owner_rid = rid;
        iores->mapped = NULL;
-       iores->mapped_rid = -1;
 
        return (&iores->eio);
 }
@@ -420,19 +418,15 @@ bhnd_erom_iores_map(struct bhnd_erom_io *eio, bhnd_addr_t 
addr,
                }
 
                /* Otherwise, we need to drop the existing mapping */
-               bhnd_release_resource(iores->owner, SYS_RES_MEMORY,
-                   iores->mapped_rid, iores->mapped);
+               bhnd_release_resource(iores->owner, iores->mapped);
                iores->mapped = NULL;
-               iores->mapped_rid = -1;
        }
 
        /* Try to allocate the new mapping */
-       iores->mapped_rid = iores->owner_rid;
        iores->mapped = bhnd_alloc_resource(iores->owner, SYS_RES_MEMORY,
-           iores->mapped_rid, addr, addr+size-1, size,
+           iores->owner_rid, addr, addr+size-1, size,
            RF_ACTIVE|RF_SHAREABLE);
        if (iores->mapped == NULL) {
-               iores->mapped_rid = -1;
                return (ENXIO);
        }
 
@@ -481,10 +475,8 @@ bhnd_erom_iores_fini(struct bhnd_erom_io *eio)
 
        /* Release any mapping */
        if (iores->mapped) {
-               bhnd_release_resource(iores->owner, SYS_RES_MEMORY,
-                   iores->mapped_rid, iores->mapped);
+               bhnd_release_resource(iores->owner, iores->mapped);
                iores->mapped = NULL;
-               iores->mapped_rid = -1;
        }
 
        free(eio, M_BHND);
diff --git a/sys/dev/bhnd/bhnd_subr.c b/sys/dev/bhnd/bhnd_subr.c
index 299388d51626..9274b2386728 100644
--- a/sys/dev/bhnd/bhnd_subr.c
+++ b/sys/dev/bhnd/bhnd_subr.c
@@ -1044,7 +1044,7 @@ bhnd_release_resources(device_t dev, const struct 
resource_spec *rs,
                if (res[i] == NULL)
                        continue;
 
-               bhnd_release_resource(dev, rs[i].type, rs[i].rid, res[i]);
+               bhnd_release_resource(dev, res[i]);
                res[i] = NULL;
        }
 }
@@ -2216,7 +2216,7 @@ bhnd_bus_generic_alloc_resource(device_t dev, device_t 
child, int type,
 
        /* Attempt activation */
        if (flags & RF_ACTIVE) {
-               error = BHND_BUS_ACTIVATE_RESOURCE(dev, child, type, rid, br);
+               error = BHND_BUS_ACTIVATE_RESOURCE(dev, child, br);
                if (error)
                        goto failed;
        }
@@ -2238,8 +2238,8 @@ failed:
  * the backing resource to BUS_RELEASE_RESOURCE().
  */
 int
-bhnd_bus_generic_release_resource(device_t dev, device_t child, int type,
-    int rid, struct bhnd_resource *r)
+bhnd_bus_generic_release_resource(device_t dev, device_t child,
+    struct bhnd_resource *r)
 {
        int error;
 
@@ -2262,8 +2262,8 @@ bhnd_bus_generic_release_resource(device_t dev, device_t 
child, int type,
  * to a parent bhnd bus or bridge.
  */
 int
-bhnd_bus_generic_activate_resource(device_t dev, device_t child, int type,
-    int rid, struct bhnd_resource *r)
+bhnd_bus_generic_activate_resource(device_t dev, device_t child,
+    struct bhnd_resource *r)
 {
        int     error;
        bool    passthrough;
@@ -2273,7 +2273,7 @@ bhnd_bus_generic_activate_resource(device_t dev, device_t 
child, int type,
        /* Try to delegate to the parent */
        if (device_get_parent(dev) != NULL) {
                error = BHND_BUS_ACTIVATE_RESOURCE(device_get_parent(dev),
-                   child, type, rid, r);
+                   child, r);
        } else {
                error = ENODEV;
        }
@@ -2282,7 +2282,7 @@ bhnd_bus_generic_activate_resource(device_t dev, device_t 
child, int type,
         * parent, try falling back on standard resource activation.
         */
        if (error && !passthrough) {
-               error = bus_activate_resource(child, type, rid, r->res);
+               error = bus_activate_resource(child, r->res);
                if (!error)
                        r->direct = true;
        }
@@ -2298,11 +2298,11 @@ bhnd_bus_generic_activate_resource(device_t dev, 
device_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. */

Reply via email to