From patchwork Fri Sep 12 14:00:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 4895361 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 131A19F40F for ; Fri, 12 Sep 2014 14:00:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 434E0202B8 for ; Fri, 12 Sep 2014 14:05:21 +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 2D251202E5 for ; Fri, 12 Sep 2014 14:05:19 +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 1XSRQ4-0001Dj-JK; Fri, 12 Sep 2014 14:01:48 +0000 Received: from mail-pd0-f181.google.com ([209.85.192.181]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XSRPd-0000nr-1N for linux-arm-kernel@lists.infradead.org; Fri, 12 Sep 2014 14:01:21 +0000 Received: by mail-pd0-f181.google.com with SMTP id w10so1299883pde.12 for ; Fri, 12 Sep 2014 07:00:59 -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=Pkyfy0S+IMHjlljeCrla1nhhdvrF+yUQF7nd0TqiQ4E=; b=bOGFA7b/bGrkcDiO3g8ZvA3R1W2wm20zysyYjVxzprs8MlP25QXT8AiVfPIQiYDyUv PwI8H18kxbMldUGE+UfC9dFaUEqf71EtMxf/s9DCFrDuKzlgM77ifQp13bXR7P/Woy8m sqil+NPStgD0Yai0LvBuSytJ/5X6h2cbHOkZKuHw433506JlauQt+slD6ZexMy5McmcT EGNJsJIZUSbVGybrJEMQgbO6cTVZRb/d2GpEqTKlvQcsWEWaEtIzuIWNtdp65Wb9cRED 4NcGadm949C7b9pLLBs3TmqIgTfNp1jViqZT+6yeIWufvPEMfT3RBu6eO6Q/aufGDu5/ gpcw== X-Gm-Message-State: ALoCoQnd94VrYF+4KOxP5dAtnUDO/HHAEW6zgt0KA4zEvOhK6eSH/wBUTQtkj9+R0daKYSjWIf6Y X-Received: by 10.70.90.39 with SMTP id bt7mr13265437pdb.121.1410530459100; Fri, 12 Sep 2014 07:00:59 -0700 (PDT) Received: from localhost ([111.140.73.43]) by mx.google.com with ESMTPSA id db2sm4080594pbc.16.2014.09.12.07.00.57 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 12 Sep 2014 07:00:58 -0700 (PDT) From: Hanjun Guo To: Catalin Marinas , "Rafael J. Wysocki" , Mark Rutland , Olof Johansson , Grant Likely , Will Deacon Subject: [PATCH v4 03/18] ACPI / table: Count matched and successfully parsed entries without specifying max entries Date: Fri, 12 Sep 2014 22:00:01 +0800 Message-Id: <1410530416-30200-4-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1410530416-30200-1-git-send-email-hanjun.guo@linaro.org> References: <1410530416-30200-1-git-send-email-hanjun.guo@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140912_070121_151828_571EECA6 X-CRM114-Status: GOOD ( 11.78 ) X-Spam-Score: -2.5 (--) 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 , 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=-4.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD,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 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). Signed-off-by: Tomasz Nowicki Signed-off-by: Hanjun Guo Acked-by: Grant Likely --- 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.