]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cxl: Refactor to use __free() for cxl_root allocation in cxl_find_nvdimm_bridge()
authorDave Jiang <dave.jiang@intel.com>
Fri, 5 Jan 2024 22:07:53 +0000 (15:07 -0700)
committerDan Williams <dan.j.williams@intel.com>
Fri, 5 Jan 2024 22:36:29 +0000 (14:36 -0800)
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>
drivers/cxl/core/pmem.c

index da92a901b9e8c26ca0e26240869546335d636fe6..e69625a8d6a1d7229b7be924d7b005f4e7f1f67a 100644 (file)
@@ -64,16 +64,14 @@ static int match_nvdimm_bridge(struct device *dev, void *data)
 
 struct cxl_nvdimm_bridge *cxl_find_nvdimm_bridge(struct cxl_memdev *cxlmd)
 {
-       struct cxl_root *cxl_root = find_cxl_root(cxlmd->endpoint);
-       struct cxl_port *port;
+       struct cxl_root *cxl_root __free(put_cxl_root) =
+               find_cxl_root(cxlmd->endpoint);
        struct device *dev;
 
        if (!cxl_root)
                return NULL;
 
-       port = &cxl_root->port;
-       dev = device_find_child(&port->dev, NULL, match_nvdimm_bridge);
-       put_device(&port->dev);
+       dev = device_find_child(&cxl_root->port.dev, NULL, match_nvdimm_bridge);
 
        if (!dev)
                return NULL;