Skip to contentSkip to conversation

mfd: ipaq-micro: Use %*ph for printing hexdump of a small buffer

PATCH Applied Andy Shevchenko 2 participants 3 messages Jul 3, 2023 – Jul 13, 2023 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 mfd: ipaq-micro: Use %*ph for printing hexdump of a small buffer

The kernel already has a helper to print a hexdump of a small buffer via pointer extension. Use that instead of open coded variant.

In long term it helps to kill pr_cont() or at least narrow down its use.

---
v2: split another change to a separate patch (Lee)

 drivers/mfd/ipaq-micro.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/mfd/ipaq-micro.c +1 -4
index 6d3968458e81..cddfd2e808f2 100644
@@ -131,10 +131,7 @@ static void micro_rx_msg(struct ipaq_micro *micro, u8 id, int len, u8 *data)
 		break;
 	default:
 		dev_err(micro->dev,
-			"unknown msg %d [%d] ", id, len);
-		for (i = 0; i < len; ++i)
-			pr_cont("0x%02x ", data[i]);
-		pr_cont("\n");
+			"unknown msg %d [%d] %*ph\n", id, len, len, data);
 	}
 	spin_unlock(&micro->lock);
 }
Signature · 1 line
2.40.0.1.gaa8946217a0b
#1 lore raw

PATCH v2 2/2 mfd: ipaq-micro: Add missing break for the default case

Even default case should have a break statement to make code robust against changes (e.g., adding a case after the default one).

Add missing break for the default case.
---
v2: new patch

 drivers/mfd/ipaq-micro.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mfd/ipaq-micro.c +1 -0
index cddfd2e808f2..57fb7874fc91 100644
@@ -132,6 +132,7 @@ static void micro_rx_msg(struct ipaq_micro *micro, u8 id, int len, u8 *data)
 	default:
 		dev_err(micro->dev,
 			"unknown msg %d [%d] %*ph\n", id, len, len, data);
+		break;
 	}
 	spin_unlock(&micro->lock);
 }
Signature · 1 line
2.40.0.1.gaa8946217a0b
maintainer Applied
#2 lore raw
In reply to Andy Shevchenko
Quoted 4 lines · Andy Shevchenko

The kernel already has a helper to print a hexdump of a small buffer via pointer extension. Use that instead of open coded variant.

Quoted 8 lines

In long term it helps to kill pr_cont() or at least narrow down its use.

---
v2: split another change to a separate patch (Lee)

 drivers/mfd/ipaq-micro.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]