From patchwork Fri Mar 3 06:00:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 94818 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp81149qgd; Thu, 2 Mar 2017 22:06:53 -0800 (PST) X-Received: by 10.84.194.1 with SMTP id g1mr1757053pld.98.1488521213288; Thu, 02 Mar 2017 22:06:53 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si9512589pge.420.2017.03.02.22.06.53; Thu, 02 Mar 2017 22:06:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1751384AbdCCGGw (ORCPT + 7 others); Fri, 3 Mar 2017 01:06:52 -0500 Received: from mail-pf0-f171.google.com ([209.85.192.171]:33074 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751037AbdCCGGw (ORCPT ); Fri, 3 Mar 2017 01:06:52 -0500 Received: by mail-pf0-f171.google.com with SMTP id w189so29872959pfb.0 for ; Thu, 02 Mar 2017 22:06:51 -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=nc/2JLC7y4cML24ZBenYmJ3sfbX//lYx/qUcMRwFTkc=; b=A7V98Btal3LKcRy3QPxr85N5bGTGSLu66B0sLimJykANrBhFrU8pBK/Qo2dmu3UDRD jWODj+cOr6PPaPUDJCQ8SMshWPnC1magj1QlgZzB0NHqQrR0VcAB/UXeU7tlWT3Dmt97 Al/YyUYu1+obtUKFaG2xaKHMwH1oLmFqd/XrU= 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=nc/2JLC7y4cML24ZBenYmJ3sfbX//lYx/qUcMRwFTkc=; b=nfKobcFrukODj2bb+6DAxFjacfeOb3vOz4s6egK7p19mzgFlt0mjMQpX2clQrExF0c RO/kYE3ZhZBw9Okzb6+YPTEk2u06EXtq65nZR8due40VxShoDhWBa9J5RoAUzlmSksVm qA2hCKoORArlNGIdkWbRiUOC7C7/2y5eLSqi939JA9pyJ7mEOEevrYha/yqV0ElCmTpt J5sY/79JwtXbUqXWp8X3tMrIZNrLp+dD++V5QDCogjUkhRKtKk6Hw0eS5JNthC+R7niQ /uWXs690Ve1sMb8qBNw0oE/OkDthcCguyMlk+hVQDgftPqYOr4hQoDnred8sfShezKmY KyvA== X-Gm-Message-State: AMke39nX6lIWgSLSi3wm/0ioKty4tMbTWp9ST2lUE6e53uktt1NFfDOJnmz7QdDoaWaP/a4+ X-Received: by 10.99.146.70 with SMTP id s6mr1287925pgn.109.1488520843416; Thu, 02 Mar 2017 22:00:43 -0800 (PST) Received: from localhost.localdomain (61-216-91-114.HINET-IP.hinet.net. [61.216.91.114]) by smtp.gmail.com with ESMTPSA id s13sm20541405pfk.26.2017.03.02.22.00.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Mar 2017 22:00:42 -0800 (PST) From: Leo Yan To: Rob Herring , Mark Rutland , Wei Xu , Catalin Marinas , Will Deacon , Michael Turquette , Stephen Boyd , Mathieu Poirier , John Stultz , Guodong Xu , Haojian Zhuang , Greg Kroah-Hartman , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, mike.leach@linaro.org Cc: Leo Yan Subject: [PATCH v3 2/5] coresight: refactor with function of_coresight_get_cpu Date: Fri, 3 Mar 2017 14:00:06 +0800 Message-Id: <1488520809-31670-3-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488520809-31670-1-git-send-email-leo.yan@linaro.org> References: <1488520809-31670-1-git-send-email-leo.yan@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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 | 37 ++++++++++++++++++++---------- include/linux/coresight.h | 2 ++ 2 files changed, 27 insertions(+), 12 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" 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 629e031..d9a12fb 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -101,14 +101,36 @@ static int of_coresight_alloc_memory(struct device *dev, return 0; } +int of_coresight_get_cpu(struct device_node *node) +{ + int cpu; + struct device_node *dn; + + dn = of_parse_phandle(node, "cpu", 0); + + /* Affinity defaults to CPU0 */ + if (!dn) + return 0; + + for_each_possible_cpu(cpu) { + if (dn == of_get_cpu_node(cpu, NULL)) { + of_node_put(dn); + return cpu; + } + } + + /* Affinity to CPU0 if no cpu nodes are found */ + of_node_put(dn); + return 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; - struct device_node *dn; struct device_node *ep = NULL; struct device_node *rparent = NULL; struct device_node *rport = NULL; @@ -175,16 +197,7 @@ struct coresight_platform_data *of_get_coresight_platform_data( } while (ep); } - /* Affinity defaults to CPU0 */ - pdata->cpu = 0; - dn = of_parse_phandle(node, "cpu", 0); - for (cpu = 0; dn && cpu < nr_cpu_ids; cpu++) { - if (dn == of_get_cpu_node(cpu, NULL)) { - pdata->cpu = cpu; - break; - } - } - of_node_put(dn); + 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