diff mbox series

[v5,5/5] cxl: Refactor to use __free() for cxl_root allocation in cxl_endpoint_port_probe()

Message ID 170447780994.3687480.10026614511779346820.stgit@djiang5-mobl3
State Superseded
Headers show
Series cxl: find_cxl_root() related cleanups | expand

Commit Message

Dave Jiang Jan. 5, 2024, 6:03 p.m. UTC
Use scope-based resource management __free() macro to drop the open coded
put_device() in cxl_endpoint_port_probe().

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
v5:
- Update commit log (Dan)
v4:
- Don't check return value of find_cxl_root() per comment. (Dan)
---
 drivers/cxl/port.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c
index ddbb42f0fd70..89d303f048e7 100644
--- a/drivers/cxl/port.c
+++ b/drivers/cxl/port.c
@@ -95,7 +95,6 @@  static int cxl_endpoint_port_probe(struct cxl_port *port)
 	struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport_dev);
 	struct cxl_dev_state *cxlds = cxlmd->cxlds;
 	struct cxl_hdm *cxlhdm;
-	struct cxl_root *cxl_root;
 	struct cxl_port *root_port;
 	int rc;
 
@@ -131,7 +130,8 @@  static int cxl_endpoint_port_probe(struct cxl_port *port)
 	 * This can't fail in practice as CXL root exit unregisters all
 	 * descendant ports and that in turn synchronizes with cxl_port_probe()
 	 */
-	cxl_root = find_cxl_root(port);
+	struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port);
+
 	root_port = &cxl_root->port;
 
 	/*
@@ -139,7 +139,6 @@  static int cxl_endpoint_port_probe(struct cxl_port *port)
 	 * assemble regions from committed decoders
 	 */
 	device_for_each_child(&root_port->dev, root_port, discover_region);
-	put_cxl_root(cxl_root);
 
 	return 0;
 }