]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cxl/region: Avoid variable shadowing in region attach paths
authorAlison Schofield <alison.schofield@intel.com>
Fri, 5 Jun 2026 04:05:01 +0000 (21:05 -0700)
committerDave Jiang <dave.jiang@intel.com>
Tue, 9 Jun 2026 17:43:33 +0000 (10:43 -0700)
A couple of symbol declarations shadow earlier variables in the region
attach paths. Shadowing makes it harder to tell which object is being
referenced and can obscure future bugs.

Reuse the existing 'cxld' variable in cxl_port_attach_region() and
rename the endpoint decoder iterator in cxl_region_attach() to avoid
shadowing the function parameter.

No functional change.

Found with sparse.

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Li Ming <ming.li@zohomail.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/20260605040504.865728-1-alison.schofield@intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
drivers/cxl/core/region.c

index cc41c08c0c0cb039aebadca2cf562e866f87b1c5..f5cd20f48d2b9141ddf3f49810183556355d3088 100644 (file)
@@ -1224,8 +1224,6 @@ static int cxl_port_attach_region(struct cxl_port *port,
                        nr_targets_inc = true;
                }
        } else {
-               struct cxl_decoder *cxld;
-
                cxld = cxl_port_pick_region_decoder(port, cxled, cxlr);
                if (!cxld) {
                        dev_dbg(&cxlr->dev, "%s: no decoder available\n",
@@ -2189,14 +2187,14 @@ static int cxl_region_attach(struct cxl_region *cxlr,
         * will fail when presented as CXL_REGION_F_AUTO.
         */
        for (int i = 0; i < p->nr_targets; i++) {
-               struct cxl_endpoint_decoder *cxled = p->targets[i];
+               struct cxl_endpoint_decoder *target = p->targets[i];
                int test_pos;
 
-               test_pos = cxl_calc_interleave_pos(cxled, &cxlr->hpa_range);
-               dev_dbg(&cxled->cxld.dev,
-                       "Test cxl_calc_interleave_pos(): %s test_pos:%d cxled->pos:%d\n",
-                       (test_pos == cxled->pos) ? "success" : "fail",
-                       test_pos, cxled->pos);
+               test_pos = cxl_calc_interleave_pos(target, &cxlr->hpa_range);
+               dev_dbg(&target->cxld.dev,
+                       "Test cxl_calc_interleave_pos(): %s test_pos:%d target->pos:%d\n",
+                       (test_pos == target->pos) ? "success" : "fail",
+                       test_pos, target->pos);
        }
 
        return 0;