linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiaofei Tan <tanxiaofei@huawei.com>
To: <mchehab@kernel.org>, <linux-edac@vger.kernel.org>
Cc: Xiaofei Tan <tanxiaofei@huawei.com>, <linuxarm@huawei.com>,
	<shiju.jose@huawei.com>, <jonathan.cameron@huawei.com>
Subject: [PATCH 7/9] rasdaemon: split PCIe local table decode function to reduce length
Date: Tue, 12 Nov 2019 20:27:12 +0800	[thread overview]
Message-ID: <1573561634-225173-8-git-send-email-tanxiaofei@huawei.com> (raw)
In-Reply-To: <1573561634-225173-1-git-send-email-tanxiaofei@huawei.com>

This patch splits function decode_hip08_pcie_local_error() to reduce
length. Move header decoding and register dump to single function
separately.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
---
 non-standard-hisi_hip08.c | 75 ++++++++++++++++++++++++++++-------------------
 1 file changed, 45 insertions(+), 30 deletions(-)

diff --git a/non-standard-hisi_hip08.c b/non-standard-hisi_hip08.c
index ea640a6..fcc7a0e 100644
--- a/non-standard-hisi_hip08.c
+++ b/non-standard-hisi_hip08.c
@@ -868,36 +868,12 @@ static int decode_hip08_oem_type2_error(struct ras_events *ras,
 	return 0;
 }
 
-static int decode_hip08_pcie_local_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_pcie_local_err_hdr(struct ras_ns_dec_tab *dec_tab,
+				      struct trace_seq *s,
+				      const struct hisi_pcie_local_err_sec *err)
 {
-	const struct hisi_pcie_local_err_sec *err =
-			(struct hisi_pcie_local_err_sec *)event->error;
 	char buf[1024];
 	char *p = buf;
-	uint32_t i;
-
-	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_pcie_local_event_tab) != SQLITE_OK) {
-			trace_seq_printf(s,
-				"create sql hip08_pcie_local_event_tab fail\n");
-			return -1;
-		}
-	}
-#endif
-	record_vendor_data(dec_tab, hisi_oem_data_type_text,
-			   hip08_pcie_local_field_timestamp,
-			   0, event->timestamp);
 
 	p += sprintf(p, "[ ");
 	p += sprintf(p, "table_version=%d ", err->version);
@@ -962,11 +938,17 @@ static int decode_hip08_pcie_local_error(struct ras_events *ras,
 				   err->err_type, NULL);
 	}
 	p += sprintf(p, "]");
-
-	trace_seq_printf(s, "\nHISI HIP08: PCIe local error\n");
 	trace_seq_printf(s, "%s\n", buf);
+}
+
+static void decode_pcie_local_err_regs(struct ras_ns_dec_tab *dec_tab,
+				       struct trace_seq *s,
+				       const struct hisi_pcie_local_err_sec *err)
+{
+	char buf[1024];
+	char *p = buf;
+	uint32_t i;
 
-	p = buf;
 	trace_seq_printf(s, "Reg Dump:\n");
 	for (i = 0; i < 33; i++) {
 		if (err->val_bits & BIT(HISI_PCIE_LOCAL_VALID_ERR_MISC + i)) {
@@ -981,6 +963,39 @@ static int decode_hip08_pcie_local_error(struct ras_events *ras,
 			   hip08_pcie_local_field_regs_dump, 0, buf);
 
 	step_vendor_data_tab(dec_tab, "hip08_pcie_local_event_tab");
+}
+
+static int decode_hip08_pcie_local_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_pcie_local_err_sec *err =
+			(struct hisi_pcie_local_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_pcie_local_event_tab) != SQLITE_OK) {
+			trace_seq_printf(s,
+				"create sql hip08_pcie_local_event_tab fail\n");
+			return -1;
+		}
+	}
+#endif
+	record_vendor_data(dec_tab, hisi_oem_data_type_text,
+			   hip08_pcie_local_field_timestamp,
+			   0, event->timestamp);
+
+	trace_seq_printf(s, "\nHISI HIP08: PCIe local error\n");
+	decode_pcie_local_err_hdr(dec_tab, s, err);
+	decode_pcie_local_err_regs(dec_tab, s, err);
 
 	return 0;
 }
-- 
2.8.1


  parent reply	other threads:[~2019-11-12 12:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12 12:27 [PATCH 0/9] rasdaemon: fix some issues reported by static code analysis Xiaofei Tan
2019-11-12 12:27 ` [PATCH 1/9] rasdaemon: fix the wrong declaring of 'sruct ras_events' in ras-record.h Xiaofei Tan
2019-11-12 12:27 ` [PATCH 2/9] rasdaemon: fix an warning reported by PC-Lint Xiaofei Tan
2019-11-12 12:27 ` [PATCH 3/9] rasdaemon: decode submodule of OEM type1 for hip08 Xiaofei Tan
2019-11-26  6:07   ` Mauro Carvalho Chehab
2019-11-26  8:28     ` Xiaofei Tan
2019-11-12 12:27 ` [PATCH 4/9] rasdaemon: fix sub module name of HHA and DDRC " Xiaofei Tan
2019-11-12 12:27 ` [PATCH 5/9] rasdaemon: split OEM type1 table decode function to reduce length Xiaofei Tan
2019-11-12 12:27 ` [PATCH 6/9] rasdaemon: split OEM type2 " Xiaofei Tan
2019-11-12 12:27 ` Xiaofei Tan [this message]
2019-11-12 12:27 ` [PATCH 8/9] rasdaemon: fix magic number issues reported by static code analysis for hip08 Xiaofei Tan
2019-11-12 12:27 ` [PATCH 9/9] rasdaemon: replace sprintf with snprintf " Xiaofei Tan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1573561634-225173-8-git-send-email-tanxiaofei@huawei.com \
    --to=tanxiaofei@huawei.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mchehab@kernel.org \
    --cc=shiju.jose@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).