Skip to contentSkip to conversation

staging: qlge: emit debug and dump at same level

PATCH Superseded Kaaira Gupta 2 participants 2 messages Feb 23, 2020

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 staging: qlge: emit debug and dump at same level

Simplify code in ql_mpi_core_to_log() by calling print_hex_dump() instead of existing functions so that the debug and dump are emitted at the same KERN_<LEVEL>

---

changes since v1: make code of ql_mpi_core_to_log() simpler. changes since v2: directly call the function instead of defining a macro.

Also, can you please help me understand how are are numbers 32 and 4 chosen for the function print_hex_dump()?

----

---
 drivers/staging/qlge/qlge_dbg.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)
drivers/staging/qlge/qlge_dbg.c +3 -20
index c7af2548d119..44fb3a317b8d 100644
@@ -1324,27 +1324,10 @@ void ql_mpi_core_to_log(struct work_struct *work)
 {
 	struct ql_adapter *qdev =
 		container_of(work, struct ql_adapter, mpi_core_to_log.work);
-	u32 *tmp, count;
-	int i;
 
-	count = sizeof(struct ql_mpi_coredump) / sizeof(u32);
-	tmp = (u32 *)qdev->mpi_coredump;
-	netif_printk(qdev, drv, KERN_DEBUG, qdev->ndev,
-		     "Core is dumping to log file!\n");
-
-	for (i = 0; i < count; i += 8) {
-		pr_err("%.08x: %.08x %.08x %.08x %.08x %.08x "
-			"%.08x %.08x %.08x\n", i,
-			tmp[i + 0],
-			tmp[i + 1],
-			tmp[i + 2],
-			tmp[i + 3],
-			tmp[i + 4],
-			tmp[i + 5],
-			tmp[i + 6],
-			tmp[i + 7]);
-		msleep(5);
-	}
+	print_hex_dump(KERN_DEBUG, "Core is dumping to log file!\n",
+		       DUMP_PREFIX_OFFSET, 32, 4, qdev->mpi_coredump,
+		       sizeof(*qdev->mpi_coredump), false);
 }
 
 #ifdef QL_REG_DUMP
Signature · 1 line
2.17.1
#1 lore raw
Quoted 3 lines · Kaaira Gupta

Simplify code in ql_mpi_core_to_log() by calling print_hex_dump() instead of existing functions so that the debug and dump are emitted at the same KERN_<LEVEL>

[]

Quoted 2 lines

Also, can you please help me understand how are are numbers 32 and 4 chosen for the function print_hex_dump()?

Emit 32 bytes per line in 4 byte chunks as u32

And below:

drivers/staging/qlge/qlge_dbg.c

Quoted 1 line
drivers/staging/qlge/qlge_dbg.c +0 -0

[]

drivers/staging/qlge/qlge_dbg.c void ql_mpi_core_to_log(struct work_struct *work) · line 1326

Quoted 4 lines
drivers/staging/qlge/qlge_dbg.c +0 -0
@@ -1324,27 +1324,10 @@ void ql_mpi_core_to_log(struct work_struct *work)
 {
 	struct ql_adapter *qdev =
 		container_of(work, struct ql_adapter, mpi_core_to_log.work);

[]

drivers/staging/qlge/qlge_dbg.c void ql_mpi_core_to_log(struct work_struct *work) · line 1330

Quoted 3 lines
drivers/staging/qlge/qlge_dbg.c +3 -0
+	print_hex_dump(KERN_DEBUG, "Core is dumping to log file!\n",
+		       DUMP_PREFIX_OFFSET, 32, 4, qdev->mpi_coredump,
+		       sizeof(*qdev->mpi_coredump), false);

This use of a prefix string is not acceptable.

From the kernel-doc:

/**
* print_hex_dump - print a text hex dump to syslog for a binary blob of data
* @level: kernel log level (e.g. KERN_DEBUG)
* @prefix_str: string to prefix each line with;
* caller supplies trailing spaces for alignment if desired

So this would emit "Core is dumping..." line for for every line of hex output.