@@ -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;
}
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(-)