STRUCT REGBIT(9)
π struct regbit(9) β Kernel API Manual, bestie edition π
okay so bestie, welcome to the glow-up of the struct regbit manpage, from the Kernel API Manual. this one's short but she's iconic β a whole tiny struct that exists to pack one single bit into as few bytes as possible. main character energy fr fr β¨
π¦ NAME π¦
struct regbit β describe one bit in a register π«
like, literally just one bit. one. tiny. bit. and this struct is the whole personality β¨
πΈ SYNOPSIS πΈ
struct regbit {
u16 bit:5;
u16 reg:11;
};
that's her!! that's the whole struct!! and yes the original has that little space before the closing }; β keeping it exactly as it is, character for character, because we respect the source π
π Members π
bitβ which bit (0 to 31) in the register π§ lowkey the whole point of the struct nglregβ offset of register relative to base address, expressed in units of 32-bit words (not bytes), β οΈ not bytes β οΈ β this is the detail everyone gets wrong, iykyk
π₯ Description π₯
so the whole point of this structure is that it's used to compactly encode the location of a single bit in a register π«Ά like, she's not here to be spacious, she's here to be snatched.
here's the math bestie, and it's giving bit-budget: five bits are needed to encode the bit number. and with the uint16_t data type, that leaves 11 bits to encode a register offset up to 2047 π
and because registers are aligned on 32-bit boundaries, the offset gets specified in 32-bit words rather than bytes π which means you can encode an offset up to 0x1FFC (8188) bytes. yes both numbers. no we're not rounding. we don't do that here π
and the helper macro RB takes care of converting the register offset from bytes to 32-bit words for you, because she's a queen and she handles the messy part π
β¨
β SEE ALSO β
- Kernel file
./drivers/clk/renesas/r9a06g032-clocks.cstructr9a06g032_gate(9), structr9a06g032_clkdesc(9)π¦
go read those next, bestie, they're in the same friend group π
ngl this struct is tiny but she ate. packing a bit number AND a register offset into 16 bits? obsessed. π
and that's the page!! πΈ sign-off time: this one lives over at ./drivers/clk/renesas, dated October 2026 β so she's fresh, she's Reneasas-adjacent, and she's ready for you. mwah πππ
π¦ 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