Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3174207imu; Fri, 18 Jan 2019 06:08:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN6xG61IFb/lDu264CUBkyoxzkrOLguAm/S91Q+UG/LlJkYTDTAz/tMA+E64Bwtm6uX/eH3O X-Received: by 2002:a63:c748:: with SMTP id v8mr18116256pgg.108.1547820482359; Fri, 18 Jan 2019 06:08:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547820482; cv=none; d=google.com; s=arc-20160816; b=GPpc06SI0/uqeaWhFzX8rBtMDm/rl7FE1kvEEci3gWU6clM0qlFbx+JWF+dbNadc5w J0GnJwzR6qDVGOakpDIEXCMdYeAQwZwkvM8+boRsaJ5HVZdETIKlbfoWwEDRAoU+j4IU 9QrLvv/uYrmNu0epFFO7rXqIJe7xA1jHIs9DDWGkWJ8AdblbjcRKRWiuy0JOLx3jzZQ4 oeGkUk2OWVOmzPkSsm5DRQFysOoDFwnFeQzcKdkJgUmGym3CjmRas/XKtUgu27lfmj32 VCgzb4+Kn9wUl/BZKAtWCIV5RpW7QH4G31hJ45m66BOZzlIiKGhOTCIrX0F5ig8VugU2 yb/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cVF/+rdzQVmDvcOxbIn7hLVP8/m/t64C/jXS8/amg08=; b=dYZnVHeOZUq7ltpbq+0eE8FkAqy44CJvvAvwasCoSI8xtCxy4oAcelMqHGXzYChdfd AvEVJeCH7FvNWpddgALmemGTOgpB3gSYJMpuRSBcPpz/qTMUldRLhn+RZoC0ZD9KuEND 5rtkVUyrxWJ+VChPta96M3YO83raEeUTZnRgN2zyX/VB4SlVrGBxMlD4NwmQqqGujC66 fTedDFpiB54U4ODJfVvqWL780UTBaDezGr2sl1RfaN2+p5QDGKmLThJdJbaB9K0+txTk NeY40H5EdwF38L0q8e0aOpPxAVR6KBl26No0aE9qcz0swgqHzaqiLoB+FWZuuJcNbOPB WU4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y8si4566632pfn.26.2019.01.18.06.07.43; Fri, 18 Jan 2019 06:08:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727799AbfAROEp (ORCPT + 99 others); Fri, 18 Jan 2019 09:04:45 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36172 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727784AbfAROEn (ORCPT ); Fri, 18 Jan 2019 09:04:43 -0500 Received: by mail-lf1-f68.google.com with SMTP id a16so10568123lfg.3 for ; Fri, 18 Jan 2019 06:04:41 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=cVF/+rdzQVmDvcOxbIn7hLVP8/m/t64C/jXS8/amg08=; b=kib+mKN2iMt+SC3cr4MkhQp/2PL+OZRh39UXrQvIiU5NriO44p25wSb4Jp2xma70b1 GS/JeAAgxYEN0KF0NPixoaiV7yEqjwQGfjIMOtJ1edu7pUZPKW3MSXnxgBXgAy/qxxjh XDWlGrNNHepSGfaSJyApR+zN8VnobJbBs+Xz50c+xwdArQX1xsVYfcV/1HZBJcfE/i2P gQl7kKMftDC2070S+CQDsNb68bAnwAWty4NnilvB7wDwwvU/9H+AzWjVFey6nD3De8KY RxY+3dDX2mYO0B4BNMubqJW2PeFSa36C2iRBVALL3YfRmxz8AjXRJLt6Y/DsWX0FKj+R iwmw== X-Gm-Message-State: AJcUukeQd8Re/G3S9K46huPcT/4kIDICr7Th8qsAT7WcUayXNPDiXTAU wces+YeRyKpQUQlzka7gFqc= X-Received: by 2002:a19:a9d2:: with SMTP id s201mr12312768lfe.154.1547820281063; Fri, 18 Jan 2019 06:04:41 -0800 (PST) Received: from xi.terra (c-74bee655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.190.116]) by smtp.gmail.com with ESMTPSA id d10sm816549lfa.71.2019.01.18.06.04.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jan 2019 06:04:39 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1gkUlB-0002WA-Gq; Fri, 18 Jan 2019 15:04:37 +0100 From: Johan Hovold To: Palmer Dabbelt Cc: Albert Ou , Andreas Schwab , Atish Patra , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 5/5] riscv: use for_each_of_cpu_node iterator Date: Fri, 18 Jan 2019 15:03:08 +0100 Message-Id: <20190118140308.9599-6-johan@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118140308.9599-1-johan@kernel.org> References: <20190118140308.9599-1-johan@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the new for_each_of_cpu_node() helper to iterate over cpu nodes instead of open coding. Note that this will allow matching also on the node name instead of the (for FDT) deprecated device_type property. Signed-off-by: Johan Hovold --- arch/riscv/kernel/cpufeature.c | 5 +++-- arch/riscv/kernel/smpboot.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 4891fd62b95e..e7a4701f0256 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -28,7 +28,7 @@ bool has_fpu __read_mostly; void riscv_fill_hwcap(void) { - struct device_node *node = NULL; + struct device_node *node; const char *isa; size_t i; static unsigned long isa2hwcap[256] = {0}; @@ -46,9 +46,10 @@ void riscv_fill_hwcap(void) * We don't support running Linux on hertergenous ISA systems. For * now, we just check the ISA of the first "okay" processor. */ - while ((node = of_find_node_by_type(node, "cpu"))) + for_each_of_cpu_node(node) { if (riscv_of_processor_hartid(node) >= 0) break; + } if (!node) { pr_warn("Unable to find \"cpu\" devicetree entry\n"); return; diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index 18cda0e8cf94..6e2813257e03 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -50,12 +50,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus) void __init setup_smp(void) { - struct device_node *dn = NULL; + struct device_node *dn; int hart; bool found_boot_cpu = false; int cpuid = 1; - while ((dn = of_find_node_by_type(dn, "cpu"))) { + for_each_of_cpu_node(dn) { hart = riscv_of_processor_hartid(dn); if (hart < 0) continue; -- 2.20.1