Message ID | 170441751181.3632067.5542037427417510907.stgit@djiang5-mobl3 |
---|---|
State | New, archived |
Headers | show |
Series | find_cxl_root() related cleanups | expand |
Dave Jiang wrote: > Use scope-based resource management __free() macro to make cxl_root > allocation safer in cxl_find_nvdimm_bridge(). I would say it is perfectly safe as is, but the benefit here is dropping the open coded put_device(). I think the local @port variable can go too. Fixed that up.
diff --git a/drivers/cxl/core/pmem.c b/drivers/cxl/core/pmem.c index 57b777a088f6..df3d11257511 100644 --- a/drivers/cxl/core/pmem.c +++ b/drivers/cxl/core/pmem.c @@ -64,7 +64,8 @@ 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_root *cxl_root __free(put_cxl_root) = + find_cxl_root(cxlmd->endpoint); struct cxl_port *port; struct device *dev; @@ -73,7 +74,6 @@ struct cxl_nvdimm_bridge *cxl_find_nvdimm_bridge(struct cxl_memdev *cxlmd) port = &cxl_root->port; dev = device_find_child(&port->dev, NULL, match_nvdimm_bridge); - put_cxl_root(cxl_root); if (!dev) return NULL;
Use scope-based resource management __free() macro to make cxl_root allocation safer in cxl_find_nvdimm_bridge(). Signed-off-by: Dave Jiang <dave.jiang@intel.com> --- drivers/cxl/core/pmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)