From patchwork Mon Feb 1 07:58:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 8176551 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 D28679F4DD for ; Mon, 1 Feb 2016 08:02:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 053832042C for ; Mon, 1 Feb 2016 08:02:31 +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 3901220426 for ; Mon, 1 Feb 2016 08:02:30 +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 1aQ9Pg-0000FP-6c; Mon, 01 Feb 2016 08:00:44 +0000 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQ9PL-0007iB-6l for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2016 08:00:24 +0000 Received: by mail-pf0-x231.google.com with SMTP id x125so79793664pfb.0 for ; Mon, 01 Feb 2016 00:00:02 -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=RqnaAGfEkNogTioD5IgD5pOMTevGnwGOpWSoKVMs0JrfkuSMLNEnqtsgsQpFEOLRkf ch2vqDWxOqsOaaGEg2cxJdi8Lhm0AsCPR1eFU0oWS9Oi6ffs967YQoiqVehXVxqnaTmE kR8HD3UrfQPDNDzBPLTqyuUTNNXHiZjnfQb68= 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=CQR1PZp6HuC2wWdd0+DFl2JZCKzU4EUexAea/ewxwe+noUGpi9e/nicMJwkOo3L1BI EvLQbym46JSM2bKAG2ZGzjbEuzVKjIDIkJjg/DseNxCF3AccsBeLkWUpklNVV7O6uvdt tcrYH24uPyrDo5Czp5Vx590Bd9jl3CjedQ2lkeeUaRAvVe6KIbinio0XYdhkh3WAEt6h TJOABAPdQYzwqBYk7xwm6gAlc1lXj7nkvZ9ZedNb2Ft4b71gdBuAGPVds0SwmJ5YA0AT iPimTJdZ+rqKiACmxVYUWDM+JfiC935x66wWL7x27/AZmuIx1ZtVo7XB5CjOboY/O6Wg bGqw== X-Gm-Message-State: AG10YOS5xskOR/YyWd0lsscnVpD1teIO7Tg9H4q3LLbKTYTLGY3I/7zSnYZQVxPSo4LtrhYy X-Received: by 10.98.17.208 with SMTP id 77mr35354726pfr.37.1454313602430; Mon, 01 Feb 2016 00:00:02 -0800 (PST) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id o4sm40799282pfa.85.2016.01.31.23.59.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Feb 2016 00:00:01 -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 15:58:45 +0800 Message-Id: <1454313529-8860-3-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454313529-8860-1-git-send-email-zhang.chunyan@linaro.org> References: <1454313529-8860-1-git-send-email-zhang.chunyan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160201_000023_381013_76D0DB38 X-CRM114-Status: GOOD ( 14.25 ) 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, linux-api@vger.kernel.orgi, corbet@lwn.net, zhang.lyra@gmail.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, broonie@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.6 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) {