From patchwork Fri Mar 17 15:02:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 95428 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp346475qgd; Fri, 17 Mar 2017 08:05:09 -0700 (PDT) X-Received: by 10.98.71.151 with SMTP id p23mr17406760pfi.252.1489763109330; Fri, 17 Mar 2017 08:05:09 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t6si8908055plj.176.2017.03.17.08.05.09; Fri, 17 Mar 2017 08:05:09 -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 S1751379AbdCQPFH (ORCPT + 9 others); Fri, 17 Mar 2017 11:05:07 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:34086 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbdCQPEX (ORCPT ); Fri, 17 Mar 2017 11:04:23 -0400 Received: by mail-pg0-f52.google.com with SMTP id 21so9759074pgg.1 for ; Fri, 17 Mar 2017 08:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=SQp9Zr8oTNvBwCWbZu4ARK2JtQi49IABG7CRRXpx2W8=; b=IpzPantuxy7nraEzPoEP4v1OMbTLCFEg+z5bkRrAwmE7w0s/R7Ye3SW0twlw9uaB3T brv6DErnIq2FdGYR/hUCnjIhHZMCt8TYRyOOQfNyqCCpyZGNPTFID9P+hsfnojW+EWbY 2Kn6NsPWZPVG6860iwaSaI4AEihene4Uvy9gs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=SQp9Zr8oTNvBwCWbZu4ARK2JtQi49IABG7CRRXpx2W8=; b=RP42xu4/RyCVCm1hHS7kG44zBCaFDMOQ8uU5W/gz/HxVfw3Yh0//0OJCEY8fUrm81/ F1gmRQvZEW98fYGXHzUvd/AOyflBALcaO2n/5fjcqbIlWGlLFFt5bxfnIVzwlYE3lET7 pUwEwmkNVbkSfJI5Z5PaDosPdwMcn8C9Aumzqtrr0KDHEycsdjTFYinu9YQ5fjJrTY7y oGny3HUoHiGaw5cplrQpYx7YrXEVpTC9O3PkBQyenupLIT3hiBssB5b3aDlw36c42KEX uirmo/Zk5Jan9QKF+hL+wmBX2za+3opffSKjfUE1IDRzAMVNFiDXQJq9HmYDRCjFukvK e0Gg== X-Gm-Message-State: AFeK/H1aX5TIezB5Us79uo+xkEKqZ6KLuqlbryBNspvp4ewyYkVTxL2+MmhcmIEfLj1IGEEC X-Received: by 10.99.151.10 with SMTP id n10mr16455522pge.199.1489763051119; Fri, 17 Mar 2017 08:04:11 -0700 (PDT) Received: from localhost.localdomain ([103.230.219.215]) by smtp.gmail.com with ESMTPSA id f125sm17482582pfc.4.2017.03.17.08.03.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Mar 2017 08:04:09 -0700 (PDT) From: Leo Yan To: Rob Herring , Mark Rutland , Wei Xu , Catalin Marinas , Will Deacon , Andy Gross , David Brown , Michael Turquette , Stephen Boyd , Mathieu Poirier , Leo Yan , Guodong Xu , John Stultz , Greg Kroah-Hartman , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-clk@vger.kernel.org, mike.leach@linaro.org, Suzuki.Poulose@arm.com, sudeep.holla@arm.com Subject: [PATCH v4 3/7] coresight: refactor with function of_coresight_get_cpu Date: Fri, 17 Mar 2017 23:02:19 +0800 Message-Id: <1489762943-25849-4-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489762943-25849-1-git-send-email-leo.yan@linaro.org> References: <1489762943-25849-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 Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/of_coresight.c | 42 +++++++++++++++++++----------- include/linux/coresight.h | 2 ++ 2 files changed, 29 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 917ca39..7a60f2b 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -101,15 +101,38 @@ static int of_coresight_alloc_memory(struct device *dev, return 0; } +int of_coresight_get_cpu(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_get_cpu_node(cpu, NULL); + 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; +} + struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, 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; @@ -176,18 +199,7 @@ struct coresight_platform_data *of_get_coresight_platform_data( } while (ep); } - dn = of_parse_phandle(node, "cpu", 0); - for_each_possible_cpu(cpu) { - np = of_get_cpu_node(cpu, NULL); - 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 2a5982c..7b29743 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -263,9 +263,11 @@ static inline int coresight_timeout(void __iomem *addr, u32 offset, #endif #ifdef CONFIG_OF +extern int of_coresight_get_cpu(struct device_node *node); extern struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, struct device_node *node); #else +static int of_coresight_get_cpu(struct device_node *node) { return 0; } static inline struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, struct device_node *node) { return NULL; } #endif