Skip to content

Commit 29990ab

Browse files
Gregory Pricedavejiang
authored andcommitted
cxl/core: use cleanup.h for devm_cxl_add_dax_region
Cleanup the gotos in the function. No functional change. Signed-off-by: Gregory Price <gourry@gourry.net> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Link: https://patch.msgid.link/20260327020203.876122-4-gourry@gourry.net Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent d747cf9 commit 29990ab

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

drivers/cxl/core/region_dax.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,26 @@ static void cxlr_dax_unregister(void *_cxlr_dax)
8181

8282
int devm_cxl_add_dax_region(struct cxl_region *cxlr)
8383
{
84-
struct cxl_dax_region *cxlr_dax;
8584
struct device *dev;
8685
int rc;
8786

88-
cxlr_dax = cxl_dax_region_alloc(cxlr);
87+
struct cxl_dax_region *cxlr_dax __free(put_cxl_dax_region) =
88+
cxl_dax_region_alloc(cxlr);
8989
if (IS_ERR(cxlr_dax))
9090
return PTR_ERR(cxlr_dax);
9191

9292
dev = &cxlr_dax->dev;
9393
rc = dev_set_name(dev, "dax_region%d", cxlr->id);
9494
if (rc)
95-
goto err;
95+
return rc;
9696

9797
rc = device_add(dev);
9898
if (rc)
99-
goto err;
99+
return rc;
100100

101101
dev_dbg(&cxlr->dev, "%s: register %s\n", dev_name(dev->parent),
102102
dev_name(dev));
103103

104104
return devm_add_action_or_reset(&cxlr->dev, cxlr_dax_unregister,
105-
cxlr_dax);
106-
err:
107-
put_device(dev);
108-
return rc;
105+
no_free_ptr(cxlr_dax));
109106
}

drivers/cxl/cxl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ DEFINE_FREE(put_cxl_root, struct cxl_root *, if (_T) put_device(&_T->port.dev))
808808
DEFINE_FREE(put_cxl_port, struct cxl_port *, if (!IS_ERR_OR_NULL(_T)) put_device(&_T->dev))
809809
DEFINE_FREE(put_cxl_root_decoder, struct cxl_root_decoder *, if (!IS_ERR_OR_NULL(_T)) put_device(&_T->cxlsd.cxld.dev))
810810
DEFINE_FREE(put_cxl_region, struct cxl_region *, if (!IS_ERR_OR_NULL(_T)) put_device(&_T->dev))
811+
DEFINE_FREE(put_cxl_dax_region, struct cxl_dax_region *, if (!IS_ERR_OR_NULL(_T)) put_device(&_T->dev))
811812

812813
int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd);
813814
void cxl_bus_rescan(void);

0 commit comments

Comments
 (0)