public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] mfd: ipaq-micro: Use %*ph for printing hexdump of a small buffer
@ 2023-07-03 14:09 Andy Shevchenko
  2023-07-03 14:09 ` [PATCH v2 2/2] mfd: ipaq-micro: Add missing break for the default case Andy Shevchenko
  2023-07-13 10:20 ` [PATCH v2 1/2] mfd: ipaq-micro: Use %*ph for printing hexdump of a small buffer Lee Jones
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-07-03 14:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lee Jones, 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.

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: split another change to a separate patch (Lee)
 drivers/mfd/ipaq-micro.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/mfd/ipaq-micro.c b/drivers/mfd/ipaq-micro.c
index 6d3968458e81..cddfd2e808f2 100644
--- a/drivers/mfd/ipaq-micro.c
+++ b/drivers/mfd/ipaq-micro.c
@@ -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);
 }
-- 
2.40.0.1.gaa8946217a0b


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] mfd: ipaq-micro: Add missing break for the default case
  2023-07-03 14:09 [PATCH v2 1/2] mfd: ipaq-micro: Use %*ph for printing hexdump of a small buffer Andy Shevchenko
@ 2023-07-03 14:09 ` Andy Shevchenko
  2023-07-13 10:20 ` [PATCH v2 1/2] mfd: ipaq-micro: Use %*ph for printing hexdump of a small buffer Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-07-03 14:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lee Jones, Andy Shevchenko

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(+)

diff --git a/drivers/mfd/ipaq-micro.c b/drivers/mfd/ipaq-micro.c
index cddfd2e808f2..57fb7874fc91 100644
--- a/drivers/mfd/ipaq-micro.c
+++ b/drivers/mfd/ipaq-micro.c
@@ -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);
 }
-- 
2.40.0.1.gaa8946217a0b


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/2] mfd: ipaq-micro: Use %*ph for printing hexdump of a small buffer
  2023-07-03 14:09 [PATCH v2 1/2] mfd: ipaq-micro: Use %*ph for printing hexdump of a small buffer Andy Shevchenko
  2023-07-03 14:09 ` [PATCH v2 2/2] mfd: ipaq-micro: Add missing break for the default case Andy Shevchenko
@ 2023-07-13 10:20 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2023-07-13 10:20 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel

On Mon, 03 Jul 2023, Andy Shevchenko wrote:

> 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.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v2: split another change to a separate patch (Lee)
>  drivers/mfd/ipaq-micro.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)

Applied, thanks

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-13 10:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-03 14:09 [PATCH v2 1/2] mfd: ipaq-micro: Use %*ph for printing hexdump of a small buffer Andy Shevchenko
2023-07-03 14:09 ` [PATCH v2 2/2] mfd: ipaq-micro: Add missing break for the default case Andy Shevchenko
2023-07-13 10:20 ` [PATCH v2 1/2] mfd: ipaq-micro: Use %*ph for printing hexdump of a small buffer Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox