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
This commit is contained in:
Olivier Certner
2026-01-29 10:00:02 +01:00
parent e5f8cbb86d
commit 4b0e09a918
+5 -3
View File
@@ -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...) \