Skip to contentSkip to conversation

irda: vlsi_ir: use %*ph specifier

PATCH Superseded Andy Shevchenko 3 participants 3 messages Sep 5, 2014 – Sep 7, 2014

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irda: vlsi_ir: use %*ph specifier

Instead of looping in the code let's use kernel extension to dump small buffers.

---
 drivers/net/irda/vlsi_ir.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/net/irda/vlsi_ir.c +3 -8
index a04af9d..0319eba 100644
@@ -323,14 +323,9 @@ static void vlsi_proc_ring(struct seq_file *seq, struct vlsi_ring *r)
 		j = (unsigned) rd_get_count(rd);
 		seq_printf(seq, "current: rd = %d / status = %02x / len = %u\n",
 				h, (unsigned)rd_get_status(rd), j);
-		if (j > 0) {
-			seq_printf(seq, "   data:");
-			if (j > 20)
-				j = 20;
-			for (i = 0; i < j; i++)
-				seq_printf(seq, " %02x", (unsigned)((unsigned char *)rd->buf)[i]);
-			seq_printf(seq, "\n");
-		}
+		if (j > 0)
+			seq_printf(seq, "   data: %*ph\n", j > 20 ? 20 : j,
+				   rd->buf);
 	}
 	for (i = 0; i < r->size; i++) {
 		rd = &r->rd[i];
Signature · 1 line
2.1.0
#1 lore raw

Hello.

Quoted 16 lines · Andy Shevchenko

Instead of looping in the code let's use kernel extension to dump small buffers.

---
  drivers/net/irda/vlsi_ir.c | 11 +++--------
  1 file changed, 3 insertions(+), 8 deletions(-)
drivers/net/irda/vlsi_ir.c +0 -0
index a04af9d..0319eba 100644
@@ -323,14 +323,9 @@ static void vlsi_proc_ring(struct seq_file *seq, struct vlsi_ring *r)
  		j = (unsigned) rd_get_count(rd);
  		seq_printf(seq, "current: rd = %d / status = %02x / len = %u\n",
  				h, (unsigned)rd_get_status(rd), j);

drivers/net/irda/vlsi_ir.c static void vlsi_proc_ring(struct seq_file *seq, struct vlsi_ring *r) · line 327

Quoted 10 lines
drivers/net/irda/vlsi_ir.c +2 -8
-		if (j > 0) {
-			seq_printf(seq, "   data:");
-			if (j > 20)
-				j = 20;
-			for (i = 0; i < j; i++)
-				seq_printf(seq, " %02x", (unsigned)((unsigned char *)rd->buf)[i]);
-			seq_printf(seq, "\n");
-		}
+		if (j > 0)
+			seq_printf(seq, "   data: %*ph\n", j > 20 ? 20 : j,

Why not min(j, 20)?

drivers/net/irda/vlsi_ir.c static void vlsi_proc_ring(struct seq_file *seq, struct vlsi_ring *r) · line 329

Quoted 2 lines
drivers/net/irda/vlsi_ir.c +1 -0
+				   rd->buf);
  	}

WBR, Sergei

maintainer
#2 lore raw

From: Sergei Shtylyov <[email protected]>
Date: Fri, 05 Sep 2014 21:21:08 +0400

Quoted 5 lines · Andy Shevchenko
Quoted 2 lines

+ seq_printf(seq, " data: %*ph\n", j > 20 ? 20 : j,

   Why not min(j, 20)?

Agreed.