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>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Mao Jinlong <quic_jinlmao@quicinc.com>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Leo Yan <leo.yan@arm.com>
Subject: [PATCH v2 5/8] coresight: Refactor sysfs connection group cleanup
Date: Mon, 26 Jan 2026 13:52:05 +0000 [thread overview]
Message-ID: <20260126-arm_coresight_refactor_dev_register-v2-5-b5a3c0441c15@arm.com> (raw)
In-Reply-To: <20260126-arm_coresight_refactor_dev_register-v2-0-b5a3c0441c15@arm.com>
Move the sysfs connection group cleanup into coresight_remove_conns(),
so that the driver removes connections and related sysfs resources in
one go.
As side effect, the csdev argument to coresight_release_platform_data()
is no longer needed; adjust the code for this.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
drivers/hwtracing/coresight/coresight-core.c | 11 +++++------
drivers/hwtracing/coresight/coresight-platform.c | 2 +-
drivers/hwtracing/coresight/coresight-priv.h | 3 +--
3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index b4b87b3e0a608a1df19d81ba796d4db7d01290f5..74fdaf3f445d139b493c2d3041884550931291b3 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -1197,6 +1197,8 @@ static void coresight_remove_conns(struct coresight_device *csdev)
coresight_remove_links(conn->src_dev, conn);
conn->dest_dev = NULL;
}
+
+ coresight_remove_conns_sysfs_group(csdev);
}
/**
@@ -1297,8 +1299,7 @@ void coresight_write64(struct coresight_device *csdev, u64 val, u32 offset)
* coresight_release_platform_data: Release references to the devices connected
* to the output port of this device.
*/
-void coresight_release_platform_data(struct coresight_device *csdev,
- struct device *dev,
+void coresight_release_platform_data(struct device *dev,
struct coresight_platform_data *pdata)
{
int i;
@@ -1316,8 +1317,6 @@ void coresight_release_platform_data(struct coresight_device *csdev,
devm_kfree(dev, pdata->out_conns);
devm_kfree(dev, pdata->in_conns);
devm_kfree(dev, pdata);
- if (csdev)
- coresight_remove_conns_sysfs_group(csdev);
}
struct coresight_device *coresight_register(struct coresight_desc *desc)
@@ -1420,7 +1419,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
}
err_out:
- coresight_release_platform_data(NULL, desc->dev, desc->pdata);
+ coresight_release_platform_data(desc->dev, desc->pdata);
return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(coresight_register);
@@ -1435,7 +1434,7 @@ void coresight_unregister(struct coresight_device *csdev)
etm_perf_del_symlink_sink(csdev);
coresight_remove_conns(csdev);
coresight_clear_default_sink(csdev);
- coresight_release_platform_data(csdev, csdev->dev.parent, csdev->pdata);
+ coresight_release_platform_data(csdev->dev.parent, csdev->pdata);
device_unregister(&csdev->dev);
mutex_unlock(&coresight_mutex);
}
diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
index 0db64c5f499592e1985141161b4f90fa1f0410b4..0ca3bd762454350d33b5630244d0cfe638ee03fb 100644
--- a/drivers/hwtracing/coresight/coresight-platform.c
+++ b/drivers/hwtracing/coresight/coresight-platform.c
@@ -849,7 +849,7 @@ coresight_get_platform_data(struct device *dev)
error:
if (!IS_ERR_OR_NULL(pdata))
/* Cleanup the connection information */
- coresight_release_platform_data(NULL, dev, pdata);
+ coresight_release_platform_data(dev, pdata);
return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(coresight_get_platform_data);
diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h
index fd896ac07942ec0a4c7acff9f32421352c1efef2..1ea882dffd703b2873e41b4ce0c2564d2ce9bbad 100644
--- a/drivers/hwtracing/coresight/coresight-priv.h
+++ b/drivers/hwtracing/coresight/coresight-priv.h
@@ -239,8 +239,7 @@ static inline void *coresight_get_uci_data_from_amba(const struct amba_id *table
return NULL;
}
-void coresight_release_platform_data(struct coresight_device *csdev,
- struct device *dev,
+void coresight_release_platform_data(struct device *dev,
struct coresight_platform_data *pdata);
struct coresight_device *
coresight_find_csdev_by_fwnode(struct fwnode_handle *r_fwnode);
--
2.34.1
next prev parent reply other threads:[~2026-01-26 13:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-26 13:52 [PATCH v2 0/8] coresight: Fix device registration and unregistration Leo Yan
2026-01-26 13:52 ` [PATCH v2 1/8] coresight: Fix memory leak in coresight_alloc_device_name() Leo Yan
2026-01-26 15:48 ` Suzuki K Poulose
2026-01-26 16:18 ` Leo Yan
2026-01-26 13:52 ` [PATCH v2 2/8] coresight: Get parent device reference after sink ID map allocation Leo Yan
2026-01-26 13:52 ` [PATCH v2 3/8] coresight: Protect unregistration with mutex Leo Yan
2026-01-26 13:52 ` [PATCH v2 4/8] coresight: Refactor output connection sysfs link cleanup Leo Yan
2026-01-26 13:52 ` Leo Yan [this message]
2026-01-26 13:52 ` [PATCH v2 6/8] coresight: Move sink validation into etm_perf_add_symlink_sink() Leo Yan
2026-01-26 13:52 ` [PATCH v2 7/8] coresight: Do not mix success path with failure handling Leo Yan
2026-01-26 13:52 ` [PATCH v2 8/8] coresight: Unify error handling in coresight_register() Leo Yan
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=20260126-arm_coresight_refactor_dev_register-v2-5-b5a3c0441c15@arm.com \
--to=leo.yan@arm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=coresight@lists.linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=james.clark@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.poirier@linaro.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
all inboxes | Powered by JetHome®