Re: [PATCH v6] lib/vsprintf: Add support for generic FourCCs by extending %p4cc

From: Aditya Garg
Date: Wed Mar 05 2025 - 06:57:31 EST




> On 2 Mar 2025, at 7:12 AM, Aditya Garg <gargaditya08@xxxxxxxx> wrote:
>
> From: Hector Martin <marcan@xxxxxxxxx>
>
> %p4cc is designed for DRM/V4L2 FourCCs with their specific quirks, but
> it's useful to be able to print generic 4-character codes formatted as
> an integer. Extend it to add format specifiers for printing generic
> 32-bit FourCCs with various endian semantics:
>
> %p4ch Host byte order
> %p4cn Network byte order
> %p4cl Little-endian
> %p4cb Big-endian
>
> The endianness determines how bytes are interpreted as a u32, and the
> FourCC is then always printed MSByte-first (this is the opposite of
> V4L/DRM FourCCs). This covers most practical cases, e.g. %p4cn would
> allow printing LSByte-first FourCCs stored in host endian order
> (other than the hex form being in character order, not the integer
> value).
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> Signed-off-by: Hector Martin <marcan@xxxxxxxxx>
> Signed-off-by: Aditya Garg <gargaditya08@xxxxxxxx>
>

FWIW, Rasmus had acked this patch in my v3 submission [1] , I forgot to put it. So,

Acked-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>

[1] https://lore.kernel.org/asahi/CAKwiHFi_nngthth0wZkaPviVeS+8SWDtTw6gJcDAHCqiwXAG2A@xxxxxxxxxxxxxx/