Skip to content

Commit 321dd36

Browse files
davejiangdjbw
authored andcommitted
cxl: Refactor to use __free() for cxl_root allocation in cxl_endpoint_port_probe()
Use scope-based resource management __free() macro to drop the open coded put_device() in cxl_endpoint_port_probe(). Reviewed-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/170449247973.3779673.15088722836135359275.stgit@djiang5-mobl3 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 66f1189 commit 321dd36

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/cxl/port.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ static int cxl_endpoint_port_probe(struct cxl_port *port)
9494
struct cxl_endpoint_dvsec_info info = { .port = port };
9595
struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport_dev);
9696
struct cxl_dev_state *cxlds = cxlmd->cxlds;
97-
struct cxl_root *cxl_root;
9897
struct cxl_hdm *cxlhdm;
9998
struct cxl_port *root;
10099
int rc;
@@ -131,15 +130,15 @@ static int cxl_endpoint_port_probe(struct cxl_port *port)
131130
* This can't fail in practice as CXL root exit unregisters all
132131
* descendant ports and that in turn synchronizes with cxl_port_probe()
133132
*/
134-
cxl_root = find_cxl_root(port);
133+
struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port);
134+
135135
root = &cxl_root->port;
136136

137137
/*
138138
* Now that all endpoint decoders are successfully enumerated, try to
139139
* assemble regions from committed decoders
140140
*/
141141
device_for_each_child(&port->dev, root, discover_region);
142-
put_device(&root->dev);
143142

144143
return 0;
145144
}

0 commit comments

Comments
 (0)