]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
rasdaemon: split OEM type2 table decode function to reduce length
authorXiaofei Tan <tanxiaofei@huawei.com>
Tue, 26 Nov 2019 13:18:55 +0000 (14:18 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 26 Nov 2019 13:18:55 +0000 (14:18 +0100)
This patch splits function decode_hip08_oem_type2_error() to reduce
length. Move header decoding and register dump to single function
separately.

CC: Xiaofei Tan <tanxiaofei@huawei.com>, <linuxarm@huawei.com>, <shiju.jose@huawei.com>, <jonathan.cameron@huawei.com> Date: Tue, 26 Nov 2019 20:12:31 +0800
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
non-standard-hisi_hip08.c

index 79fc1b91a8ab28d3842b53fc22490200d719d98b..bd6829135b19d128f1b5b160f3978a89fa155367 100644 (file)
@@ -709,36 +709,13 @@ static int decode_hip08_oem_type1_error(struct ras_events *ras,
        return 0;
 }
 
-static int decode_hip08_oem_type2_error(struct ras_events *ras,
-                                       struct ras_ns_dec_tab *dec_tab,
-                                       struct trace_seq *s,
-                                       struct ras_non_standard_event *event)
+static void decode_oem_type2_err_hdr(struct ras_ns_dec_tab *dec_tab,
+                                    struct trace_seq *s,
+                                    const struct hisi_oem_type2_err_sec *err)
 {
-       const struct hisi_oem_type2_err_sec *err =
-                       (struct hisi_oem_type2_err_sec *)event->error;
        char buf[1024];
        char *p = buf;
 
-       if (err->val_bits == 0) {
-               trace_seq_printf(s, "%s: no valid error information\n",
-                                __func__);
-               return -1;
-       }
-
-#ifdef HAVE_SQLITE3
-       if (!dec_tab->stmt_dec_record) {
-               if (ras_mc_add_vendor_table(ras, &dec_tab->stmt_dec_record,
-                       &hip08_oem_type2_event_tab) != SQLITE_OK) {
-                       trace_seq_printf(s,
-                               "create sql hip08_oem_type2_event_tab fail\n");
-                       return -1;
-               }
-       }
-#endif
-       record_vendor_data(dec_tab, hisi_oem_data_type_text,
-                          hip08_oem_type2_field_timestamp,
-                          0, event->timestamp);
-
        p += sprintf(p, "[ ");
        p += sprintf(p, "table_version=%d ", err->version);
        record_vendor_data(dec_tab, hisi_oem_data_type_int,
@@ -794,10 +771,16 @@ static int decode_hip08_oem_type2_error(struct ras_events *ras,
        }
 
        p += sprintf(p, "]");
-       trace_seq_printf(s, "\nHISI HIP08: OEM Type-2 Error\n");
        trace_seq_printf(s, "%s\n", buf);
+}
+
+static void decode_oem_type2_err_regs(struct ras_ns_dec_tab *dec_tab,
+                                     struct trace_seq *s,
+                                     const struct hisi_oem_type2_err_sec *err)
+{
+       char buf[1024];
+       char *p = buf;
 
-       p = buf;
        trace_seq_printf(s, "Reg Dump:\n");
        if (err->val_bits & HISI_OEM_TYPE2_VALID_ERR_FR) {
                trace_seq_printf(s, "ERR_FR_0=0x%x\n", err->err_fr_0);
@@ -846,6 +829,40 @@ static int decode_hip08_oem_type2_error(struct ras_events *ras,
                           hip08_oem_type2_field_regs_dump, 0, buf);
 
        step_vendor_data_tab(dec_tab, "hip08_oem_type2_event_tab");
+}
+
+static int decode_hip08_oem_type2_error(struct ras_events *ras,
+                                       struct ras_ns_dec_tab *dec_tab,
+                                       struct trace_seq *s,
+                                       struct ras_non_standard_event *event)
+{
+       const struct hisi_oem_type2_err_sec *err =
+                       (struct hisi_oem_type2_err_sec *)event->error;
+
+       if (err->val_bits == 0) {
+               trace_seq_printf(s, "%s: no valid error information\n",
+                                __func__);
+               return -1;
+       }
+
+#ifdef HAVE_SQLITE3
+       if (!dec_tab->stmt_dec_record) {
+               if (ras_mc_add_vendor_table(ras, &dec_tab->stmt_dec_record,
+                       &hip08_oem_type2_event_tab) != SQLITE_OK) {
+                       trace_seq_printf(s,
+                               "create sql hip08_oem_type2_event_tab fail\n");
+                       return -1;
+               }
+       }
+#endif
+       record_vendor_data(dec_tab, hisi_oem_data_type_text,
+                          hip08_oem_type2_field_timestamp,
+                          0, event->timestamp);
+
+
+       trace_seq_printf(s, "\nHISI HIP08: OEM Type-2 Error\n");
+       decode_oem_type2_err_hdr(dec_tab, s, err);
+       decode_oem_type2_err_regs(dec_tab, s, err);
 
        return 0;
 }