From patchwork Fri Oct 17 13:36:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 5097641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E0AE6C11AC for ; Fri, 17 Oct 2014 13:42:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 238062015D for ; Fri, 17 Oct 2014 13:42:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E288200F4 for ; Fri, 17 Oct 2014 13:42:31 +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 1Xf7l3-0006j4-4t; Fri, 17 Oct 2014 13:39:53 +0000 Received: from mail-pd0-f182.google.com ([209.85.192.182]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xf7jo-00068l-Cc for linux-arm-kernel@lists.infradead.org; Fri, 17 Oct 2014 13:38:37 +0000 Received: by mail-pd0-f182.google.com with SMTP id y10so788819pdj.41 for ; Fri, 17 Oct 2014 06:38:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZRGBkL6h6CHcEsHYf8zfMbIYSEdEvZgmLScM2TY9cC8=; b=MHpehpQ3PPtqRCMF4qZLmQfEw5Zbzx5RNRCyoC8i6Ufc/cn/1GinWc1CuRpNCSQnio GZHthzn7Q1HJJ1z5ObazcP2aLKtSGLcqikE4bCTj8Ouf62+ug2DqRdiaXWlPrf2tzFPp +3ri8v/8Nk52VIRM8Fg0TUUSHOGRi1aVtDQPy5CUyxmSpERArm7W3HCbI0OgkKe6eB4E DX7jfekXC5w7rOcPtMa3qjXTuib9p1zMPLsBQp7lAK7izRUBO+tnXZ5aqibeR9FgaiUA /b4uXeFv9Z0Dsl73Pj7RH1YuB8jJcf5NHU98R4aqC4wKlxMlaNIDwLCNnKcgj7CpsMmc FMkQ== X-Gm-Message-State: ALoCoQlcFbCN01j3+EjKTQOI1KX/dZTHAntG2ETq92c2S2zNKOp8wXupD85J0o0dWyA9+KYXSfp0 X-Received: by 10.66.191.232 with SMTP id hb8mr8596812pac.117.1413553095384; Fri, 17 Oct 2014 06:38:15 -0700 (PDT) Received: from localhost ([220.202.153.90]) by mx.google.com with ESMTPSA id m2sm1629011pdf.48.2014.10.17.06.38.12 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 17 Oct 2014 06:38:14 -0700 (PDT) From: Hanjun Guo To: Catalin Marinas , "Rafael J. Wysocki" , Mark Rutland , Olof Johansson , Grant Likely , Will Deacon Subject: [PATCH v5 03/18] ACPI / table: Count matched and successfully parsed entries without specifying max entries Date: Fri, 17 Oct 2014 21:36:59 +0800 Message-Id: <1413553034-20956-4-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1413553034-20956-1-git-send-email-hanjun.guo@linaro.org> References: <1413553034-20956-1-git-send-email-hanjun.guo@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141017_063836_492073_91278237 X-CRM114-Status: GOOD ( 11.83 ) X-Spam-Score: -0.9 (/) Cc: linaro-acpi@lists.linaro.org, Liviu Dudau , Lv Zheng , Rob Herring , Lorenzo Pieralisi , Daniel Lezcano , Robert Moore , linux-acpi@vger.kernel.org, Charles.Garcia-Tobin@arm.com, Robert Richter , Jason Cooper , Arnd Bergmann , Marc Zyngier , Jon Masters , Tomasz Nowicki , Mark Brown , Bjorn Helgaas , linux-arm-kernel@lists.infradead.org, Graeme Gregory , Kangkang.Shen@huawei.com, Randy Dunlap , linux-kernel@vger.kernel.org, Hanjun Guo , Sudeep Holla X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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: Tomasz Nowicki It is very useful to traverse all available table entries without max number of expected entries type. Current acpi_parse_entries() implementation gives that feature but it does not count those entries, it returns 0 instead, so fix it to count matched and successfully entries and return it. NOTE: This change has no impact to x86 and ia64 archs since existing code checks for error occurrence only (acpi_parse_entries(...,0) < 0). Acked-by: Grant Likely Signed-off-by: Tomasz Nowicki Signed-off-by: Hanjun Guo --- drivers/acpi/tables.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 21ae521..b18e45e 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -225,10 +225,13 @@ acpi_parse_entries(unsigned long table_size, while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < table_end) { if (entry->type == entry_id - && (!max_entries || count++ < max_entries)) + && (!max_entries || count < max_entries)) { if (handler(entry, table_end)) return -EINVAL; + count++; + } + /* * If entry->length is 0, break from this loop to avoid * infinite loop.