From patchwork Wed Nov 26 14:01:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 41539 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 00E2F25E18 for ; Wed, 26 Nov 2014 14:01:52 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id l15sf1998798wiw.0 for ; Wed, 26 Nov 2014 06:01:51 -0800 (PST) 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=AJl1UlfxezadsxKjpyvMzWJT8TAf/l7Ub4D+NByR8nU=; b=I6vq7v5BL461S8gi37fIPNq3PY4rEJrM4s4E46pz6FhCd/qYXZRolIfvH05u79/wSF K/F+kSvcAamSP1DpVDtUQ1fBSK1rbIYxUxzaMO3y1Kp0IO1rKzeE0jsxD1zO89ewzkmG 9CK8i01+0KHlh//YXsQ2Hv5CQD+4A0zGZeOapkUam1FA9oj9QpJ47TIT+JqzXk06tQgE AtHlqpvytG0T6SeElYxu7dTzTPQf8X6vLANBfuKGzlM/KlqF12KiawuZbzbzoiOGSi4q F+sr0UxkLIcYNpdlfHRR+Dfd9hgUjGz+tC/3QjYfEaEWy4ek35FuBxfrpZ50OEGwz6K+ PIUQ== X-Gm-Message-State: ALoCoQn3YIFz7wEm0F+yNroeHmeyWL3QKF/pHugZECG3/L1nB5WCO40+vtyXJx18VqTpYmg7GIX2 X-Received: by 10.152.26.72 with SMTP id j8mr9209023lag.3.1417010511298; Wed, 26 Nov 2014 06:01:51 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.166 with SMTP id t6ls781643lat.20.gmail; Wed, 26 Nov 2014 06:01:51 -0800 (PST) X-Received: by 10.152.216.167 with SMTP id or7mr32850117lac.93.1417010511082; Wed, 26 Nov 2014 06:01:51 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id xi1si4508670lbb.29.2014.11.26.06.01.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Nov 2014 06:01:51 -0800 (PST) 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 ms9so2499330lab.10 for ; Wed, 26 Nov 2014 06:01:51 -0800 (PST) X-Received: by 10.112.62.166 with SMTP id z6mr33390514lbr.74.1417010510974; Wed, 26 Nov 2014 06:01:50 -0800 (PST) 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.184.201 with SMTP id ew9csp624410lbc; Wed, 26 Nov 2014 06:01:49 -0800 (PST) X-Received: by 10.69.31.138 with SMTP id km10mr54033172pbd.6.1417010506923; Wed, 26 Nov 2014 06:01:46 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ft3si6938066pbb.98.2014.11.26.06.01.45 for ; Wed, 26 Nov 2014 06:01:46 -0800 (PST) Received-SPF: none (google.com: linux-acpi-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 S1752070AbaKZOBo (ORCPT + 6 others); Wed, 26 Nov 2014 09:01:44 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:38408 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752722AbaKZOBm (ORCPT ); Wed, 26 Nov 2014 09:01:42 -0500 Received: by mail-pa0-f44.google.com with SMTP id et14so2926583pad.17 for ; Wed, 26 Nov 2014 06:01:42 -0800 (PST) X-Received: by 10.70.94.36 with SMTP id cz4mr53326086pdb.169.1417010501723; Wed, 26 Nov 2014 06:01:41 -0800 (PST) Received: from localhost ([39.181.45.161]) by mx.google.com with ESMTPSA id j10sm4395392pdr.92.2014.11.26.06.01.39 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 26 Nov 2014 06:01:40 -0800 (PST) From: Hanjun Guo To: "Rafael J. Wysocki" Cc: linux-acpi@vger.kernel.org, linaro-acpi@lists.linaro.org, Tomasz Nowicki , Hanjun Guo Subject: [PATCH 2/2] ACPI / table: Count matched and successfully parsed entries without specifying max entries Date: Wed, 26 Nov 2014 22:01:14 +0800 Message-Id: <1417010474-2399-2-git-send-email-hanjun.guo@linaro.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1417010474-2399-1-git-send-email-hanjun.guo@linaro.com> References: <1417010474-2399-1-git-send-email-hanjun.guo@linaro.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-acpi@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 acpi_parse_entries() allows to traverse all available table entries (aka subtables) by passing max_entries parameter equal to 0, but since its count variable is only incremented if max_entries is not 0, the function always returns 0 for max_entries equal to 0. It would be more useful if it returned the number of entries matched instead, so make it increment count in that case too. 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 f1debe9..93b8152 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -224,10 +224,13 @@ acpi_parse_entries(char *id, 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.