public inbox for linux-cxl@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Gregory Price <gourry@gourry.net>, linux-cxl@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com,
	dave@stgolabs.net, jonathan.cameron@huawei.com,
	alison.schofield@intel.com, vishal.l.verma@intel.com,
	ira.weiny@intel.com, dan.j.williams@intel.com
Subject: Re: [PATCH v3 3/3] cxl/core: use cleanup.h for devm_cxl_add_dax_region
Date: Tue, 17 Feb 2026 16:55:13 -0700	[thread overview]
Message-ID: <68d44fc4-55fe-42df-85ea-cffc60454325@intel.com> (raw)
In-Reply-To: <20260211204206.2171525-4-gourry@gourry.net>



On 2/11/26 1:42 PM, Gregory Price wrote:
> Cleanup the gotos in the function.
> 
> No functional change intended.
> 
> Signed-off-by: Gregory Price <gourry@gourry.net>
> ---
>  drivers/cxl/core/region_dax.c | 21 ++++++++-------------
>  drivers/cxl/cxl.h             |  1 +
>  2 files changed, 9 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/cxl/core/region_dax.c b/drivers/cxl/core/region_dax.c
> index c8dd2bd1d9b9..49907c6c7620 100644
> --- a/drivers/cxl/core/region_dax.c
> +++ b/drivers/cxl/core/region_dax.c
> @@ -81,29 +81,24 @@ static void cxlr_dax_unregister(void *_cxlr_dax)
>  
>  int devm_cxl_add_dax_region(struct cxl_region *cxlr)
>  {
> -	struct cxl_dax_region *cxlr_dax;
> -	struct device *dev;
> +	struct cxl_dax_region *cxlr_dax __free(put_cxl_dax_region) = NULL;
>  	int rc;
>  
>  	cxlr_dax = cxl_dax_region_alloc(cxlr);

The typical __cleanup() pattern is to move the variable declaration here in order to minimize unintended issues between declare and check.

>  	if (IS_ERR(cxlr_dax))
>  		return PTR_ERR(cxlr_dax);
>  
> -	dev = &cxlr_dax->dev;

Given that this local var is used multiple times, maybe we should keep it?

DJ

> -	rc = dev_set_name(dev, "dax_region%d", cxlr->id);
> +	rc = dev_set_name(&cxlr_dax->dev, "dax_region%d", cxlr->id);
>  	if (rc)
> -		goto err;
> +		return rc;
>  
> -	rc = device_add(dev);
> +	rc = device_add(&cxlr_dax->dev);
>  	if (rc)
> -		goto err;
> +		return rc;
>  
> -	dev_dbg(&cxlr->dev, "%s: register %s\n", dev_name(dev->parent),
> -		dev_name(dev));
> +	dev_dbg(&cxlr->dev, "%s: register %s\n", dev_name(cxlr_dax->dev.parent),
> +		dev_name(&cxlr_dax->dev));
>  
>  	return devm_add_action_or_reset(&cxlr->dev, cxlr_dax_unregister,
> -					cxlr_dax);
> -err:
> -	put_device(dev);
> -	return rc;
> +					no_free_ptr(cxlr_dax));
>  }
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index 04c673e7cdb0..0b59008ea45a 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -803,6 +803,7 @@ DEFINE_FREE(put_cxl_root, struct cxl_root *, if (_T) put_device(&_T->port.dev))
>  DEFINE_FREE(put_cxl_port, struct cxl_port *, if (!IS_ERR_OR_NULL(_T)) put_device(&_T->dev))
>  DEFINE_FREE(put_cxl_root_decoder, struct cxl_root_decoder *, if (!IS_ERR_OR_NULL(_T)) put_device(&_T->cxlsd.cxld.dev))
>  DEFINE_FREE(put_cxl_region, struct cxl_region *, if (!IS_ERR_OR_NULL(_T)) put_device(&_T->dev))
> +DEFINE_FREE(put_cxl_dax_region, struct cxl_dax_region *, if (!IS_ERR_OR_NULL(_T)) put_device(&_T->dev))
>  
>  int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd);
>  void cxl_bus_rescan(void);


  reply	other threads:[~2026-02-17 23:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-11 20:42 [PATCH v3 0/3] pull region-specific logic into new files Gregory Price
2026-02-11 20:42 ` [PATCH v3 1/3] cxl/core/region: move pmem region driver logic into region_pmem.c Gregory Price
2026-02-11 20:42 ` [PATCH v3 2/3] cxl/core/region: move dax region device logic into region_dax.c Gregory Price
2026-02-11 20:42 ` [PATCH v3 3/3] cxl/core: use cleanup.h for devm_cxl_add_dax_region Gregory Price
2026-02-17 23:55   ` Dave Jiang [this message]
2026-02-20  5:23     ` Gregory Price

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68d44fc4-55fe-42df-85ea-cffc60454325@intel.com \
    --to=dave.jiang@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave@stgolabs.net \
    --cc=gourry@gourry.net \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=kernel-team@meta.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox