From patchwork Wed Oct 30 11:49:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep KarkadaNagesha X-Patchwork-Id: 3114431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 50C519F43F for ; Wed, 30 Oct 2013 11:49:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B74C20145 for ; Wed, 30 Oct 2013 11:49:32 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7431620155 for ; Wed, 30 Oct 2013 11:49:27 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VbUH3-000598-Aa; Wed, 30 Oct 2013 11:49:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VbUH0-0000Rb-Tn; Wed, 30 Oct 2013 11:49:18 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VbUGx-0000QR-Jr for linux-arm-kernel@lists.infradead.org; Wed, 30 Oct 2013 11:49:16 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 30 Oct 2013 11:48:52 +0000 Received: from [10.1.207.23] ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 30 Oct 2013 11:48:51 +0000 Message-ID: <5270F238.6010602@arm.com> Date: Wed, 30 Oct 2013 11:49:12 +0000 From: Sudeep KarkadaNagesha User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Wei Yongjun , "robherring2@gmail.com" Subject: Re: [PATCH -next v2] arm64: use for_each_node_by_type() macro References: <52709A9E.8060800@gmail.com> In-Reply-To: X-OriginalArrivalTime: 30 Oct 2013 11:48:51.0788 (UTC) FILETIME=[00D850C0:01CED566] X-MC-Unique: 113103011485201901 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131030_074915_849688_0B869152 X-CRM114-Status: GOOD ( 14.48 ) X-Spam-Score: -2.6 (--) Cc: Mark Rutland , Catalin Marinas , Will Deacon , "rob.herring@calxeda.com" , "yongjun_wei@trendmicro.com.cn" , "grant.likely@linaro.org" , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 30/10/13 05:54, Wei Yongjun wrote: > From: Wei Yongjun > > Use for_each_node_by_type() macro instead of open coding it. > > Signed-off-by: Wei Yongjun > --- > v1 -> v2: remove extra space > --- > arch/arm64/kernel/cpu_ops.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c > index aa0c9e7..37a4977 100644 > --- a/arch/arm64/kernel/cpu_ops.c > +++ b/arch/arm64/kernel/cpu_ops.c > @@ -78,10 +78,10 @@ int __init cpu_read_ops(struct device_node *dn, int cpu) > > void __init cpu_read_bootcpu_ops(void) > { > - struct device_node *dn = NULL; > + struct device_node *dn; > u64 mpidr = cpu_logical_map(0); > > - while ((dn = of_find_node_by_type(dn, "cpu"))) { > + for_each_node_by_type(dn, "cpu") { > u64 hwid; > const __be32 *prop; > In fact this function can be simplified by making use of OF helper directly, something like below snippet. But it requires [1] for correct functionality. Regards, Sudeep [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2013-October/206401.html -->8 diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c index de78d22..f297a18 100644 --- a/arch/arm64/kernel/cpu_ops.c +++ b/arch/arm64/kernel/cpu_ops.c @@ -73,22 +73,10 @@ int __init cpu_read_ops(struct device_node *dn, int cpu) void __init cpu_read_bootcpu_ops(void) { - struct device_node *dn = NULL; - u64 mpidr = cpu_logical_map(0); - - while ((dn = of_find_node_by_type(dn, "cpu"))) { - u64 hwid; - const __be32 *prop; - - prop = of_get_property(dn, "reg", NULL); - if (!prop) - continue; - - hwid = of_read_number(prop, of_n_addr_cells(dn)); - if (hwid == mpidr) { - cpu_read_ops(dn, 0); - of_node_put(dn); - return; - } + struct device_node *dn = of_get_cpu_node(0, NULL); + if (!dn) { + pr_err("failed to find device node for boot cpu\n"); + return; } + cpu_read_ops(dn, 0); }