From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751875AbdG0PMA (ORCPT ); Thu, 27 Jul 2017 11:12:00 -0400 Received: from foss.arm.com ([217.140.101.70]:48096 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751645AbdG0PKu (ORCPT ); Thu, 27 Jul 2017 11:10:50 -0400 From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, will.deacon@arm.com, marc.zyngier@arm.com, mark.rutland@arm.com, sudeep.holla@arm.com, mathieu.poirier@linaro.org, Jonathan.Cameron@huawei.com, Suzuki K Poulose , Leo Yan Subject: [PATCH v3 3/6] coresight: of: Use of_device_node_get_cpu helper Date: Thu, 27 Jul 2017 16:10:15 +0100 Message-Id: <1501168218-26741-4-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1501168218-26741-1-git-send-email-suzuki.poulose@arm.com> References: <1501168218-26741-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reuse the new generic helper, of_device_node_get_cpu() to map a given CPU phandle to a logical CPU number. Cc: Leo Yan Acked-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/of_coresight.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index a187941..42ce9f8 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -104,26 +105,17 @@ static int of_coresight_alloc_memory(struct device *dev, int of_coresight_get_cpu(const struct device_node *node) { int cpu; - bool found; - struct device_node *dn, *np; + struct device_node *dn; 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); - + cpu = of_device_node_get_cpu(dn); /* Affinity to CPU0 if no cpu nodes are found */ - return found ? cpu : 0; + if (cpu >= nr_cpu_ids) + return 0; + return cpu; } EXPORT_SYMBOL_GPL(of_coresight_get_cpu); -- 2.7.5