@@ -3218,8 +3218,7 @@ cxl_port_find_switch_decoder(struct cxl_port *port, struct range *hpa)
return cxld_dev ? to_cxl_decoder(cxld_dev) : NULL;
}
-static struct cxl_root_decoder *
-cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled)
+static int cxl_endpoint_initialize(struct cxl_endpoint_decoder *cxled)
{
struct cxl_memdev *cxlmd = cxled_to_memdev(cxled);
struct cxl_port *iter = cxled_to_port(cxled);
@@ -3230,7 +3229,7 @@ cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled)
iter = to_cxl_port(iter->dev.parent);
if (!iter)
- return NULL;
+ return -ENXIO;
cxld = cxl_port_find_switch_decoder(iter, hpa);
if (!cxld) {
@@ -3238,12 +3237,12 @@ cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled)
"%s:%s no CXL window for range %#llx:%#llx\n",
dev_name(&cxlmd->dev), dev_name(&cxld->dev),
cxld->hpa_range.start, cxld->hpa_range.end);
- return NULL;
+ return -ENXIO;
}
+ cxled->cxlrd = to_cxl_root_decoder(&cxld->dev);
-
- return to_cxl_root_decoder(&cxld->dev);
+ return 0;
}
static int match_region_by_range(struct device *dev, void *data)
@@ -3364,19 +3363,6 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
return ERR_PTR(rc);
}
-static int cxl_endpoint_initialize(struct cxl_endpoint_decoder *cxled)
-{
- struct cxl_root_decoder *cxlrd;
-
- cxlrd = cxl_find_root_decoder(cxled);
- if (!cxlrd)
- return -ENXIO;
-
- cxled->cxlrd = cxlrd;
-
- return 0;
-}
-
static int cxl_endpoint_add(struct cxl_endpoint_decoder *cxled)
{
struct range *hpa = &cxled->cxld.hpa_range;
To determine other endpoint parameters such as interleaving parameters during endpoint initialization, the iterator function in cxl_find_root_decoder() can be used. Unfold this function into cxl_endpoint_initialize() and make the iterator available there. Signed-off-by: Robert Richter <rrichter@amd.com> --- drivers/cxl/core/region.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-)