[PATCH 10/21] megaraid_sas: Add formatting option for megasas_dump

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add option to format the buffer that is being dumped.
Currently, the IO frame and chain frame dumped in the syslog is
getting split across multiple lines based on the formatting.
Fix this by using KERN_CONT in printk.

Signed-off-by: Sumit Saxena <sumit.saxena@xxxxxxxxxxxx>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@xxxxxxxxxxxx>
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 7449df36a092..d0fd307e30af 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -2838,22 +2838,28 @@ blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
 }
 
 /**
- * megasas_dump -	This function will provide hexdump
- * @ptr:		Pointer starting which memory should be dumped
- * @size:		Size of memory to be dumped
+ * megasas_dump -	This function will print hexdump of provided buffer.
+ * @buf:		Buffer to be dumped
+ * @sz:		Size in bytes
+ * @format:		Different formats of dumping e.g. format=n will
+ *			cause only 'n' 32 bit words to be dumped in a single
+ *			line.
  */
 inline void
-megasas_dump(void *ptr, int sz)
+megasas_dump(void *buf, int sz, int format)
 {
 	int i;
-	__le32 *loc = (__le32 *)ptr;
+	__le32 *buf_loc = (__le32 *)buf;
 
-	for (i = 0; i < sz / sizeof(__le32); i++) {
-		if (i && ((i % 8) == 0))
-			printk("\n\t");
-		printk("%08x ", le32_to_cpu(loc[i]));
+	for (i = 0; i < (sz / sizeof(__le32)); i++) {
+		if ((i % format) == 0) {
+			if (i != 0)
+				printk(KERN_CONT "\n");
+			printk(KERN_CONT "%08x: ", (i * 4));
+		}
+		printk(KERN_CONT "%08x ", le32_to_cpu(buf_loc[i]));
 	}
-	printk("\n");
+	printk(KERN_CONT "\n");
 }
 
 /**
@@ -2887,10 +2893,10 @@ megasas_dump_fusion_io(struct scsi_cmnd *scmd)
 
 		printk(KERN_INFO "IO request frame:\n");
 		megasas_dump(cmd->io_request,
-			     MEGA_MPI2_RAID_DEFAULT_IO_FRAME_SIZE);
+			     MEGA_MPI2_RAID_DEFAULT_IO_FRAME_SIZE, 8);
 		printk(KERN_INFO "Chain frame:\n");
 		megasas_dump(cmd->sg_frame,
-			     instance->max_chain_frame_sz);
+			     instance->max_chain_frame_sz, 8);
 	}
 
 }
-- 
2.16.1




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux