From patchwork Sat Mar 25 18:23:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 96006 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp566128qgd; Sat, 25 Mar 2017 11:27:46 -0700 (PDT) X-Received: by 10.84.232.131 with SMTP id i3mr18805052plk.172.1490466466850; Sat, 25 Mar 2017 11:27:46 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l4si4955673pfl.164.2017.03.25.11.27.46; Sat, 25 Mar 2017 11:27:46 -0700 (PDT) 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; dkim=pass header.i=@linaro.org; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751926AbdCYSZz (ORCPT + 15 others); Sat, 25 Mar 2017 14:25:55 -0400 Received: from mail-wr0-f170.google.com ([209.85.128.170]:35406 "EHLO mail-wr0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751683AbdCYSYr (ORCPT ); Sat, 25 Mar 2017 14:24:47 -0400 Received: by mail-wr0-f170.google.com with SMTP id u1so11125726wra.2 for ; Sat, 25 Mar 2017 11:24:23 -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=wl3PlqpaGP6cTS2QTW335ohHL1ZfGCD3ubSamuQzBfc=; b=BPXBleum4S4DUU0a23KHKHyK86E+b46Rkz5+mdV5vCsLMRjadZiklfsxkgOC4sebS5 c/NgpWw6jG13zVYfztagDpkpstuRcsx36IST0rUcEj8Pvcq2ljl7maFSXrE5KVZ8f5dT aZ1vw5+dyhLGti3hs6FGHmIXP3jHJD7jFzS+Q= 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=wl3PlqpaGP6cTS2QTW335ohHL1ZfGCD3ubSamuQzBfc=; b=R/5bTGrRls+b7+CYa/FI17xxYm1MvsHFOb27zYuQ5YNCt+wrJD4YpCrWIJGPuUYLo6 XsKQpTMExjaWRrPmFptQwCkpQ+agYr6bj2izVYojhaA8rkqv4G1mBKzcX2UMX1vN4Q1n 4B7VN4GNSpNDuySgR+7E72GoanJKnNSketaQNn//1PJK7u8sakTp1jm9gJ7ePHsfrY2w gAf+VlEmgH5BbUUO2X6gOCVoTSa3nWZgdhA3xIUDXQ0v48kng9pBIrgMGONxa3T302/h 1u5sOASHCZqRnN1YLAbQJ0XED3PJNgSZBCEdQzuN2znOOtSgoLs+mFVZExxb25EwBt5g Npog== X-Gm-Message-State: AFeK/H1hDencURfiXJTHjaRtiHayyisnlB6dPLT0gKKPlZV/BuLdrTCm3qmdVMGag1LdiX6i X-Received: by 10.223.171.23 with SMTP id q23mr12986847wrc.163.1490466262557; Sat, 25 Mar 2017 11:24:22 -0700 (PDT) Received: from localhost.localdomain (li1529-187.members.linode.com. [139.162.244.187]) by smtp.gmail.com with ESMTPSA id e72sm7464075wma.5.2017.03.25.11.24.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Mar 2017 11:24:21 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Rob Herring , Mark Rutland , Wei Xu , Catalin Marinas , Will Deacon , Andy Gross , David Brown , Michael Turquette , Stephen Boyd , Mathieu Poirier , Guodong Xu , John Stultz , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@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 Cc: Leo Yan Subject: [PATCH v5 4/9] coresight: refactor with function of_coresight_get_cpu Date: Sun, 26 Mar 2017 02:23:12 +0800 Message-Id: <1490466197-29163-5-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490466197-29163-1-git-send-email-leo.yan@linaro.org> References: <1490466197-29163-1-git-send-email-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 | 43 +++++++++++++++++++----------- include/linux/coresight.h | 2 ++ 2 files changed, 30 insertions(+), 15 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index 1a77280..78d2399 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -101,15 +101,39 @@ 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_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, 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 +200,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_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 2a5982c..bf96678 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 inline 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