From: Hanjun Guo <hanjun.guo@linaro.org>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-acpi@vger.kernel.org, linaro-acpi@lists.linaro.org,
Tomasz Nowicki <tomasz.nowicki@linaro.org>,
Hanjun Guo <hanjun.guo@linaro.org>
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 [thread overview]
Message-ID: <1417010474-2399-2-git-send-email-hanjun.guo@linaro.com> (raw)
In-Reply-To: <1417010474-2399-1-git-send-email-hanjun.guo@linaro.com>
From: Tomasz Nowicki <tomasz.nowicki@linaro.org>
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 <grant.likely@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
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.
--
1.9.1
next prev parent reply other threads:[~2014-11-26 14:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-26 14:01 [PATCH 1/2] ACPI / table: Add new function to get table entries Hanjun Guo
2014-11-26 14:01 ` Hanjun Guo [this message]
2014-11-26 22:14 ` Rafael J. Wysocki
2014-11-27 0:29 ` Hanjun Guo
2014-11-27 0:54 ` Rafael J. Wysocki
2014-12-03 2:27 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1417010474-2399-2-git-send-email-hanjun.guo@linaro.com \
--to=hanjun.guo@linaro.org \
--cc=linaro-acpi@lists.linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=tomasz.nowicki@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox