[PATCH v8 1/3] cxl/region: Simplify poison_by_decoder() error handling
From: Richard Cheng
Date: Fri Jul 31 2026 - 02:51:58 EST
"rc" carries both an error code and the loop control
signal for device_for_each_child(), so returning it bare is misleading,
the early guards mean "keep walking", not "no error". Zeroing "rc" to
forgive an -EFAULT on a RAM partition adds to that by discarding what
the device actually returned.
Return a literal 0 where the walk should continue, and test the
forgiven case directly instead of rewriting "rc". No functional change.
Suggested-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
Signed-off-by: Richard Cheng <icheng@xxxxxxxxxx>
---
drivers/cxl/core/region.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 1e211542b6b6..fabaad3469b1 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -2950,14 +2950,14 @@ static int poison_by_decoder(struct device *dev, void *arg)
struct cxl_dev_state *cxlds;
struct cxl_memdev *cxlmd;
u64 offset, length;
- int rc = 0;
+ int rc;
if (!is_endpoint_decoder(dev))
- return rc;
+ return 0;
cxled = to_cxl_endpoint_decoder(dev);
if (!cxled->dpa_res)
- return rc;
+ return 0;
cxlmd = cxled_to_memdev(cxled);
cxlds = cxlmd->cxlds;
@@ -2967,18 +2967,14 @@ static int poison_by_decoder(struct device *dev, void *arg)
offset = cxled->dpa_res->start - cxled->skip;
length = cxled->skip;
rc = cxl_mem_get_poison(cxlmd, offset, length, NULL);
- if (rc == -EFAULT && mode == CXL_PARTMODE_RAM)
- rc = 0;
- if (rc)
+ if (rc && (rc != -EFAULT || mode != CXL_PARTMODE_RAM))
return rc;
}
offset = cxled->dpa_res->start;
length = cxled->dpa_res->end - offset + 1;
rc = cxl_mem_get_poison(cxlmd, offset, length, cxled->cxld.region);
- if (rc == -EFAULT && mode == CXL_PARTMODE_RAM)
- rc = 0;
- if (rc)
+ if (rc && (rc != -EFAULT || mode != CXL_PARTMODE_RAM))
return rc;
/* Iterate until commit_end is reached */
--
2.43.0