From: Leo Yan <leo.yan@arm.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@linaro.org>,
James Clark <james.clark@linaro.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Mao Jinlong <quic_jinlmao@quicinc.com>,
coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: Leo Yan <leo.yan@arm.com>
Subject: [PATCH v1 5/5] coresight: Refine error handling for device registration
Date: Mon, 12 May 2025 16:41:08 +0100 [thread overview]
Message-ID: <20250512154108.23920-6-leo.yan@arm.com> (raw)
In-Reply-To: <20250512154108.23920-1-leo.yan@arm.com>
When error happens in a device registration, the coresight_unregister()
function is invoked for cleanup. coresight_unregister() includes the
complete flow for unregisteration a CoreSight device, it causes
redundant operations for some errors.
This commit changes to invoke more specific functions for cleanup
resources for each error. This can allow the cleanup flow in better
granularity.
As a result, the local "registered" variable is not used anymore, remove
it.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
drivers/hwtracing/coresight/coresight-core.c | 26 ++++++++------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index 4fc82206b326..1eb4f6f0fe40 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -1297,7 +1297,6 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
{
int ret;
struct coresight_device *csdev;
- bool registered = false;
csdev = kzalloc(sizeof(*csdev), GFP_KERNEL);
if (!csdev) {
@@ -1362,27 +1361,23 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) {
ret = etm_perf_add_symlink_sink(csdev);
- if (ret) {
- device_unregister(&csdev->dev);
+ if (ret)
/*
* As with the above, all resources are free'd
* explicitly via coresight_device_release() triggered
* from put_device(), which is in turn called from
* function device_unregister().
*/
- goto out_unlock;
- }
+ goto out_unregister_device;
}
- /* Device is now registered */
- registered = true;
ret = coresight_create_conns_sysfs_group(csdev);
if (ret)
- goto out_unlock;
+ goto out_del_symlink_sink;
ret = coresight_fixup_orphan_conns(csdev);
if (ret)
- goto out_unlock;
+ goto out_remove_conns;
mutex_unlock(&coresight_mutex);
@@ -1390,15 +1385,14 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
cti_assoc_ops->add(csdev);
return csdev;
+out_remove_conns:
+ coresight_remove_conns_sysfs_group(csdev);
+out_del_symlink_sink:
+ etm_perf_del_symlink_sink(csdev);
+out_unregister_device:
+ device_unregister(&csdev->dev);
out_unlock:
mutex_unlock(&coresight_mutex);
-
- /* Unregister the device if needed */
- if (registered) {
- coresight_unregister(csdev);
- return ERR_PTR(ret);
- }
-
err_out:
/* Cleanup the connection information */
coresight_release_platform_data(NULL, csdev->dev.parent, desc->pdata);
--
2.34.1
next prev parent reply other threads:[~2025-05-12 15:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 15:41 [PATCH v1 0/5] coresight: Fix device registration and unregistration Leo Yan
2025-05-12 15:41 ` [PATCH v1 1/5] coresight: Correct sink ID map allocation failure handling Leo Yan
2025-05-12 15:41 ` [PATCH v1 2/5] coresight: Protect unregistration with mutex Leo Yan
2025-05-12 15:41 ` [PATCH v1 3/5] coresight: Explicitly use the parent device handler Leo Yan
2025-09-11 8:52 ` Suzuki K Poulose
2025-09-11 9:21 ` Leo Yan
2025-05-12 15:41 ` [PATCH v1 4/5] coresight: Separate failure and success flows Leo Yan
2025-09-11 10:03 ` Suzuki K Poulose
2025-05-12 15:41 ` Leo Yan [this message]
2025-09-11 10:20 ` [PATCH v1 5/5] coresight: Refine error handling for device registration Suzuki K Poulose
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=20250512154108.23920-6-leo.yan@arm.com \
--to=leo.yan@arm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=coresight@lists.linaro.org \
--cc=james.clark@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.leach@linaro.org \
--cc=quic_jinlmao@quicinc.com \
--cc=suzuki.poulose@arm.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