From patchwork Thu Apr 6 13:30:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 96974 Delivered-To: patch@linaro.org Received: by 10.182.246.10 with SMTP id xs10csp733150obc; Thu, 6 Apr 2017 06:32:46 -0700 (PDT) X-Received: by 10.99.171.5 with SMTP id p5mr36966124pgf.208.1491485566860; Thu, 06 Apr 2017 06:32:46 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y127si1892000pgy.49.2017.04.06.06.32.46; Thu, 06 Apr 2017 06:32:46 -0700 (PDT) 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 S934632AbdDFNco (ORCPT + 7 others); Thu, 6 Apr 2017 09:32:44 -0400 Received: from mail-pg0-f44.google.com ([74.125.83.44]:34811 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934818AbdDFNck (ORCPT ); Thu, 6 Apr 2017 09:32:40 -0400 Received: by mail-pg0-f44.google.com with SMTP id 21so36664389pgg.1 for ; Thu, 06 Apr 2017 06:32:40 -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=2kt28QdepAfE78Y2GrWBtywn9xT4klQ/93D4FHlh/zY=; b=T85/78xfVVTKZoApzMy1I4tyjIKak4QZ3iPljRdRR2cKVOwdi9q2QN/LJYmZLWhqKv qQ7TJ7TD//tOI2FfVsiYCFM9JICEt4lCFc1Q4T1WceGv+h7lkBUPo7oqJTbWHXpCwKeB VTAdjFojlbwb7b+yM5Gnm92GaWthGRDETJryQ= 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=2kt28QdepAfE78Y2GrWBtywn9xT4klQ/93D4FHlh/zY=; b=fPZwrD6fCmxSWggQHDRVVmkGKfu22xvoJONQ05V1icypfqoWyXP2+59Ms00v3BFYyr BMvW2IAu7nKts8YpfwP6++N/e8MC4kWAJlSx+CFR5u8ZnhH/rCeOH0ghD6W2QfFCKS8+ ouy7ibSjqjKgAQGhvTbMa1yaNHaMImIctVQOE9lWDLJKiDyBf740fj4wdwd6CdJqJadv gQlLzUd/dPR9eQiBACw5cboxzw0CSqdxAX3dtb+d5syHTh94ycqfY+YxAtkDiEZPqE++ iG2aJ1N7nc0EDRWmMVYPJbWA+jZMG/cksh5Bk7cATNWze2CxJhwf9b9SzS6+p9ogOvh6 rsJg== X-Gm-Message-State: AFeK/H34OXU/jlUDBmF0tgzcUeaWlNvPti8XhuuHxV1H9GSCLSPWTMdVNDfq9cmFuO3AhYSC X-Received: by 10.99.110.6 with SMTP id j6mr36932280pgc.64.1491485553570; Thu, 06 Apr 2017 06:32:33 -0700 (PDT) Received: from localhost.localdomain (li1627-128.members.linode.com. [172.104.47.128]) by smtp.gmail.com with ESMTPSA id 129sm4074223pgj.59.2017.04.06.06.32.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Apr 2017 06:32:32 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Rob Herring , Mark Rutland , Wei Xu , Catalin Marinas , Will Deacon , Andy Gross , David Brown , Mathieu Poirier , Suzuki K Poulose , Stephen Boyd , 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, Mike Leach , Sudeep Holla Cc: Leo Yan Subject: [PATCH v6 4/8] coresight: refactor with function of_coresight_get_cpu Date: Thu, 6 Apr 2017 21:30:57 +0800 Message-Id: <1491485461-22800-5-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491485461-22800-1-git-send-email-leo.yan@linaro.org> References: <1491485461-22800-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 Reviewed-by: Suzuki K Poulose 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 -- 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 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