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: 37345 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D5908203EE for ; Fri, 12 Sep 2014 14:07:36 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id mc6sf522915lab.2 for ; Fri, 12 Sep 2014 07:07:35 -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=KYhp1A0dpHCcdDuSCHPXhF/YFh72jqchWtAHGWVVx8U=; b=EaALzPCwE9DkUZlaG7CvuPRWfCJXE/O0OF1M2+hZBfUM4BKJwjlTKs/oISP5qmsPLa Vi4r6oU1t3SWchYDnVAUDsRNsd7OSls7cE9RD5eoRQzE+Y4r4Ky1JcxWGRpNPO2E4q48 FYMm/hRpLR/CM+3PfRnS3pOk2YXs5oqQxmdfhvmUN8UTq97pPE4k32oGjqXhL9ghRtEP ikIo/2Ac1FJrpgfpGMNnDn9jriyiIAj7BK9GK7dfTaSv25siAwrVgVMVQAbkGdaosxSC n6yqr8x7sb8OcXZKT2iTtDOnFfjRmXMo+WkvbRIc+/p1EC9SD0U/h9+il+0ILmA3+3XS eiSA== X-Gm-Message-State: ALoCoQmwScASuBweD6M3xvJ0NtgCnMRrbabaDxqAvCaY77u6zhFT1whwq/onSGGojwpKFSQlL8G6 X-Received: by 10.180.105.3 with SMTP id gi3mr704515wib.3.1410530486458; Fri, 12 Sep 2014 07:01:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.116.99 with SMTP id jv3ls182124lab.54.gmail; Fri, 12 Sep 2014 07:01:26 -0700 (PDT) X-Received: by 10.152.28.74 with SMTP id z10mr9555720lag.10.1410530486273; Fri, 12 Sep 2014 07:01:26 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) by mx.google.com with ESMTPS id xt8si6714778lab.44.2014.09.12.07.01.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Sep 2014 07:01:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id z11so936727lbi.26 for ; Fri, 12 Sep 2014 07:01:26 -0700 (PDT) X-Received: by 10.112.62.200 with SMTP id a8mr8716240lbs.34.1410530486192; Fri, 12 Sep 2014 07:01:26 -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.141.42 with SMTP id rl10csp737568lbb; Fri, 12 Sep 2014 07:01:25 -0700 (PDT) X-Received: by 10.68.65.73 with SMTP id v9mr11454492pbs.164.1410530484421; Fri, 12 Sep 2014 07:01:24 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id iv3si8220138pbd.30.2014.09.12.07.01.23 for ; Fri, 12 Sep 2014 07:01:24 -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 S1754992AbaILOBE (ORCPT + 27 others); Fri, 12 Sep 2014 10:01:04 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:44337 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754899AbaILOA7 (ORCPT ); Fri, 12 Sep 2014 10:00:59 -0400 Received: by mail-pd0-f179.google.com with SMTP id g10so1288284pdj.24 for ; Fri, 12 Sep 2014 07:00:59 -0700 (PDT) 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 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, 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 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> 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.217.181 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). 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.