From patchwork Fri May 19 04:25:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 100151 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp141221qge; Thu, 18 May 2017 21:27:38 -0700 (PDT) X-Received: by 10.98.192.80 with SMTP id x77mr8353701pff.1.1495168058532; Thu, 18 May 2017 21:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495168058; cv=none; d=google.com; s=arc-20160816; b=zxSWiEO0C6T1hSGiCUYTA7sUBIbMDJj5Gu3PlB9H1UQvsrgmeXzFogyW/lVZxTWl+x qu9spt7TIflhUEGbg67twwNaNNhmIFsDWUKqgJM2UoKTy/VnBcXROoToMELx/dE9fxDA dnDbToqek9aSc00B9EK9w/8bGSRbGGvFhODAUHpwaqe2Uc4X4fnfc7q63frNuawVYbzR R1E6AgkyTPQeoTkqP+Y0SpmudxdX8Y7w2ck/yndD0hnq9OWUCUKoo+512U9sIJK41TaP dT5tAkStJsA6UEW//2Ca2seurbx0pH8G+UcjrGfaz5+Rdi4tbMNlE755pkYh6g+SIb6t TTfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=pQBhgBdAWMz2W1N5baOSR/Y3fVkFD+KZqlylO+zf+fU=; b=eXI8YXl2N0tkTu0wNMKaMIBB2eOWu9zd0N8J7cJXockcUlKScMSweI8Q7EVjhmiqmG 2ACN4iC35hrMJkRvEhtHqYl5XMCNgdDRunBACe1Ks1/4vdfJew8H0+iu48I1roczfaUe lhaT44o9PY3CtfCej9eK/dtodepvYK3oMNwBarNM/LafQkQ29+C8g6HaIN770kMnuhOQ SvL1AT77MkqOTESv6CNcAPl60zRur+jWzXgD+AkEt+T4liHES8NqCjaQTl4V+RsJJ10E LIfeNrs/BafEwpt5TCFWfWmKrBXKLmgdIfsgTpiJk5A9cS3e82qYfbpHp65jFMdriua0 SYjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q22si7089126pgc.268.2017.05.18.21.27.38; Thu, 18 May 2017 21:27:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755033AbdESE1a (ORCPT + 10 others); Fri, 19 May 2017 00:27:30 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:35784 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755015AbdESE12 (ORCPT ); Fri, 19 May 2017 00:27:28 -0400 Received: by mail-pg0-f43.google.com with SMTP id q125so32324815pgq.2 for ; Thu, 18 May 2017 21:27:27 -0700 (PDT) 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=AUa/r/owcEkLREAOhERJKHIL8sY1rKzDXiQd4uezk7o=; b=SSPh+zCW3PP8rwQjQx8KC/xv+COW81PDzn5EtEUjVQY6+BD763oZJNXKNcMKQhLN8b j9a4PYuU76FF5XMH+QNNIpUh0h0fJUZuxcKOTesHWfNQL+Wa5++R1l/1/RQWZ6yHkr4r 63+AG6VV5/Mcr+/tFamwSX2xwfUb5IBJVGoeg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AUa/r/owcEkLREAOhERJKHIL8sY1rKzDXiQd4uezk7o=; b=sLpEt4jxtFf/X2YcksXxFb+EIZ6fSXsgT6Hf0M5SHlyXsA0f9OqTDMyr46/NRD0v7g uy4/IZ/zOgb/3tSiUO5SVnXhCHloCpexlXt/KRvL3STwgnQ4BZW+Pfy2PkzFScMXQs3K HHLkC4zLOzjO3a2topqpoxss+D9qNq9QcL47dCeLdtnTYwYAmHYMa6b1KQ7a7v+PEl1C DPJBMqSJ3XT2Dzjo+8/Q3xbSeaKi4Ez626Vmh+A6256O7OFJZAdX1I5fSs0loc1cCUxl HbSujVPCnBWT8lhszLkpAkKz34M3h2C3CwBcHIRAewSY0WWqXP86jvIjKvKAtglw3Avp thJw== X-Gm-Message-State: AODbwcAIrGgmofWaZG0KCpoG1RLP5Ko4aCYUYy42FbYYvanzhMT0l/Vf BufNZ+CMM4y5xRiU X-Received: by 10.98.78.193 with SMTP id c184mr7963661pfb.85.1495168033233; Thu, 18 May 2017 21:27:13 -0700 (PDT) Received: from localhost.localdomain (li637-108.members.linode.com. [106.186.117.108]) by smtp.gmail.com with ESMTPSA id c29sm5823259pfj.101.2017.05.18.21.27.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 May 2017 21:27:11 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Mathieu Poirier , Rob Herring , Mark Rutland , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , Catalin Marinas , Will Deacon , Wei Xu , Andy Gross , David Brown , Greg Kroah-Hartman , Suzuki K Poulose , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Stephen Boyd , Mike Leach Cc: Leo Yan Subject: [PATCH v10 06/10] coresight: refactor with function of_coresight_get_cpu Date: Fri, 19 May 2017 12:25:53 +0800 Message-Id: <1495167957-14923-7-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495167957-14923-1-git-send-email-leo.yan@linaro.org> References: <1495167957-14923-1-git-send-email-leo.yan@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This is refactor to add function of_coresight_get_cpu(), so it's used to retrieve CPU id for coresight component. Finally can use it as a common function for multiple places. Suggested-by: Mathieu Poirier Reviewed-by: Suzuki K Poulose Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/of_coresight.c | 43 +++++++++++++++++++----------- include/linux/coresight.h | 3 +++ 2 files changed, 31 insertions(+), 15 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index 225b2dd..a187941 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -101,16 +101,40 @@ static int of_coresight_alloc_memory(struct device *dev, return 0; } +int of_coresight_get_cpu(const struct device_node *node) +{ + int cpu; + bool found; + struct device_node *dn, *np; + + dn = of_parse_phandle(node, "cpu", 0); + + /* Affinity defaults to CPU0 */ + if (!dn) + return 0; + + for_each_possible_cpu(cpu) { + np = of_cpu_device_node_get(cpu); + found = (dn == np); + of_node_put(np); + if (found) + break; + } + of_node_put(dn); + + /* Affinity to CPU0 if no cpu nodes are found */ + return found ? cpu : 0; +} +EXPORT_SYMBOL_GPL(of_coresight_get_cpu); + struct coresight_platform_data * of_get_coresight_platform_data(struct device *dev, const struct device_node *node) { - int i = 0, ret = 0, cpu; + int i = 0, ret = 0; struct coresight_platform_data *pdata; struct of_endpoint endpoint, rendpoint; struct device *rdev; - bool found; - struct device_node *dn, *np; struct device_node *ep = NULL; struct device_node *rparent = NULL; struct device_node *rport = NULL; @@ -177,18 +201,7 @@ of_get_coresight_platform_data(struct device *dev, } while (ep); } - dn = of_parse_phandle(node, "cpu", 0); - for_each_possible_cpu(cpu) { - np = of_cpu_device_node_get(cpu); - found = (dn == np); - of_node_put(np); - if (found) - break; - } - of_node_put(dn); - - /* Affinity to CPU0 if no cpu nodes are found */ - pdata->cpu = found ? cpu : 0; + pdata->cpu = of_coresight_get_cpu(node); return pdata; } diff --git a/include/linux/coresight.h b/include/linux/coresight.h index bf0aa50..d950dad 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -263,10 +263,13 @@ static inline int coresight_timeout(void __iomem *addr, u32 offset, #endif #ifdef CONFIG_OF +extern int of_coresight_get_cpu(const struct device_node *node); extern struct coresight_platform_data * of_get_coresight_platform_data(struct device *dev, const struct device_node *node); #else +static inline int of_coresight_get_cpu(const struct device_node *node) +{ return 0; } static inline struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, const struct device_node *node) { return NULL; } #endif