linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: zhang.chunyan@linaro.org (Chunyan Zhang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/6] stm class: adds a loop to extract the first valid STM device name
Date: Mon,  1 Feb 2016 15:58:45 +0800	[thread overview]
Message-ID: <1454313529-8860-3-git-send-email-zhang.chunyan@linaro.org> (raw)
In-Reply-To: <1454313529-8860-1-git-send-email-zhang.chunyan@linaro.org>

The node name of STM master management policy is a concatenation of an
STM device name to which this policy applies and following an arbitrary
string, these two strings are concatenated with a dot.

This patch adds a loop for extracting the STM device name when an
arbitrary number of dot(s) are found in this STM device name.

Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
---
 drivers/hwtracing/stm/policy.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c
index 11ab6d0..691686e 100644
--- a/drivers/hwtracing/stm/policy.c
+++ b/drivers/hwtracing/stm/policy.c
@@ -321,21 +321,26 @@ stp_policies_make(struct config_group *group, const char *name)
 	/*
 	 * node must look like <device_name>.<policy_name>, where
 	 * <device_name> is the name of an existing stm device and
-	 * <policy_name> is an arbitrary string
+	 * <policy_name> is an arbitrary string, when an arbitrary
+	 * number of dot(s) are found in the <device_name>, the
+	 * first matched STM device name would be extracted.
 	 */
-	p = strchr(devname, '.');
-	if (!p) {
-		kfree(devname);
-		return ERR_PTR(-EINVAL);
-	}
+	for (p = devname; ; p++) {
+		p = strchr(p, '.');
+		if (!p) {
+			kfree(devname);
+			return ERR_PTR(-EINVAL);
+		}
 
-	*p++ = '\0';
+		*p = '\0';
 
-	stm = stm_find_device(devname);
-	kfree(devname);
+		stm = stm_find_device(devname);
+		if (stm)
+			break;
+		*p = '.';
+	};
 
-	if (!stm)
-		return ERR_PTR(-ENODEV);
+	kfree(devname);
 
 	mutex_lock(&stm->policy_mutex);
 	if (stm->policy) {
-- 
1.9.1

  parent reply	other threads:[~2016-02-01  7:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-01  7:58 [PATCH 0/6] Introduce CoreSight STM support Chunyan Zhang
2016-02-01  7:58 ` [PATCH 1/6] stm class: Add ioctl get_options interface Chunyan Zhang
2016-02-01  8:19   ` Chunyan Zhang
2016-02-01  7:58 ` Chunyan Zhang [this message]
2016-02-01  8:19   ` [PATCH 2/6] stm class: adds a loop to extract the first valid STM device name Chunyan Zhang
2016-02-01  7:58 ` [PATCH 3/6] stm class: provision for statically assigned masterIDs Chunyan Zhang
2016-02-01  8:20   ` Chunyan Zhang
2016-02-01  7:58 ` [PATCH 4/6] Documentations: Add explanations of the case for non-configurable masters Chunyan Zhang
2016-02-01  8:20   ` Chunyan Zhang
2016-02-01  7:58 ` [PATCH 5/6] coresight-stm: Bindings for System Trace Macrocell Chunyan Zhang
2016-02-01  8:20   ` Chunyan Zhang
2016-02-01  7:58 ` [PATCH 6/6] coresight-stm: adding driver for CoreSight STM component Chunyan Zhang
2016-02-01  8:21   ` Chunyan Zhang
2016-02-01 10:01   ` kbuild test robot
2016-02-01 12:44     ` Chunyan Zhang
2016-02-01 16:53       ` Mathieu Poirier
2016-02-01  8:18 ` [PATCH 0/6] Introduce CoreSight STM support Chunyan Zhang

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=1454313529-8860-3-git-send-email-zhang.chunyan@linaro.org \
    --to=zhang.chunyan@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).