public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] input: byd: use %*ph for Z packet dump
@ 2025-12-02  3:31 Vivek BalachandharTN
  2025-12-09  5:43 ` Dmitry Torokhov
  2026-01-14  7:37 ` Andy Shevchenko
  0 siblings, 2 replies; 5+ messages in thread
From: Vivek BalachandharTN @ 2025-12-02  3:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, Thomas Gleixner, Ingo Molnar,
	Vivek Balachandhar TN

Replace the hand-rolled %02x formatting of the Z packet warning in the
BYD driver with the %*ph format specifier. %*ph is the preferred helper
for printing a buffer in hexadecimal and makes the logging clearer and
more consistent.

Signed-off-by: Vivek BalachandharTN <vivek.balachandhar@gmail.com>
---
 drivers/input/mouse/byd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c
index 71aa23dd7d8d..a1420f03f3b3 100644
--- a/drivers/input/mouse/byd.c
+++ b/drivers/input/mouse/byd.c
@@ -315,9 +315,8 @@ static psmouse_ret_t byd_process_byte(struct psmouse *psmouse)
 	}
 	default:
 		psmouse_warn(psmouse,
-			     "Unrecognized Z: pkt = %02x %02x %02x %02x\n",
-			     psmouse->packet[0], psmouse->packet[1],
-			     psmouse->packet[2], psmouse->packet[3]);
+			     "Unrecognized Z: pkt = %*ph\n",
+			     4, psmouse->packet);
 		return PSMOUSE_BAD_DATA;
 	}
 
-- 
2.34.1


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

* Re: [PATCH] input: byd: use %*ph for Z packet dump
  2025-12-02  3:31 [PATCH] input: byd: use %*ph for Z packet dump Vivek BalachandharTN
@ 2025-12-09  5:43 ` Dmitry Torokhov
  2026-01-14  7:37 ` Andy Shevchenko
  1 sibling, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2025-12-09  5:43 UTC (permalink / raw)
  To: Vivek BalachandharTN
  Cc: linux-input, linux-kernel, Thomas Gleixner, Ingo Molnar

On Tue, Dec 02, 2025 at 03:31:20AM +0000, Vivek BalachandharTN wrote:
> Replace the hand-rolled %02x formatting of the Z packet warning in the
> BYD driver with the %*ph format specifier. %*ph is the preferred helper
> for printing a buffer in hexadecimal and makes the logging clearer and
> more consistent.
> 
> Signed-off-by: Vivek BalachandharTN <vivek.balachandhar@gmail.com>

Applied, thank you.

-- 
Dmitry

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

* Re: [PATCH] input: byd: use %*ph for Z packet dump
  2025-12-02  3:31 [PATCH] input: byd: use %*ph for Z packet dump Vivek BalachandharTN
  2025-12-09  5:43 ` Dmitry Torokhov
@ 2026-01-14  7:37 ` Andy Shevchenko
  2026-01-14  8:49   ` Vivek BalachandharTN
  1 sibling, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2026-01-14  7:37 UTC (permalink / raw)
  To: Vivek BalachandharTN
  Cc: Dmitry Torokhov, linux-input, linux-kernel, Thomas Gleixner,
	Ingo Molnar

On Tue, Dec 02, 2025 at 03:31:20AM +0000, Vivek BalachandharTN wrote:
> Replace the hand-rolled %02x formatting of the Z packet warning in the
> BYD driver with the %*ph format specifier. %*ph is the preferred helper
> for printing a buffer in hexadecimal and makes the logging clearer and
> more consistent.

You probably took one of the oldest examples of such a conversion done in
the input subsystem.

> +			     "Unrecognized Z: pkt = %*ph\n",
> +			     4, psmouse->packet);

The (not-so-critical) problem here is the stack consumption and additional work
for the printf() to parse '*'. To optimise that, static field widths may be
embedded in the format strings

			     "Unrecognized Z: pkt = %4ph\n",
			     psmouse->packet);

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] input: byd: use %*ph for Z packet dump
  2026-01-14  7:37 ` Andy Shevchenko
@ 2026-01-14  8:49   ` Vivek BalachandharTN
  2026-01-14  8:53     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Vivek BalachandharTN @ 2026-01-14  8:49 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Dmitry Torokhov, linux-input, linux-kernel, Thomas Gleixner,
	Ingo Molnar

Thanks Andy — good point. Packet length is fixed here, so |%4ph| is 
better. I’ll follow this pattern in future patches (and can send a small 
follow-up to adjust this one if desired).


Best, Vivek

On 2026-01-14 3:37 a.m., Andy Shevchenko wrote:
> On Tue, Dec 02, 2025 at 03:31:20AM +0000, Vivek BalachandharTN wrote:
>> Replace the hand-rolled %02x formatting of the Z packet warning in the
>> BYD driver with the %*ph format specifier. %*ph is the preferred helper
>> for printing a buffer in hexadecimal and makes the logging clearer and
>> more consistent.
> You probably took one of the oldest examples of such a conversion done in
> the input subsystem.
>
>> +			     "Unrecognized Z: pkt = %*ph\n",
>> +			     4, psmouse->packet);
> The (not-so-critical) problem here is the stack consumption and additional work
> for the printf() to parse '*'. To optimise that, static field widths may be
> embedded in the format strings
>
> 			     "Unrecognized Z: pkt = %4ph\n",
> 			     psmouse->packet);
>

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

* Re: [PATCH] input: byd: use %*ph for Z packet dump
  2026-01-14  8:49   ` Vivek BalachandharTN
@ 2026-01-14  8:53     ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-01-14  8:53 UTC (permalink / raw)
  To: Vivek BalachandharTN
  Cc: Dmitry Torokhov, linux-input, linux-kernel, Thomas Gleixner,
	Ingo Molnar

On Wed, Jan 14, 2026 at 04:49:32AM -0400, Vivek BalachandharTN wrote:
> Thanks Andy — good point. Packet length is fixed here, so |%4ph| is better.
> I’ll follow this pattern in future patches (and can send a small follow-up
> to adjust this one if desired).

You can find all such places in input subsystem and convert them all
(1 patch per subfolder probably, 1 for keyboard/*, 1 for mouse/*, ...).

P.S. And do not top-post!

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-01-14  8:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02  3:31 [PATCH] input: byd: use %*ph for Z packet dump Vivek BalachandharTN
2025-12-09  5:43 ` Dmitry Torokhov
2026-01-14  7:37 ` Andy Shevchenko
2026-01-14  8:49   ` Vivek BalachandharTN
2026-01-14  8:53     ` Andy Shevchenko

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