mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] coresight: core: Add coresight name support
@ 2023-02-08 11:07 Mao Jinlong
  2023-02-08 14:26 ` Suzuki K Poulose
  0 siblings, 1 reply; 8+ messages in thread
From: Mao Jinlong @ 2023-02-08 11:07 UTC (permalink / raw)
  To: Mathieu Poirier, Suzuki K Poulose, Mike Leach, Leo Yan,
	Alexander Shishkin
  Cc: Mao Jinlong, coresight, linux-arm-kernel, linux-kernel,
	linux-arm-msm, Tingwei Zhang, Yuanfang Zhang, Tao Zhang,
	Hao Zhang

Apart from STM and ETM sources, there will be more sources added to
coresight components. For example, there are over 10 TPDM sources.
Add coresight name support for custom names which will be
easy to identify the source.

Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
---
 drivers/hwtracing/coresight/coresight-core.c | 34 +++++++++++---------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index d3bf82c0de1d..5e95d9c7f256 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -1733,28 +1733,32 @@ char *coresight_alloc_device_name(struct coresight_dev_list *dict,
 {
 	int idx;
 	char *name = NULL;
+	const char *coresight_name = NULL;
 	struct fwnode_handle **list;
+	struct device_node *node = dev->of_node;
 
 	mutex_lock(&coresight_mutex);
 
-	idx = coresight_search_device_idx(dict, dev_fwnode(dev));
-	if (idx < 0) {
-		/* Make space for the new entry */
-		idx = dict->nr_idx;
-		list = krealloc_array(dict->fwnode_list,
-				      idx + 1, sizeof(*dict->fwnode_list),
-				      GFP_KERNEL);
-		if (ZERO_OR_NULL_PTR(list)) {
-			idx = -ENOMEM;
-			goto done;
+	if (!of_property_read_string(node, "coresight-name", &coresight_name))
+		name = devm_kasprintf(dev, GFP_KERNEL, "%s", coresight_name);
+	else {
+		idx = coresight_search_device_idx(dict, dev_fwnode(dev));
+		if (idx < 0) {
+			/* Make space for the new entry */
+			idx = dict->nr_idx;
+			list = krealloc_array(dict->fwnode_list,
+					      idx + 1, sizeof(*dict->fwnode_list),
+					      GFP_KERNEL);
+			if (ZERO_OR_NULL_PTR(list))
+				goto done;
+
+			list[idx] = dev_fwnode(dev);
+			dict->fwnode_list = list;
+			dict->nr_idx = idx + 1;
 		}
 
-		list[idx] = dev_fwnode(dev);
-		dict->fwnode_list = list;
-		dict->nr_idx = idx + 1;
+		name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
 	}
-
-	name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
 done:
 	mutex_unlock(&coresight_mutex);
 	return name;
-- 
2.39.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-04-24 22:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-08 11:07 [PATCH] coresight: core: Add coresight name support Mao Jinlong
2023-02-08 14:26 ` Suzuki K Poulose
2023-02-09  2:16   ` Jinlong Mao
2023-03-01 15:11     ` Jinlong Mao
2023-03-13  9:16       ` Suzuki K Poulose
     [not found]         ` <6b976d2b-3c78-96e4-bf35-3ef88828a9dd@quicinc.com>
2023-03-17 14:25           ` Suzuki K Poulose
2023-04-24 13:42             ` Jinlong Mao
2023-04-24 22:26               ` Suzuki K Poulose

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®