]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
efi/cper: Add a new helper function to print bitmasks
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 14 Aug 2025 16:52:54 +0000 (09:52 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:09:39 +0000 (13:09 +0100)
commit095ebf8277b57b8f283b308f8abcad4eedbbd637
tree18f14a308d10ad40cb68ec96759a81264a830811
parentde9f85fdf7eb975000ad62521e4eba64c7e8b1ab
efi/cper: Add a new helper function to print bitmasks

[ Upstream commit a976d790f49499ccaa0f991788ad8ebf92e7fd5c ]

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@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Acked-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/efi/cper.c
include/linux/cper.h