From patchwork Tue Feb 28 15:06:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 94630 Delivered-To: patch@linaro.org Received: by 10.140.20.113 with SMTP id 104csp1362094qgi; Tue, 28 Feb 2017 07:09:11 -0800 (PST) X-Received: by 10.99.122.71 with SMTP id j7mr3106180pgn.52.1488294551332; Tue, 28 Feb 2017 07:09:11 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a91si2007213pld.245.2017.02.28.07.09.11; Tue, 28 Feb 2017 07:09:11 -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 S1751986AbdB1PJJ (ORCPT + 7 others); Tue, 28 Feb 2017 10:09:09 -0500 Received: from mail-pg0-f45.google.com ([74.125.83.45]:34494 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751507AbdB1PJI (ORCPT ); Tue, 28 Feb 2017 10:09:08 -0500 Received: by mail-pg0-f45.google.com with SMTP id p5so6194770pga.1 for ; Tue, 28 Feb 2017 07:08:09 -0800 (PST) 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=/oF6k4xAOGxl6YX+AVR2szNvAgCg7QI0Rj1zJDeITOk=; b=YFGPgA3SnioC7XOjoER5GLnxYCyC6rrfVwZzsUc6AtTaPrdsueesAET/+pkvt0A79P Bk6WgSBBi5vF+1bzoh7k3A8iO21apJhE1b1pTsQ3fOGwEyTEmYfPizgYVZ0Ho7yQAR1E ioAu28QvypEUrxVRLUryr2h1B541hRhA8/rAo= 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=/oF6k4xAOGxl6YX+AVR2szNvAgCg7QI0Rj1zJDeITOk=; b=XTEa/qn0V6oTwn74Bs4i+dcb1mPhwTGt1rVcTsTGoc/yyIo+B5mu4RIakoNuIB7eI4 oIQYcss0b9avo9/9OPguCF5hOJXWMy+gSnwwkjzO43gClf56UXjUZD/XZAIvHsCgghxo 73DDy7iRkG+NMRjjeT4yYYvjaKtHULy8EsKoVf1cRCEF0cEgIBgTIOIi7mKAcl3pzj1X srjAuvkFUQZoZ0SM25/lrMJTM+aPs4p5LlATY4a6sXjstQBG2PS7BPQXcKo3fStkdexZ UshPjtqiUoGe+yeLgGNSa127eE9huMg0k31TxHpX/4WxPXtmxo/rA55bZiUDQIEtiQuF iJHA== X-Gm-Message-State: AMke39kk6chdTTCUcyuFb5AGkZGVKKsvfGMRjOnT2OoNic7ekz/bINdn5VZ9kS3KzQEC1rQD X-Received: by 10.99.111.8 with SMTP id k8mr1959298pgc.29.1488294488582; Tue, 28 Feb 2017 07:08:08 -0800 (PST) Received: from localhost.localdomain ([103.192.224.50]) by smtp.gmail.com with ESMTPSA id c64sm4926145pfa.45.2017.02.28.07.08.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Feb 2017 07:08:07 -0800 (PST) From: Leo Yan To: Rob Herring , Mark Rutland , Mathieu Poirier , Leo Yan , Greg Kroah-Hartman , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org Subject: [PATCH v2 2/3] coresight: refactor with function of_coresight_get_cpu Date: Tue, 28 Feb 2017 23:06:59 +0800 Message-Id: <1488294420-14188-3-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488294420-14188-1-git-send-email-leo.yan@linaro.org> References: <1488294420-14188-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 | 35 ++++++++++++++++++++---------- include/linux/coresight.h | 2 ++ 2 files changed, 25 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..2e7bbe2 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -101,14 +101,34 @@ 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)) + break; + } + of_node_put(dn); + + return cpu; +} +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; - struct device_node *dn; struct device_node *ep = NULL; struct device_node *rparent = NULL; struct device_node *rport = NULL; @@ -175,16 +195,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..6709561 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -263,11 +263,13 @@ 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 struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, struct device_node *node) { return NULL; } +static int of_coresight_get_cpu(struct device_node *node) { return 0; } #endif #ifdef CONFIG_PID_NS