From patchwork Wed May 24 00:02:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 100401 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp34853qge; Tue, 23 May 2017 17:04:40 -0700 (PDT) X-Received: by 10.99.102.134 with SMTP id a128mr34798664pgc.42.1495584279947; Tue, 23 May 2017 17:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495584279; cv=none; d=google.com; s=arc-20160816; b=JBqvykIQhCLz1w57VTuawRoEMrAs1rYXh+tPogxs5kTlX60ZjWjA1QPcGqX/LoXtvM AzX4zfzgsqRKfNDMt6N7msR91WFmApHRdzsoOrvraDGsAJtGaqCUJfA+46Kb+V/iIoYw rMzIRpOmsj9rcts8yxVcXs72XCyI5vHcdxq7GOxhsAxF3MfNwHr6IxgVPbR+sGc8Sa59 wM+7FqK//5FHMozg7yeHpja/Yaf7Qm2X/QxgkoTwD7J8xn1MlgE7wV7GokkSdQi8e5Kg r1ibHao+cqGRmA5oyfuPkmv0h1VQm+r4fTRRyeLwoeO32Zzlzqg//LnUnkEq9AqDhODy c/Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=pQBhgBdAWMz2W1N5baOSR/Y3fVkFD+KZqlylO+zf+fU=; b=NBPbO4Ylym1a96SlWLFxyNfrGf3972tLzEi5L5TSEw+pZC3XbYdLiO4Mot4MU3YlkP FKzKEaPIkcc9ckX8wuSOHt++2oUeTBy5WE3wDmzrMHaQVpDb6KMghSCvmb9rYiWZ3GrS mbRlzloPfDaX6dS7GbEfAzvFQxzRPUQmrLcNS5JlppQtu/QONlpRq8vdKb3mUgTvuOdy VZZ1l4Qnlc5kY9sB2lTOfbyTkX+CYXv+8x1m/hoU5shwyclciXDMVGXiocLj3NYW+jy5 3LLS7dQJQG0B8BMQWUFI/xVLYkc/+xpwzkEbV4uvGpMTFP2S1p2UlOvDZLpGqB8yx+EY 7pDg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p24si23127929pli.172.2017.05.23.17.04.39; Tue, 23 May 2017 17:04:39 -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 S1035034AbdEXAEc (ORCPT + 10 others); Tue, 23 May 2017 20:04:32 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:35081 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034580AbdEXAD4 (ORCPT ); Tue, 23 May 2017 20:03:56 -0400 Received: by mail-pf0-f179.google.com with SMTP id n23so129169286pfb.2 for ; Tue, 23 May 2017 17:03:56 -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=AUa/r/owcEkLREAOhERJKHIL8sY1rKzDXiQd4uezk7o=; b=R7n9BHR48gEX16v4wTjRmrR3CY7JVkvi/5pYkwBss9sWlbSY9FWapc9nW9k76iu4Wk CUl6PCAoJiCUy/YrUqOKhhl+3joB2Yaot3oioFsxEBhfiJZtyLUPsGMGfmF/KHWQr2uf RScXfGpvNEDyfJH0m6miNq5wc5FE/DXdAj/bg= 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=AUa/r/owcEkLREAOhERJKHIL8sY1rKzDXiQd4uezk7o=; b=uSdf3GC98yJriVAMqAxurIVHT2bGHVProRPcskwWQWzxmvmsvHRbSyzcXxljXrfLmO LixVkJZafPFwSoDqf1IloYnr9xEmY6d/sz5fa037yaZsozHzAVtO6uRf/rz1ZlmBd01S sSK8cRUgneVgTZ7/y7EMCVZr64c0tcuOxU/J11400dPMGnvM1UFVq+hR3OGqkMFOpsNB 0NsxZzghq3F86IHiDLz0C+4eQZzQsQNeRX/0cjnctccf2xWxXoWL7mspssgxeNCaNxii zRerb19mN3psZRryHtT4w29VRT1hPaXb2yaDI3qv/A60ekCJbO2eqHHyqaKb8fABRYJG WPaQ== X-Gm-Message-State: AODbwcA2ZkVXDjj1GjyFG+qGg5MbGckVxAm2RLwXTJdRd3ZcY1h98Ywa eljvlvVnfhanx4re X-Received: by 10.99.115.14 with SMTP id o14mr34503764pgc.31.1495584235418; Tue, 23 May 2017 17:03:55 -0700 (PDT) Received: from localhost.localdomain (li1068-205.members.linode.com. [106.184.3.205]) by smtp.gmail.com with ESMTPSA id l186sm3613987pgd.42.2017.05.23.17.03.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 May 2017 17:03:53 -0700 (PDT) From: Leo Yan To: Jonathan Corbet , Mathieu Poirier , Rob Herring , Mark Rutland , Liviu Dudau , Wei Xu , Catalin Marinas , Will Deacon , Andy Gross , David Brown , Greg Kroah-Hartman , Suzuki K Poulose , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Stephen Boyd , Mike Leach Cc: Leo Yan Subject: [PATCH v12 6/9] coresight: refactor with function of_coresight_get_cpu Date: Wed, 24 May 2017 08:02:54 +0800 Message-Id: <1495584177-32193-7-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495584177-32193-1-git-send-email-leo.yan@linaro.org> References: <1495584177-32193-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 Reviewed-by: Suzuki K Poulose Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/of_coresight.c | 43 +++++++++++++++++++----------- include/linux/coresight.h | 3 +++ 2 files changed, 31 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 225b2dd..a187941 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -101,16 +101,40 @@ static int of_coresight_alloc_memory(struct device *dev, return 0; } +int of_coresight_get_cpu(const 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, const 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; @@ -177,18 +201,7 @@ of_get_coresight_platform_data(struct device *dev, } 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 bf0aa50..d950dad 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -263,10 +263,13 @@ static inline int coresight_timeout(void __iomem *addr, u32 offset, #endif #ifdef CONFIG_OF +extern int of_coresight_get_cpu(const struct device_node *node); extern struct coresight_platform_data * of_get_coresight_platform_data(struct device *dev, const struct device_node *node); #else +static inline int of_coresight_get_cpu(const struct device_node *node) +{ return 0; } static inline struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, const struct device_node *node) { return NULL; } #endif