From patchwork Wed Feb 3 08:15:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 8199101 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 4E1459F37A for ; Wed, 3 Feb 2016 08:18:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CE0812025B for ; Wed, 3 Feb 2016 08:18:20 +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 0196C20204 for ; Wed, 3 Feb 2016 08:18:20 +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 1aQscO-0006h0-KX; Wed, 03 Feb 2016 08:16:52 +0000 Received: from mail-pa0-x230.google.com ([2607:f8b0:400e:c03::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQscK-0006Vx-UQ for linux-arm-kernel@lists.infradead.org; Wed, 03 Feb 2016 08:16:49 +0000 Received: by mail-pa0-x230.google.com with SMTP id ho8so9635522pac.2 for ; Wed, 03 Feb 2016 00:16:28 -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=eUEOEzK3tl2cTpnZfnArvgp4bJkzwxKuco8ycYEAquHpjg4lJr+dWd6IbGFE5qfInr BY103UHwrgTwdewuaSeRJW17ta+BpzFxBH2qlUVXGUqqa3FScxLJty86e+SRDZXuf/aW a50EN7CnSz07BEo7v856ihvG+qTKOHUmqympI= 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=lDMj3MIz2DRRqyUWy8rDUuMavyIVmpq2M0Gj9ODROsr0piSyJ7SPoPwB71jaRB7lER IaVrAaI51LnmkkAws1pF47lajECkPmEbzlnqdAYrXpLUN29CAhp8YB9oY9qU6ionZSTT bI+5MvstZC2VcTeVnyDc+1DX2NRHpVK8/3KdIa0JSn0Q2sYuXNVlTB6AepO3Y0X1TnsV Xbn1kWqk1qywuJoazc4fR/BMfL9x/cFiYGgfNdIz92GKd0HqfBPTn0yLOENgF1RqIm9Q vw3mm9biaBlOQt1o4PNlaPW37IeIMHAGBEjk7dLyeRiW1wU9QjXsprGNCtbZV0wRqrSx CVbA== X-Gm-Message-State: AG10YOTQzp1A8K/6PxnKWK85RJrJ8bHWAR0GzLDQhj/7vyqE8u7alX3nmxDN888qJzb6J8X3 X-Received: by 10.66.122.97 with SMTP id lr1mr322772pab.68.1454487388056; Wed, 03 Feb 2016 00:16:28 -0800 (PST) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id tp6sm7725820pab.25.2016.02.03.00.16.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Feb 2016 00:16:27 -0800 (PST) From: Chunyan Zhang To: mathieu.poirier@linaro.org, alexander.shishkin@linux.intel.com Subject: [PATCH V2 2/6] stm class: adds a loop to extract the first valid STM device name Date: Wed, 3 Feb 2016 16:15:33 +0800 Message-Id: <1454487337-30184-3-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454487337-30184-1-git-send-email-zhang.chunyan@linaro.org> References: <1454487337-30184-1-git-send-email-zhang.chunyan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160203_001649_056748_C008A79C X-CRM114-Status: GOOD ( 14.89 ) X-Spam-Score: -2.7 (--) 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, al.grant@arm.com, corbet@lwn.net, zhang.lyra@gmail.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, tor@ti.com, broonie@kernel.org, mike.leach@arm.com, 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=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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) {