@@ -62,16 +62,21 @@ static int match_nvdimm_bridge(struct device *dev, void *data)
6262 return is_cxl_nvdimm_bridge (dev );
6363}
6464
65- struct cxl_nvdimm_bridge * cxl_find_nvdimm_bridge (struct cxl_memdev * cxlmd )
65+ /**
66+ * cxl_find_nvdimm_bridge() - find a bridge device relative to a port
67+ * @port: any descendant port of an nvdimm-bridge associated
68+ * root-cxl-port
69+ */
70+ struct cxl_nvdimm_bridge * cxl_find_nvdimm_bridge (struct cxl_port * port )
6671{
67- struct cxl_port * port = find_cxl_root (cxlmd -> endpoint );
72+ struct cxl_port * root_port = find_cxl_root (port );
6873 struct device * dev ;
6974
70- if (!port )
75+ if (!root_port )
7176 return NULL ;
7277
73- dev = device_find_child (& port -> dev , NULL , match_nvdimm_bridge );
74- put_device (& port -> dev );
78+ dev = device_find_child (& root_port -> dev , NULL , match_nvdimm_bridge );
79+ put_device (& root_port -> dev );
7580
7681 if (!dev )
7782 return NULL ;
@@ -242,18 +247,20 @@ static void cxlmd_release_nvdimm(void *_cxlmd)
242247
243248/**
244249 * devm_cxl_add_nvdimm() - add a bridge between a cxl_memdev and an nvdimm
250+ * @parent_port: parent port for the (to be added) @cxlmd endpoint port
245251 * @cxlmd: cxl_memdev instance that will perform LIBNVDIMM operations
246252 *
247253 * Return: 0 on success negative error code on failure.
248254 */
249- int devm_cxl_add_nvdimm (struct cxl_memdev * cxlmd )
255+ int devm_cxl_add_nvdimm (struct cxl_port * parent_port ,
256+ struct cxl_memdev * cxlmd )
250257{
251258 struct cxl_nvdimm_bridge * cxl_nvb ;
252259 struct cxl_nvdimm * cxl_nvd ;
253260 struct device * dev ;
254261 int rc ;
255262
256- cxl_nvb = cxl_find_nvdimm_bridge (cxlmd );
263+ cxl_nvb = cxl_find_nvdimm_bridge (parent_port );
257264 if (!cxl_nvb )
258265 return - ENODEV ;
259266
0 commit comments