[PATCH v2] staging: qlge: emit debug and dump at same level

Subsystems: staging subsystem, the rest

STALE2391d

2 messages, 2 authors, 2020-02-22 · open the first message on its own page

[PATCH v2] staging: qlge: emit debug and dump at same level

From: Kaaira Gupta <hidden>
Date: 2020-02-22 21:51:20

Write a macro QLGE_DUMP_DBG having a function print_hex_dump so that
the debug and dump are emitted at the same KERN_<LEVEL> and code becomes
simpler. Write a macro instead of calling the function directly in
ql_mpi_core_to_log() to go according to the coding practices followed in
other drivers such as nvec and vc04_services.

Signed-off-by: Kaaira Gupta <redacted>
---

changes since v1: make code of ql_mpi_core_to_log() simpler.

----
---
 drivers/staging/qlge/qlge_dbg.c | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
index c7af2548d119..f4440670bc46 100644
--- a/drivers/staging/qlge/qlge_dbg.c
+++ b/drivers/staging/qlge/qlge_dbg.c
@@ -1,5 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define QLGE_DUMP_DBG(str, buf, len)			    \
+	print_hex_dump(KERN_DEBUG, str, DUMP_PREFIX_OFFSET, \
+			32, 4, buf, len, false)
 
 #include <linux/slab.h>
 
@@ -1324,27 +1327,9 @@ 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);
-	}
+	QLGE_DUMP_DBG("Core is dumping to log file!\n", qdev->mpi_coredump,
+		      sizeof(*qdev->mpi_coredump));
 }
 
 #ifdef QL_REG_DUMP
-- 
2.17.1

Re: [PATCH v2] staging: qlge: emit debug and dump at same level

From: Joe Perches <joe@perches.com>
Date: 2020-02-22 23:16:29

On Sun, 2020-02-23 at 03:21 +0530, Kaaira Gupta wrote:
quoted hunk
Write a macro QLGE_DUMP_DBG having a function print_hex_dump so that
the debug and dump are emitted at the same KERN_<LEVEL> and code becomes
simpler. Write a macro instead of calling the function directly in
ql_mpi_core_to_log() to go according to the coding practices followed in
other drivers such as nvec and vc04_services.

Signed-off-by: Kaaira Gupta <redacted>
---

changes since v1: make code of ql_mpi_core_to_log() simpler.

----
---
 drivers/staging/qlge/qlge_dbg.c | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
[]
quoted hunk
@@ -1,5 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define QLGE_DUMP_DBG(str, buf, len)			    \
+	print_hex_dump(KERN_DEBUG, str, DUMP_PREFIX_OFFSET, \
+			32, 4, buf, len, false)
There is no need to create a used-once macro.
Just code the one use in-place.
quoted hunk
 #include <linux/slab.h>
 
@@ -1324,27 +1327,9 @@ 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);
-	}
+	QLGE_DUMP_DBG("Core is dumping to log file!\n", qdev->mpi_coredump,
+		      sizeof(*qdev->mpi_coredump));
 }
 
 #ifdef QL_REG_DUMP

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help