The branch main has been updated by jhb:

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

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

    dpaa2_rc_add_res: Pass rid by value
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D53408
---
 sys/dev/dpaa2/dpaa2_rc.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/sys/dev/dpaa2/dpaa2_rc.c b/sys/dev/dpaa2/dpaa2_rc.c
index 36cacd1daa4b..5e4346ad6969 100644
--- a/sys/dev/dpaa2/dpaa2_rc.c
+++ b/sys/dev/dpaa2/dpaa2_rc.c
@@ -79,7 +79,7 @@ static int dpaa2_rc_add_managed_child(struct dpaa2_rc_softc *,
 static int dpaa2_rc_enable_irq(struct dpaa2_mcp *, struct dpaa2_cmd *, uint8_t,
     bool, uint16_t);
 static int dpaa2_rc_configure_irq(device_t, device_t, int, uint64_t, uint32_t);
-static int dpaa2_rc_add_res(device_t, device_t, enum dpaa2_dev_type, int *, 
int);
+static int dpaa2_rc_add_res(device_t, device_t, enum dpaa2_dev_type, int, int);
 static int dpaa2_rc_print_type(struct resource_list *, enum dpaa2_dev_type);
 static struct dpaa2_mcp *dpaa2_rc_select_portal(device_t, device_t);
 
@@ -2890,7 +2890,7 @@ dpaa2_rc_add_child(struct dpaa2_rc_softc *sc, struct 
dpaa2_cmd *cmd,
        const char *devclass;
        int dpio_n = 0; /* to limit DPIOs by # of CPUs */
        int dpcon_n = 0; /* to limit DPCONs by # of CPUs */
-       int rid, error;
+       int error;
 
        rcdev = sc->dev;
        rcinfo = device_get_ivars(rcdev);
@@ -2944,7 +2944,6 @@ dpaa2_rc_add_child(struct dpaa2_rc_softc *sc, struct 
dpaa2_cmd *cmd,
        for (; res_spec && res_spec->type != -1; res_spec++) {
                if (res_spec->type < DPAA2_DEV_MC)
                        continue; /* Skip non-DPAA2 resource. */
-               rid = res_spec->rid;
 
                /* Limit DPIOs and DPCONs by number of CPUs. */
                if (res_spec->type == DPAA2_DEV_IO && dpio_n >= mp_ncpus) {
@@ -2956,8 +2955,8 @@ dpaa2_rc_add_child(struct dpaa2_rc_softc *sc, struct 
dpaa2_cmd *cmd,
                        continue;
                }
 
-               error = dpaa2_rc_add_res(rcdev, dev, res_spec->type, &rid,
-                   res_spec->flags);
+               error = dpaa2_rc_add_res(rcdev, dev, res_spec->type,
+                   res_spec->rid, res_spec->flags);
                if (error)
                        device_printf(rcdev, "%s: dpaa2_rc_add_res() failed: "
                            "error=%d\n", __func__, error);
@@ -2993,7 +2992,7 @@ dpaa2_rc_add_managed_child(struct dpaa2_rc_softc *sc, 
struct dpaa2_cmd *cmd,
        const char *devclass;
        uint64_t start, end, count;
        uint32_t flags = 0;
-       int rid, error;
+       int error;
 
        rcdev = sc->dev;
        child = sc->dev;
@@ -3088,10 +3087,9 @@ dpaa2_rc_add_managed_child(struct dpaa2_rc_softc *sc, 
struct dpaa2_cmd *cmd,
        for (; res_spec && res_spec->type != -1; res_spec++) {
                if (res_spec->type < DPAA2_DEV_MC)
                        continue; /* Skip non-DPAA2 resource. */
-               rid = res_spec->rid;
 
-               error = dpaa2_rc_add_res(rcdev, dev, res_spec->type, &rid,
-                   res_spec->flags);
+               error = dpaa2_rc_add_res(rcdev, dev, res_spec->type,
+                   res_spec->rid, res_spec->flags);
                if (error)
                        device_printf(rcdev, "%s: dpaa2_rc_add_res() failed: "
                            "error=%d\n", __func__, error);
@@ -3285,7 +3283,7 @@ dpaa2_rc_wait_for_cmd(struct dpaa2_mcp *mcp, struct 
dpaa2_cmd *cmd)
  */
 static int
 dpaa2_rc_add_res(device_t rcdev, device_t child, enum dpaa2_dev_type devtype,
-    int *rid, int flags)
+    int rid, int flags)
 {
        device_t dpaa2_dev;
        struct dpaa2_devinfo *dinfo = device_get_ivars(child);
@@ -3297,7 +3295,7 @@ dpaa2_rc_add_res(device_t rcdev, device_t child, enum 
dpaa2_dev_type devtype,
        error = DPAA2_MC_GET_FREE_DEV(rcdev, &dpaa2_dev, devtype);
        if (error && !(flags & RF_SHAREABLE)) {
                device_printf(rcdev, "%s: failed to obtain a free %s (rid=%d) "
-                   "for: %s (id=%u)\n", __func__, dpaa2_ttos(devtype), *rid,
+                   "for: %s (id=%u)\n", __func__, dpaa2_ttos(devtype), rid,
                    dpaa2_ttos(dinfo->dtype), dinfo->id);
                return (error);
        }
@@ -3308,7 +3306,7 @@ dpaa2_rc_add_res(device_t rcdev, device_t child, enum 
dpaa2_dev_type devtype,
                if (error) {
                        device_printf(rcdev, "%s: failed to obtain a shared "
                            "%s (rid=%d) for: %s (id=%u)\n", __func__,
-                           dpaa2_ttos(devtype), *rid, dpaa2_ttos(dinfo->dtype),
+                           dpaa2_ttos(devtype), rid, dpaa2_ttos(dinfo->dtype),
                            dinfo->id);
                        return (error);
                }
@@ -3316,16 +3314,16 @@ dpaa2_rc_add_res(device_t rcdev, device_t child, enum 
dpaa2_dev_type devtype,
        }
 
        /* Add DPAA2 device to the resource list of the child device. */
-       resource_list_add(&dinfo->resources, devtype, *rid,
+       resource_list_add(&dinfo->resources, devtype, rid,
            (rman_res_t) dpaa2_dev, (rman_res_t) dpaa2_dev, 1);
 
        /* Reserve a newly added DPAA2 resource. */
        res = resource_list_reserve(&dinfo->resources, rcdev, child, devtype,
-           *rid, (rman_res_t) dpaa2_dev, (rman_res_t) dpaa2_dev, 1,
+           rid, (rman_res_t) dpaa2_dev, (rman_res_t) dpaa2_dev, 1,
            flags & ~RF_ACTIVE);
        if (!res) {
                device_printf(rcdev, "%s: failed to reserve %s (rid=%d) for: %s 
"
-                   "(id=%u)\n", __func__, dpaa2_ttos(devtype), *rid,
+                   "(id=%u)\n", __func__, dpaa2_ttos(devtype), rid,
                    dpaa2_ttos(dinfo->dtype), dinfo->id);
                return (EBUSY);
        }
@@ -3336,7 +3334,7 @@ dpaa2_rc_add_res(device_t rcdev, device_t child, enum 
dpaa2_dev_type devtype,
                if (error) {
                        device_printf(rcdev, "%s: failed to reserve a shared "
                            "%s (rid=%d) for: %s (id=%u)\n", __func__,
-                           dpaa2_ttos(devtype), *rid, dpaa2_ttos(dinfo->dtype),
+                           dpaa2_ttos(devtype), rid, dpaa2_ttos(dinfo->dtype),
                            dinfo->id);
                        return (error);
                }

Reply via email to