diff options
author | Tomasz Nowicki <tomasz.nowicki@linaro.org> | 2014-11-26 09:01:14 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-11-26 20:07:41 -0500 |
commit | 4ceacd02f5a1795c5c697e0345ee10beef675290 (patch) | |
tree | 168a8638a12acff9ee059fcfd24818d4df17393f | |
parent | f08bb472bff3c0397fb7d6f47bc5cec41dad76e3 (diff) |
ACPI / table: Always count matched and successfully parsed entries
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>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/tables.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index f1debe97dcfc..93b81523a2fe 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c | |||
@@ -224,10 +224,13 @@ acpi_parse_entries(char *id, unsigned long table_size, | |||
224 | while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < | 224 | while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < |
225 | table_end) { | 225 | table_end) { |
226 | if (entry->type == entry_id | 226 | if (entry->type == entry_id |
227 | && (!max_entries || count++ < max_entries)) | 227 | && (!max_entries || count < max_entries)) { |
228 | if (handler(entry, table_end)) | 228 | if (handler(entry, table_end)) |
229 | return -EINVAL; | 229 | return -EINVAL; |
230 | 230 | ||
231 | count++; | ||
232 | } | ||
233 | |||
231 | /* | 234 | /* |
232 | * If entry->length is 0, break from this loop to avoid | 235 | * If entry->length is 0, break from this loop to avoid |
233 | * infinite loop. | 236 | * infinite loop. |