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>
This commit is contained in:
parent
f08bb472bf
commit
4ceacd02f5
@ -224,10 +224,13 @@ acpi_parse_entries(char *id, unsigned long table_size,
|
|||||||
while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
|
while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
|
||||||
table_end) {
|
table_end) {
|
||||||
if (entry->type == entry_id
|
if (entry->type == entry_id
|
||||||
&& (!max_entries || count++ < max_entries))
|
&& (!max_entries || count < max_entries)) {
|
||||||
if (handler(entry, table_end))
|
if (handler(entry, table_end))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If entry->length is 0, break from this loop to avoid
|
* If entry->length is 0, break from this loop to avoid
|
||||||
* infinite loop.
|
* infinite loop.
|
||||||
|
Loading…
Reference in New Issue
Block a user