REG_FIELD_PREP(9)
π REG_FIELD_PREP(9) β like, the Kernel API Manual one, bestie
okay so picture this: you're deep in the kernel, you've got a u32 bitfield, and you need a value prepared for it. That's literally the whole gig. Welcome to REG_FIELD_PREP from the Kernel API Manual, she's iconic, she's in ./include/drm/intel/reg_bits.h, let's go β¨
β¨ SYNOPSIS β¨
REG_FIELD_PREP (__mask , __val );
two args, no drama π
πΈ ARGUMENTS πΈ
__maskβ the shifted mask, bestie. It's the thing that defines your field's length and its position. mask is the blueprint, fr fr.__valβ the actual value you're putting in that field. the main character of the operation π
π DESCRIPTION π
so this is a local copy of FIELD_PREP β yes, a copy, we live here now β and it exists to do three very specific things, no cap:
- generate an integer constant expression,
- force
u32, because we said so, - stay consistent with
REG_FIELD_GET,REG_BITandREG_GENMASK. the friend group has to match, obviously π«Ά
that's it, that's the vibe check. π
π₯ RETURN π₯
__val β but masked and shifted into the field defined by __mask. so it comes back all glowed-up and field-shaped. slay.
π SEE ALSO π
all of these live in the kernel file ./include/drm/intel/reg_bits.h, and they're all in the group chat:
REG_FIELD_PREP8(9)REG_FIELD_PREP16(9)REG_FIELD_GET8(9)REG_FIELD_GET(9)REG_FIELD_GET64(9)REG_FIELD_MAX(9)
go read them, iykyk π
ngl this page is short and sweet and that's the point β don't overthink it, just mask and shift π¦
okay bye, this page was brought to you by <pink>./include/drm/intel</pink> in <purple>October 2026</purple> β mwah, take care of her ππβ¨
π¦ 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