FIELD_PREP_WM16(9)
π FIELD_PREP_WM16 (kernel API manual, bestie) π
okay so picture this: you're deep in the kernel, you've got a bitfield, and the mask is doing that thing where it lives in the upper half of the register. yeah. this macro is literally the girl for that job. it lives in the Kernel API Manual and it's about to make your register writes iconic β¨
π NAME π
FIELD_PREP_WM16 β prepare a bitfield element with a mask in the upper half π«Ά
β¨ SYNOPSIS β¨
FIELD_PREP_WM16 (_mask , _val );
no cap, that's the whole signature. two args, zero drama πΈ
π§ ARGUMENTS π§
_maskβ the shifted mask that defines the field's length and its position. it's giving "boundaries, but make it bitwise" π_valβ the value you're putting in the field. main character energy, but it has to fit the mask's vibe π
π₯ DESCRIPTION π₯
so what does it actually do? FIELD_PREP_WM16 masks and shifts up the value, and then bitwise ORs that result with the mask shifted up by 16. yes, both. it's an overachiever, we love her π
this is highkey useful for a super common hardware register design where the upper 16-bit half of a 32-bit register is used as a write-enable mask. in that kind of register, a bit in the lower half is only updated if the corresponding bit in the upper half is high. so likeβ¦ the top half is the bouncer and the bottom half only gets in if the bouncer says yes ππͺ
fr fr, remember: lower-half bit updates are gated by the upper-half bit. that's the whole point of the design, don't sleep on it β
π SEE ALSO π
- Kernel file
./include/linux/hw_bitfield.hβ go read the source, iykyk π¦ FIELD_PREP_WM16_CONST(9)β the const sibling, she's also slaying β¨
and that's the whole page, bestie π this one came from the ./include/linux crew, dated October 2026, page FIELD_PREP_WM16(9) β go forth and prep those fields π«Άππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms