Skip to content

Commit 66f1189

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

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

drivers/cxl/core/pmem.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,14 @@ static int match_nvdimm_bridge(struct device *dev, void *data)
6464

6565
struct cxl_nvdimm_bridge *cxl_find_nvdimm_bridge(struct cxl_memdev *cxlmd)
6666
{
67-
struct cxl_root *cxl_root = find_cxl_root(cxlmd->endpoint);
68-
struct cxl_port *port;
67+
struct cxl_root *cxl_root __free(put_cxl_root) =
68+
find_cxl_root(cxlmd->endpoint);
6969
struct device *dev;
7070

7171
if (!cxl_root)
7272
return NULL;
7373

74-
port = &cxl_root->port;
75-
dev = device_find_child(&port->dev, NULL, match_nvdimm_bridge);
76-
put_device(&port->dev);
74+
dev = device_find_child(&cxl_root->port.dev, NULL, match_nvdimm_bridge);
7775

7876
if (!dev)
7977
return NULL;

0 commit comments

Comments
 (0)