ux500_swap_bits_in_byte(9)
β¨ ux500_swap_bits_in_byte(9) β¨
okay bestie, so this one is from the Kernel API Manual and it's literally the cutest little bit-shuffler ever. we're talking ux500_swap_bits_in_byte β it mirrors the bits in a byte π¦ like, full reverse-glow-up for your 8 little bits. no cap.
πΈ SYNOPSIS πΈ
u8 ux500_swap_bits_in_byte (u8 b );
that's it. that's the whole vibe. one byte in, one byte out. π
π ARGUMENTS π
bβ the byte that's about to get mirrored. it's the main character of this whole operation, give it a little respect π«Ά
π DESCRIPTION π
so the bits get swapped like this, and honestly the way that it works is kind of iconic. so b includes bits 0-7, right? then nibble 1 (n1) holds bits 0-3 and nibble 2 (n2) holds bits 4-7. two lil nibbles, each living their own life π
π§ Nibble 1 (n1)
heads up bestie: the "old" (moved) bit gets replaced with a zero. so like, it does not survive the move, okay? it's giving farewell tour π
- Move bit 6 and 7, 4 positions to the left.
- Move bit 3 and 5, 2 positions to the left.
- Move bit 1-4, 1 position to the left.
π§ Nibble 2 (n2)
- Move bit 0 and 1, 4 positions to the right.
- Move bit 2 and 4, 2 positions to the right.
- Move bit 3-6, 1 position to the right.
then you combine the two nibbles into one complete, fully swapped byte. that's the finale β¨ the two halves reunite and it's beautiful. reunion episode energy fr fr ππ
π¦ SEE ALSO π¦
- Kernel file
./drivers/crypto/stm32/stm32-cryp.c ux500_swizzle_key(9)β the sibling, obviously π
signed off with love from the ./drivers/crypto/stm32 corner of the kernel π
that's October 2026 energy for ya π
π¦ 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