From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Li Ming <ming4.li@intel.com>
Cc: <dave@stgolabs.net>, <dave.jiang@intel.com>,
<alison.schofield@intel.com>, <vishal.l.verma@intel.com>,
<ira.weiny@intel.com>, <dan.j.williams@intel.com>,
<linux-cxl@vger.kernel.org>
Subject: Re: [PATCH v2 3/3] cxl/port: Refactor __devm_cxl_add_port() to drop goto pattern
Date: Tue, 27 Aug 2024 13:05:54 +0100 [thread overview]
Message-ID: <20240827130554.000049b3@Huawei.com> (raw)
In-Reply-To: <20240826083058.1509232-3-ming4.li@intel.com>
On Mon, 26 Aug 2024 08:30:58 +0000
Li Ming <ming4.li@intel.com> wrote:
> The "goto error" pattern is not recommended, it can be removed via
> refactoring.
I'd avoid this first comment. Goto error is fine, but not when
it is not used for all error paths after the first one where it's
relevant (which is what is happening here)
> In __devm_cxl_add_port(), there is a 'goto' to call
> put_device() for the error cases between device_initialize() and
> device_add() to dereference the 'struct device' of a new cxl_port.
> The refactoring is introducing a new function called cxl_port_add()
> which is used to add the 'struct device' of a new cxl_port to
> device hierarchy, moving the functions needing the help of above
> 'goto' into cxl_port_add(), and using a scope-based resource management
> __free() to drop the open coded put_device() and 'goto' for the error
> cases.
>
> Suggested-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Li Ming <ming4.li@intel.com>
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Nice.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huwaei.com>
next prev parent reply other threads:[~2024-08-27 12:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 8:30 [PATCH v2 1/3] cxl/port: Use __free() to drop put_device() for cxl_port Li Ming
2024-08-26 8:30 ` [PATCH v2 2/3] cxl/port: Use scoped_guard()/guard() to drop device_lock() " Li Ming
2024-08-27 11:55 ` Jonathan Cameron
2024-08-26 8:30 ` [PATCH v2 3/3] cxl/port: Refactor __devm_cxl_add_port() to drop goto pattern Li Ming
2024-08-27 12:05 ` Jonathan Cameron [this message]
2024-08-28 1:33 ` Li, Ming4
2024-08-27 11:48 ` [PATCH v2 1/3] cxl/port: Use __free() to drop put_device() for cxl_port Jonathan Cameron
2024-08-28 1:27 ` Li, Ming4
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=20240827130554.000049b3@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=ming4.li@intel.com \
--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