]> git.ipfire.org Git - thirdparty/linux.git/commit
x86/cacheinfo: Use enums for cache descriptor types
authorAhmed S. Darwish <darwi@linutronix.de>
Mon, 24 Mar 2025 13:33:13 +0000 (14:33 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 25 Mar 2025 09:22:56 +0000 (10:22 +0100)
commite1e6b57146554a321d0ed1e76d2839ac24117f26
treea9eeb2baa82e6410b184e271b189e76d420a167b
parent7596ab7a107bf70d571d75ad6ae078127f5ea11b
x86/cacheinfo: Use enums for cache descriptor types

The leaf 0x2 one-byte cache descriptor types:

CACHE_L1_INST
CACHE_L1_DATA
CACHE_L2
CACHE_L3

are just discriminators to be used within the cache_table[] mapping.
Their specific values are irrelevant.

Use enums for such types.

Make the enum packed and static assert that its values remain within a
single byte so that the cache_table[] array size do not go out of hand.

Use a __CHECKER__ guard for the static_assert(sizeof(enum) == 1) line as
sparse ignores the __packed annotation on enums.

This is similar to:

  fe3944fb245a ("fs: Move enum rw_hint into a new header file")

for the core SCSI code.

Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/Z9rsTirs9lLfEPD9@lx-t490
Link: https://lore.kernel.org/r/20250324133324.23458-19-darwi@linutronix.de
arch/x86/include/asm/cpuid/types.h
arch/x86/kernel/cpu/cacheinfo.c