cxl/region: Handle endpoint decoders in cxl_region_find_decoder()
[ Upstream commit 453a7fde8031a5192ed2f9646ad048c1a5e930dc ] 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 <alison.schofield@intel.com> Tested-by: Wonjae Lee <wj28.lee@samsung.com> Link: https://lore.kernel.org/r/79ae6d72978ef9f3ceec9722e1cb793820553c8e.1706736863.git.alison.schofield@intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
031b6233fe
commit
9f57eecf94
|
@ -729,12 +729,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,
|
||||
struct cxl_region *cxlr)
|
||||
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);
|
||||
|
@ -852,10 +857,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));
|
||||
|
|
Loading…
Reference in New Issue