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: 61163 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp334261lbl; Thu, 4 Feb 2016 00:56:43 -0800 (PST) X-Received: by 10.98.70.211 with SMTP id o80mr9191001pfi.124.1454576202983; Thu, 04 Feb 2016 00:56:42 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tg6si15440189pab.0.2016.02.04.00.56.42; Thu, 04 Feb 2016 00:56:42 -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 S1755797AbcBDI4l (ORCPT + 30 others); Thu, 4 Feb 2016 03:56:41 -0500 Received: from mail-pf0-f178.google.com ([209.85.192.178]:33806 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755622AbcBDI4i (ORCPT ); Thu, 4 Feb 2016 03:56:38 -0500 Received: by mail-pf0-f178.google.com with SMTP id o185so38171477pfb.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=VBCxAtBtIHoFkWEZvcVQGGaLQ15e/8i+waJlJ5WOLPFeyG00rP707QwUVcHbitt6NY P9GzfP9FE4d9R+DdYpiBmGh7rvnwIStoc8EdVjEMCj7UWnboqKoNY12AsmQS0xvaA8e3 1w7fLRgR55AxRv2B4ubL8VhtZuyVG7dskMiXLg5NyLmuel0rWoyEwYBZH2NAByeOEq57 8ectd0+IiqqkAD3xcVCzoQKuW2DCF7ZzK18Ta9X+cAslI7SI8iqHHqrIAKaMY5CR1LXX 53jHMBML2SmGRKTuDzXMNWuQxEUOYT063YvSK7VJP+XtdbUDGjpi7aHaGZX9q3RCkK+0 huMA== X-Gm-Message-State: AG10YOQpl701g2Kxs3HCcYS/IxBSlasuW+GcfaPzimYRqLcX1hXaUI/UMEOcnacpW83GBK5N 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 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: 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> 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) {