@@ -981,7 +981,8 @@ static int __init acpi_parse_madt_lapic_entries(void)
{
int count;
int x2count = 0;
- struct acpi_subtable_proc madt_proc[1];
+ int ret;
+ struct acpi_subtable_proc madt_proc[2];
if (!cpu_has_apic)
return -ENODEV;
@@ -1008,16 +1009,19 @@ static int __init acpi_parse_madt_lapic_entries(void)
memset(madt_proc, 0, sizeof(madt_proc));
madt_proc[0].id = ACPI_MADT_TYPE_LOCAL_X2APIC;
madt_proc[0].handler = acpi_parse_x2apic;
- x2count = acpi_table_parse_entries_array(ACPI_SIG_MADT,
- sizeof(struct acpi_table_madt),
- madt_proc, ARRAY_SIZE(madt_proc), MAX_LOCAL_APIC);
-
- memset(madt_proc, 0, sizeof(madt_proc));
- madt_proc[0].id = ACPI_MADT_TYPE_LOCAL_APIC;
- madt_proc[0].handler = acpi_parse_lapic;
- count = acpi_table_parse_entries_array(ACPI_SIG_MADT,
+ madt_proc[1].id = ACPI_MADT_TYPE_LOCAL_APIC;
+ madt_proc[1].handler = acpi_parse_lapic;
+ ret = acpi_table_parse_entries_array(ACPI_SIG_MADT,
sizeof(struct acpi_table_madt),
madt_proc, ARRAY_SIZE(madt_proc), MAX_LOCAL_APIC);
+ if (ret < 0) {
+ printk(KERN_ERR PREFIX
+ "Error parsing LAPIC/X2APIC entries\n");
+ return ret;
+ }
+
+ x2count = madt_proc[0].count;
+ count = madt_proc[1].count;
}
if (!count && !x2count) {
printk(KERN_ERR PREFIX "No LAPIC entries present\n");
@@ -1032,21 +1036,16 @@ static int __init acpi_parse_madt_lapic_entries(void)
memset(madt_proc, 0, sizeof(madt_proc));
madt_proc[0].id = ACPI_MADT_TYPE_LOCAL_X2APIC_NMI;
madt_proc[0].handler = acpi_parse_x2apic_nmi;
- count = acpi_table_parse_entries_array(ACPI_SIG_MADT,
+ madt_proc[1].id = ACPI_MADT_TYPE_LOCAL_APIC_NMI;
+ madt_proc[1].handler = acpi_parse_lapic_nmi;
+ ret = acpi_table_parse_entries_array(ACPI_SIG_MADT,
sizeof(struct acpi_table_madt),
madt_proc, ARRAY_SIZE(madt_proc), 0);
- memset(madt_proc, 0, sizeof(madt_proc));
- madt_proc[0].id = ACPI_MADT_TYPE_LOCAL_APIC_NMI;
- madt_proc[0].handler = acpi_parse_lapic_nmi;
- x2count = acpi_table_parse_entries_array(ACPI_SIG_MADT,
- sizeof(struct acpi_table_madt),
- madt_proc, ARRAY_SIZE(madt_proc), 0);
-
- if (count < 0 || x2count < 0) {
+ if (ret < 0) {
printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
/* TBD: Cleanup to allow fallback to MPS */
- return count;
+ return ret;
}
return 0;
}
@@ -239,6 +239,7 @@ acpi_parse_entries(char *id, unsigned long table_size,
struct acpi_subtable_header *entry;
int count = 0;
unsigned long table_end;
+ int i;
if (acpi_disabled)
return -ENODEV;
@@ -269,7 +270,7 @@ acpi_parse_entries(char *id, unsigned long table_size,
for (i = 0; i < proc_num; i++) {
if (entry->type != proc[i].id)
continue;
- if (!proc->handler || proc[i].handler(entry, table_end)) {
+ if (!proc->handler || proc[i].handler(entry, table_end))
return -EINVAL;
proc->count++;