Skip to content

Commit 453a7fd

Browse files
AlisonSchofielddjbw
authored andcommitted
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: Alison Schofield <[email protected]> Tested-by: Wonjae Lee <[email protected]> Link: https://lore.kernel.org/r/79ae6d72978ef9f3ceec9722e1cb793820553c8e.1706736863.git.alison.schofield@intel.com Signed-off-by: Dan Williams <[email protected]>
1 parent b626070 commit 453a7fd

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/cxl/core/region.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -730,12 +730,17 @@ static int match_auto_decoder(struct device *dev, void *data)
730730
return 0;
731731
}
732732

733-
static struct cxl_decoder *cxl_region_find_decoder(struct cxl_port *port,
734-
struct cxl_region *cxlr)
733+
static struct cxl_decoder *
734+
cxl_region_find_decoder(struct cxl_port *port,
735+
struct cxl_endpoint_decoder *cxled,
736+
struct cxl_region *cxlr)
735737
{
736738
struct device *dev;
737739
int id = 0;
738740

741+
if (port == cxled_to_port(cxled))
742+
return &cxled->cxld;
743+
739744
if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags))
740745
dev = device_find_child(&port->dev, &cxlr->params,
741746
match_auto_decoder);
@@ -853,10 +858,7 @@ static int cxl_rr_alloc_decoder(struct cxl_port *port, struct cxl_region *cxlr,
853858
{
854859
struct cxl_decoder *cxld;
855860

856-
if (port == cxled_to_port(cxled))
857-
cxld = &cxled->cxld;
858-
else
859-
cxld = cxl_region_find_decoder(port, cxlr);
861+
cxld = cxl_region_find_decoder(port, cxled, cxlr);
860862
if (!cxld) {
861863
dev_dbg(&cxlr->dev, "%s: no decoder available\n",
862864
dev_name(&port->dev));

0 commit comments

Comments
 (0)