@@ -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_cxl_root(cxl_root);
+ dev = device_find_child(&cxl_root->port.dev, NULL, match_nvdimm_bridge);
if (!dev)
return NULL;
Use scope-based resource management __free() macro to drop the open coded put_device() in cxl_find_nvdimm_bridge(). Signed-off-by: Dave Jiang <dave.jiang@intel.com> --- v5 - Update commit log (Dan) --- drivers/cxl/core/pmem.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)