From patchwork Mon Apr 25 10:25:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 66569 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp954429qge; Mon, 25 Apr 2016 03:25:49 -0700 (PDT) X-Received: by 10.66.27.164 with SMTP id u4mr46905359pag.112.1461579949180; Mon, 25 Apr 2016 03:25:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fi4si6240510pad.96.2016.04.25.03.25.48; Mon, 25 Apr 2016 03:25:49 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754262AbcDYKZr (ORCPT + 29 others); Mon, 25 Apr 2016 06:25:47 -0400 Received: from mail.kernel.org ([198.145.29.136]:37397 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752299AbcDYKZq (ORCPT ); Mon, 25 Apr 2016 06:25:46 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5981320173; Mon, 25 Apr 2016 10:25:45 +0000 (UTC) Received: from [10.0.0.5] (107.238.189.80.dyn.plus.net [80.189.238.107]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CA52520155; Mon, 25 Apr 2016 10:25:42 +0000 (UTC) Date: Mon, 25 Apr 2016 11:25:11 +0100 (BST) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-X260 To: linux-arm-kernel@lists.infradead.org cc: sstabellini@kernel.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, shannon.zhao@linaro.org, linux-kernel@vger.kernel.org, peter.huangpeng@huawei.com Subject: [PATCH] make dt_scan_depth1_nodes more readable Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland Improve the readability of dt_scan_depth1_nodes by removing the nested conditionals. Signed-off-by: Mark Rutland Signed-off-by: Stefano Stabellini --- Note: this patch is based on xentip/for-linus-4.7 diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 57ee317..6884c76 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -66,17 +66,24 @@ static int __init dt_scan_depth1_nodes(unsigned long node, void *data) { /* - * Return 1 as soon as we encounter a node at depth 1 that is - * not the /chosen node, or /hypervisor node with compatible - * string "xen,xen". + * Ignore anything not directly under the root node; we'll + * catch its parent instead. */ - if (depth == 1 && (strcmp(uname, "chosen") != 0)) { - if (strcmp(uname, "hypervisor") != 0 || - !of_flat_dt_is_compatible(node, "xen,xen")) - return 1; - } + if (depth != 1) + return 0; - return 0; + if (strcmp(uname, "chosen") == 0) + return 0; + + if (strcmp(uname, "hypervisor") == 0 && + of_flat_dt_is_compatible(node, "xen,xen")) + return 0; + + /* + * This node at depth 1 is neither a chosen node nor a xen node, + * which we do not expect. + */ + return 1; } /*