From patchwork Thu Nov 5 12:56:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 7561381 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 52C119F36A for ; Thu, 5 Nov 2015 12:59:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5001920776 for ; Thu, 5 Nov 2015 12:59:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B13F20769 for ; Thu, 5 Nov 2015 12:59:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZuK74-0002oV-KF; Thu, 05 Nov 2015 12:57:58 +0000 Received: from szxga02-in.huawei.com ([119.145.14.65]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZuK6z-0002kH-Pp for linux-arm-kernel@lists.infradead.org; Thu, 05 Nov 2015 12:57:55 +0000 Received: from 172.24.1.47 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.1.47]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CVT65722; Thu, 05 Nov 2015 20:56:57 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.235.1; Thu, 5 Nov 2015 20:56:49 +0800 From: Shannon Zhao To: , , , Subject: [PATCH] ARM: ACPI: Fix the helper which checks if only a /chosen node Date: Thu, 5 Nov 2015 20:56:27 +0800 Message-ID: <1446728187-14552-1-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.563B521C.0023,ss=1,re=0.000,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2011-05-27 18:58:46 X-Mirapoint-Loop-Id: 559e334e282bb8e1090e8ab52247ba04 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151105_045754_295008_06470EF1 X-CRM114-Status: GOOD ( 17.28 ) X-Spam-Score: -4.2 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shannon.zhao@linaro.org 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 From: Shannon Zhao Assuming that there are several other nodes and a /chosen node in a DTS and the /chosen node is last node, of_scan_flat_dt() will return 0 while we expect it returns 1 when it's used to call a function to check if there is only a /chosen node in DTS. Fix this by passing a meaningful parameter instead of NULL to of_scan_flat_dt() to record if it finds a node that is not /chosen node. Signed-off-by: Shannon Zhao --- arch/arm64/kernel/acpi.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 19de753..51c988c 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -60,12 +60,15 @@ static int __init dt_scan_depth1_nodes(unsigned long node, const char *uname, int depth, void *data) { + bool *found = data; + /* * Return 1 as soon as we encounter a node at depth 1 that is * not the /chosen node. */ if (depth == 1 && (strcmp(uname, "chosen") != 0)) - return 1; + *found = true; + return 0; } @@ -176,15 +179,20 @@ out: */ void __init acpi_boot_table_init(void) { + bool found = false; /* * Enable ACPI instead of device tree unless * - ACPI has been disabled explicitly (acpi=off), or * - the device tree is not empty (it has more than just a /chosen node) * and ACPI has not been force enabled (acpi=force) */ - if (param_acpi_off || - (!param_acpi_force && of_scan_flat_dt(dt_scan_depth1_nodes, NULL))) + if (param_acpi_off) { return; + } else if (!param_acpi_force) { + of_scan_flat_dt(dt_scan_depth1_nodes, &found); + if (found) + return; + } /* * ACPI is disabled at this point. Enable it in order to parse