From patchwork Mon Feb 1 08:19:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 8176711 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0C6729F3CD for ; Mon, 1 Feb 2016 08:21:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 20EAE2042B for ; Mon, 1 Feb 2016 08:21:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1064D2041D for ; Mon, 1 Feb 2016 08:21:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQ9in-0002MD-Nm; Mon, 01 Feb 2016 08:20:29 +0000 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQ9ii-00015z-Bk for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2016 08:20:25 +0000 Received: by mail-pf0-x22e.google.com with SMTP id x125so80089414pfb.0 for ; Mon, 01 Feb 2016 00:20:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f733EETAzF8qfBJJSjhFbEY8DPyinVAzvIQ7/GZG+0w=; b=BiW9NXEGiLhPu7S1UCHTMG0WiTzzOqGGr13p6YjjVybAYA/zC0fwu/1+dOPbowR+cR D4utrwcvs4ZTak5zb/qo4L0sC6TFR0xHudAfwN4Z1jW2/60A8z7hY7O9gMHHslJHstaN 3YMWC9ocXAz+54ONLdLEW0zMhYy/WeOWMtkiw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f733EETAzF8qfBJJSjhFbEY8DPyinVAzvIQ7/GZG+0w=; b=S84LjI2oOLSbJD8hytnYs8iOaIhLfo89FTeY9B68ht04s3ASe/tasqQH1aoMlvUF/m VOw7D6tDb+wD0Clk/OJTuE5UF8P4YFHrE35+v42v6g9e+uOshwK3ArIADDFWfKfHd+8e 5BrNGZYSkehbcc3fiLEELU1S5fa8vOk1sQ4fOPA42FLMHr+e5BSVD175NWwy2TWosQJU tpVyT13LfaA9dVOfBNAo6eugUSyPSOnZUbDVqti1B10UIa8dDMnbIgTszrJdO/D8nK5C VA6CTM+Z6gEfay++EnZampfb0mrYXLJOEr3D4dvAL0EA8yX6uZwvZ7qBOrgnB51lwyp0 7mtA== X-Gm-Message-State: AG10YOSr/9HVpb8wjjSnc7wr3lseZf84Wln3eCqBSsPWPASdd5m79NpXg+sW46b3fcMvijsh X-Received: by 10.98.67.135 with SMTP id l7mr36456873pfi.148.1454314803718; Mon, 01 Feb 2016 00:20:03 -0800 (PST) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id 68sm40980126pfa.78.2016.02.01.00.19.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Feb 2016 00:20:02 -0800 (PST) From: Chunyan Zhang To: mathieu.poirier@linaro.org, alexander.shishkin@linux.intel.com Subject: [PATCH 2/6] stm class: adds a loop to extract the first valid STM device name Date: Mon, 1 Feb 2016 16:19:47 +0800 Message-Id: <1454314787-9199-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454313529-8860-3-git-send-email-zhang.chunyan@linaro.org> References: <1454313529-8860-3-git-send-email-zhang.chunyan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160201_002024_685497_46AC8278 X-CRM114-Status: GOOD ( 14.23 ) X-Spam-Score: -1.4 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, corbet@lwn.net, zhang.lyra@gmail.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, broonie@kernel.org, linux-api@vger.kernel.org, pratikp@codeaurora.org, nicolas.guion@st.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 ., where * is the name of an existing stm device and - * is an arbitrary string + * is an arbitrary string, when an arbitrary + * number of dot(s) are found in the , 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) {