ACPI: extlog: Handle multiple records
[sfrench/cifs-2.6.git] / drivers / acpi / acpi_extlog.c
index 72f1fb77abcd03b5a332d0d13d8803a2cb8035df..e648158368a7d8802f129e6da1509fa054f8af71 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/ratelimit.h>
 #include <linux/edac.h>
 #include <linux/ras.h>
+#include <acpi/ghes.h>
 #include <asm/cpu.h>
 #include <asm/mce.h>
 
@@ -138,8 +139,8 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
        int     cpu = mce->extcpu;
        struct acpi_hest_generic_status *estatus, *tmp;
        struct acpi_hest_generic_data *gdata;
-       const guid_t *fru_id = &guid_null;
-       char *fru_text = "";
+       const guid_t *fru_id;
+       char *fru_text;
        guid_t *sec_type;
        static u32 err_seq;
 
@@ -160,17 +161,23 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 
        /* log event via trace */
        err_seq++;
-       gdata = (struct acpi_hest_generic_data *)(tmp + 1);
-       if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
-               fru_id = (guid_t *)gdata->fru_id;
-       if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
-               fru_text = gdata->fru_text;
-       sec_type = (guid_t *)gdata->section_type;
-       if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
-               struct cper_sec_mem_err *mem = (void *)(gdata + 1);
-               if (gdata->error_data_length >= sizeof(*mem))
-                       trace_extlog_mem_event(mem, err_seq, fru_id, fru_text,
-                                              (u8)gdata->error_severity);
+       apei_estatus_for_each_section(tmp, gdata) {
+               if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
+                       fru_id = (guid_t *)gdata->fru_id;
+               else
+                       fru_id = &guid_null;
+               if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
+                       fru_text = gdata->fru_text;
+               else
+                       fru_text = "";
+               sec_type = (guid_t *)gdata->section_type;
+               if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
+                       struct cper_sec_mem_err *mem = (void *)(gdata + 1);
+
+                       if (gdata->error_data_length >= sizeof(*mem))
+                               trace_extlog_mem_event(mem, err_seq, fru_id, fru_text,
+                                                      (u8)gdata->error_severity);
+               }
        }
 
 out: