Re: [PATCH v4 3/5] efi/cper: Add a new helper function to print bitmasks
From: Jonathan Cameron
Date: Fri Aug 08 2025 - 11:25:16 EST
On Tue, 05 Aug 2025 11:35:40 -0700
Daniel Ferguson <danielf@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> From: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>
>
> Add a helper function to print a string with names associated
> to each bit field.
>
> A typical example is:
>
> const char * const bits[] = {
> "bit 3 name",
> "bit 4 name",
> "bit 5 name",
> };
> char str[120];
> unsigned int bitmask = BIT(3) | BIT(5);
>
> #define MASK GENMASK(5,3)
>
> cper_bits_to_str(str, sizeof(str), FIELD_GET(MASK, bitmask),
> bits, ARRAY_SIZE(bits));
>
> The above code fills string "str" with "bit 3 name|bit 5 name".
>
> Reviewed-by; Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
>
oops. That was probably my mess up. Please fix that ; to : and
put it in the right place.
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>
> Acked-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>