Commit 453a7fde authored by Alison Schofield's avatar Alison Schofield Committed by Dan Williams
Browse files

cxl/region: Handle endpoint decoders in cxl_region_find_decoder()



In preparation for adding a new caller of cxl_region_find_decoders()
teach it to find a decoder from a cxl_endpoint_decoder structure.

Combining switch and endpoint decoder lookup in one function prevents
code duplication in call sites.

Update the existing caller.

Signed-off-by: default avatarAlison Schofield <alison.schofield@intel.com>
Tested-by: default avatarWonjae Lee <wj28.lee@samsung.com>
Link: https://lore.kernel.org/r/79ae6d72978ef9f3ceec9722e1cb793820553c8e.1706736863.git.alison.schofield@intel.com


Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent b626070f
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -730,12 +730,17 @@ static int match_auto_decoder(struct device *dev, void *data)
	return 0;
}

static struct cxl_decoder *cxl_region_find_decoder(struct cxl_port *port,
static struct cxl_decoder *
cxl_region_find_decoder(struct cxl_port *port,
			struct cxl_endpoint_decoder *cxled,
			struct cxl_region *cxlr)
{
	struct device *dev;
	int id = 0;

	if (port == cxled_to_port(cxled))
		return &cxled->cxld;

	if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags))
		dev = device_find_child(&port->dev, &cxlr->params,
					match_auto_decoder);
@@ -853,10 +858,7 @@ static int cxl_rr_alloc_decoder(struct cxl_port *port, struct cxl_region *cxlr,
{
	struct cxl_decoder *cxld;

	if (port == cxled_to_port(cxled))
		cxld = &cxled->cxld;
	else
		cxld = cxl_region_find_decoder(port, cxlr);
	cxld = cxl_region_find_decoder(port, cxled, cxlr);
	if (!cxld) {
		dev_dbg(&cxlr->dev, "%s: no decoder available\n",
			dev_name(&port->dev));