From patchwork Thu Jul 27 15:10:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 9867107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9C4CF60382 for ; Thu, 27 Jul 2017 15:12:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CFE328758 for ; Thu, 27 Jul 2017 15:12:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81B6E28769; Thu, 27 Jul 2017 15:12:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 063A728758 for ; Thu, 27 Jul 2017 15:12:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Z7+0QxxPLTQ5ZohGS3wbnVX3wRLvSWdgtrvjHK8kpnc=; b=dUWksAodAie6/dXZQlQGrrSQA7 2BD2ufJN/rxCeE0qz2MIAxk7EV0npQDJX4Pk5XbIOtvHvdIL8B7+1Maj01icbAZgIyXHqVDp60NFb v7S6P7n7lP7zK1vjxDsYTphLT2WIgPT/TnTwHA/m2wnVW/HQTaEQZkmFDmNuw3O5HdsefU3yq/2BV s8fgkrqou9gI8oKnnngj+b5AEVPn3OuWiuxZnjWDa+LqeEx/Q3Jb4g2kqAyJMgAUDGpSZTvHRbCcK 11cwDXzi+aSMGQpNrUqmKWlGr4TfJ53yP2rNeG7o9tLUXRsKPonYBJi/CJVyE9meZwVsMdpG4YO5U gGmRye0A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dakSl-0001jN-Ol; Thu, 27 Jul 2017 15:12:31 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dakRR-0000d1-No for linux-arm-kernel@lists.infradead.org; Thu, 27 Jul 2017 15:11:13 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1162415BE; Thu, 27 Jul 2017 08:10:50 -0700 (PDT) Received: from e107814-lin.cambridge.arm.com (e107814-lin.cambridge.arm.com [10.1.206.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 684B23F577; Thu, 27 Jul 2017 08:10:48 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170727_081110_176095_40244BA6 X-CRM114-Status: UNSURE ( 9.61 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, mathieu.poirier@linaro.org, Suzuki K Poulose , marc.zyngier@arm.com, Jonathan.Cameron@huawei.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, sudeep.holla@arm.com, Leo Yan MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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);