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: 61058 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp152404lbl; Wed, 3 Feb 2016 00:16:33 -0800 (PST) X-Received: by 10.98.86.139 with SMTP id h11mr278444pfj.105.1454487393731; Wed, 03 Feb 2016 00:16:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v16si7753393pfa.129.2016.02.03.00.16.33; Wed, 03 Feb 2016 00:16:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756777AbcBCIQb (ORCPT + 30 others); Wed, 3 Feb 2016 03:16:31 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:34395 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755965AbcBCIQ2 (ORCPT ); Wed, 3 Feb 2016 03:16:28 -0500 Received: by mail-pa0-f48.google.com with SMTP id uo6so9843790pac.1 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=Bek2ojsInmo0g9DNFBNy+mXneU12R1fTB14Jrr4FsaHPMOtNI7E0AXnOK1Sc0fw0Zy 8qQyCDrVOuHi4pFq4hiEPWrMZTTsJjJznklcZqDerkxMgrId2q1NBCu0K/dfWDt5OUpw 85CzY6VmR4nGu1ym70E6PQvzZ4GZVQUXt/mV8GWzwaUCzQzoJD2upQbzTFOWd65tQwYP D9wAkjeFHawDuXHeqi9wLZvdoksTVgyOTRxv6QBnWpVOYSmaX+yOr/DIDApolAy/Xn0O xfZVYQjLQwPRdjaHVaGkp5MMTjEVs4747XUkxD8pqynoHORiCRtFEzkdjhKv6gQ+35X8 ob8g== X-Gm-Message-State: AG10YOQTagm1H12WFVKqX+jhiVi6/WeaCjlWb5lOOUDq8RczSk35+L7DLfPdKq2i+rU29YnY 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 Cc: robh@kernel.org, broonie@kernel.org, pratikp@codeaurora.org, nicolas.guion@st.com, corbet@lwn.net, mark.rutland@arm.com, mike.leach@arm.com, tor@ti.com, al.grant@arm.com, zhang.lyra@gmail.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- drivers/hwtracing/stm/policy.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) -- 1.9.1 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) {