From patchwork Thu Feb 4 08:56:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 8214941 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 076479F4DD for ; Thu, 4 Feb 2016 08:58:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 238D1201BC for ; Thu, 4 Feb 2016 08:58:49 +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 5B0F720138 for ; Thu, 4 Feb 2016 08:58:48 +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 1aRFio-0001BA-7Y; Thu, 04 Feb 2016 08:57:02 +0000 Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aRFil-00017p-LU for linux-arm-kernel@lists.infradead.org; Thu, 04 Feb 2016 08:57:00 +0000 Received: by mail-pf0-x233.google.com with SMTP id o185so38171478pfb.1 for ; Thu, 04 Feb 2016 00:56:38 -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=NFbhtnROu3+v+EkotqyvuPRCg2x8u+aCMguB1oYTuIA=; b=TnAMjKmKIZHSJdzfyqa1Eb5bG+JNKNxxz6lzuFz9NoEeBbWflegATeO4RbD5n/3o/N jJ4EshrmhI/vm3Y+CWHhG7GKs+9OdJcL7zcYDuvj4Arzv0ggIG7tGIgqOUqf0jXrXHSg hITkbEL7ueKd1jaM67CkvNJbX9VgSAHcDned4= 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=NFbhtnROu3+v+EkotqyvuPRCg2x8u+aCMguB1oYTuIA=; b=LR48k+6S/otteAoaNfoPfY87BjTF8H67SQOVoa2HHZcaE5QX/VFQMIwyP7pjbbNCPq fqH8hFZ70xobFYc+FjP6U7dzSpmhFHfrdjzu2QvQDHWphJkP8oJ1686/vuEyPfkrQxlv zz3xcie3RSUkGPBrvHXGrAMLGEOP8s8NFaCZiTbC5i/4B3VdOJ1K1P19AiXFYzj2UgD/ hmBNHKXGbKUP+XGOFkaHLKwmd/3pL+6ds/L2cU2qn1aHxblaofXJ5c6OIL5eksCnrurf Q8kKnHc0tlbgbxdkWEQjzQ30emWhS+56QE+q1wE44oDZWyB9whTVScxZxRqdRRE1UQe+ n88w== X-Gm-Message-State: AG10YOSi7vNx555a5qScvo0uMd476n+14lMm+1CKsvFuTuaOHAnDoc7n8XLfVXp0me9w4F8d X-Received: by 10.66.121.194 with SMTP id lm2mr9281518pab.27.1454576198455; Thu, 04 Feb 2016 00:56:38 -0800 (PST) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id 195sm12435673pfa.5.2016.02.04.00.56.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Feb 2016 00:56:37 -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: Thu, 4 Feb 2016 16:56:19 +0800 Message-Id: <1454576179-27224-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454487337-30184-3-git-send-email-zhang.chunyan@linaro.org> References: <1454487337-30184-3-git-send-email-zhang.chunyan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160204_005659_779117_6E4E0AFC X-CRM114-Status: GOOD ( 14.25 ) 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) {