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: 38860 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C0A462054E for ; Fri, 17 Oct 2014 13:38:42 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id p9sf488514lbv.8 for ; Fri, 17 Oct 2014 06:38:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Qs629T6rHHUh2ICW/M3kLAlYWdogigpKsf++hu8XSIc=; b=k35AvwnDZBkmUAU1dtzLstII3EYK0rk1SVF9KsPh8rWoQKdJqeJ+Pq/f5COQTwHTTY o/cUdbyY4Uk/jMKiNdJpwv216iAYJHPviT8NU34I1QLlfxRGj4AOv70eNB72lrTqaLYA 8NmpWVHWKfm0T3J0EUHS2wDZamaNEmSMM1fkXvfds4TlZuk04h1HR2bsdOqhfTTsou7a FsajTq2rSdFFITwCtE4z+juOqKatJHsZvbYpUsXIfnrXeaRGF4Xq6cGAnKRCv8FeNNhS 4duRzVcfIET0RsvVpP63GoSULNdjL/CP0TLN49iqMyS4Uacu98i1uy4j+3+0/OhyP9tz qItQ== X-Gm-Message-State: ALoCoQmfIVUFRq4WwFIIM4ANA0OVd6DHlrIVAeFHykzlh+auOFGHqdv+XVpyhWBfJhUAzTNKFik+ X-Received: by 10.180.96.101 with SMTP id dr5mr4489232wib.0.1413553121597; Fri, 17 Oct 2014 06:38:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.52 with SMTP id o20ls276154laa.3.gmail; Fri, 17 Oct 2014 06:38:41 -0700 (PDT) X-Received: by 10.152.206.36 with SMTP id ll4mr9083092lac.64.1413553121198; Fri, 17 Oct 2014 06:38:41 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id mi5si2110697lbc.61.2014.10.17.06.38.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Oct 2014 06:38:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ge10so701281lab.24 for ; Fri, 17 Oct 2014 06:38:41 -0700 (PDT) X-Received: by 10.112.77.74 with SMTP id q10mr640831lbw.66.1413553121080; Fri, 17 Oct 2014 06:38:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp228253lbz; Fri, 17 Oct 2014 06:38:40 -0700 (PDT) X-Received: by 10.68.164.65 with SMTP id yo1mr8577252pbb.126.1413553119176; Fri, 17 Oct 2014 06:38:39 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ru9si1142685pab.173.2014.10.17.06.38.38 for ; Fri, 17 Oct 2014 06:38:39 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753096AbaJQNiT (ORCPT + 27 others); Fri, 17 Oct 2014 09:38:19 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:57303 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752964AbaJQNiP (ORCPT ); Fri, 17 Oct 2014 09:38:15 -0400 Received: by mail-pa0-f44.google.com with SMTP id et14so855922pad.17 for ; Fri, 17 Oct 2014 06:38:15 -0700 (PDT) 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 Cc: Graeme Gregory , Arnd Bergmann , Sudeep Holla , Jon Masters , Jason Cooper , Marc Zyngier , Bjorn Helgaas , Daniel Lezcano , Mark Brown , Rob Herring , Robert Richter , Lv Zheng , Robert Moore , Lorenzo Pieralisi , Liviu Dudau , Randy Dunlap , Charles.Garcia-Tobin@arm.com, Kangkang.Shen@huawei.com, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, Tomasz Nowicki , Hanjun Guo 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: hanjun.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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.