diff options
| author | Olivier Certner <olce@FreeBSD.org> | 2026-01-29 09:00:02 +0000 |
|---|---|---|
| committer | Olivier Certner <olce@FreeBSD.org> | 2026-02-03 14:03:02 +0000 |
| commit | 4b0e09a918fbcdb3938ecb8e0efc3313bd3b2308 (patch) | |
| tree | 62e43c88822fcdec76e56370eefe4368d3642ca0 | |
| parent | e5f8cbb86d58f25b5ff168506b78d09dca266fb6 (diff) | |
hwpstate_amd(4): Fix BITS_WITH_VALUE()/SET_BITS_VALUE() to obey the mask
While here, rename an argument of BITS_VALUE() to be consistent with the
other macros.
Reviewed by: aokblast
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D54997
| -rw-r--r-- | sys/x86/cpufreq/hwpstate_amd.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/x86/cpufreq/hwpstate_amd.c b/sys/x86/cpufreq/hwpstate_amd.c index 34838753e221..08c833d1a2dd 100644 --- a/sys/x86/cpufreq/hwpstate_amd.c +++ b/sys/x86/cpufreq/hwpstate_amd.c @@ -115,9 +115,11 @@ #define HWP_AMD_CLASSNAME "hwpstate_amd" -#define BITS_VALUE(bits, num) (((num) & (bits)) >> (ffsll((bits)) - 1)) -#define BITS_WITH_VALUE(bits, val) ((uintmax_t)(val) << (ffsll((bits)) - 1)) -#define SET_BITS_VALUE(var, bits, val) \ +#define BITS_VALUE(bits, val) \ + (((val) & (bits)) >> (ffsll((bits)) - 1)) +#define BITS_WITH_VALUE(bits, val) \ + (((uintmax_t)(val) << (ffsll((bits)) - 1)) & (bits)) +#define SET_BITS_VALUE(var, bits, val) \ ((var) = ((var) & ~(bits)) | BITS_WITH_VALUE((bits), (val))) #define HWPSTATE_DEBUG(dev, msg...) \ |
