The cxl_pmem driver specific cxl_nvdimm structure isn't a suitable parameter for an exported API that can be used by other drivers. Instead, use a dev structure, which should be woven into any caller using this API. This will allow for either the nvdimm's dev, or the memdev's dev to be used. Signed-off-by: Ben Widawsky <ben.widawsky@xxxxxxxxx> --- Changes since v2: - Added kdoc to cxl_find_nvdimm_bridge() --- drivers/cxl/core/pmem.c | 12 +++++++++--- drivers/cxl/cxl.h | 2 +- drivers/cxl/pmem.c | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/cxl/core/pmem.c b/drivers/cxl/core/pmem.c index 8de240c4d96b..7e431667ade1 100644 --- a/drivers/cxl/core/pmem.c +++ b/drivers/cxl/core/pmem.c @@ -62,10 +62,16 @@ static int match_nvdimm_bridge(struct device *dev, void *data) return is_cxl_nvdimm_bridge(dev); } -struct cxl_nvdimm_bridge *cxl_find_nvdimm_bridge(struct cxl_nvdimm *cxl_nvd) +/** + * cxl_find_nvdimm_bridge() - Find an nvdimm bridge for a given device + * @dev: The device to find a bridge for. This device must be in the part of the + * CXL topology which is being bridged. + * + * Return: bridge device that hosts cxl_nvdimm objects if found, else NULL. + */ +struct cxl_nvdimm_bridge *cxl_find_nvdimm_bridge(struct device *dev) { - struct cxl_port *port = find_cxl_root(&cxl_nvd->dev); - struct device *dev; + struct cxl_port *port = find_cxl_root(dev); if (!port) return NULL; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index f9dab312ed26..062654204eca 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -479,7 +479,7 @@ struct cxl_nvdimm *to_cxl_nvdimm(struct device *dev); bool is_cxl_nvdimm(struct device *dev); bool is_cxl_nvdimm_bridge(struct device *dev); int devm_cxl_add_nvdimm(struct device *host, struct cxl_memdev *cxlmd); -struct cxl_nvdimm_bridge *cxl_find_nvdimm_bridge(struct cxl_nvdimm *cxl_nvd); +struct cxl_nvdimm_bridge *cxl_find_nvdimm_bridge(struct device *dev); /* * Unit test builds overrides this to __weak, find the 'strong' version diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c index 15ad666ab03e..fabdb0c6dbf2 100644 --- a/drivers/cxl/pmem.c +++ b/drivers/cxl/pmem.c @@ -39,7 +39,7 @@ static int cxl_nvdimm_probe(struct device *dev) struct nvdimm *nvdimm; int rc; - cxl_nvb = cxl_find_nvdimm_bridge(cxl_nvd); + cxl_nvb = cxl_find_nvdimm_bridge(&cxl_nvd->dev); if (!cxl_nvb) return -ENXIO; -- 2.35.0