doc_read_page_getbytes(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… doc_read_page_getbytes β€” Kernel API Manual, bestie edition ✨

okay so you found a kernel doc page and you're like "what is this" β€” don't worry, I got you. this one is doc_read_page_getbytes, straight out of the Kernel API Manual, and it's giving "niche MTD driver lore" but honestly? kinda iconic.


🌸 NAME 🌸

doc_read_page_getbytes β€” reads bytes from a prepared page. that's it. that's the whole vibe. πŸŽ€


✨ SYNOPSIS ✨

int doc_read_page_getbytes (struct docg3 *docg3 , int len , u_char *buf
, int first , int last_odd );

five arguments, one int coming back at you. she's compact. πŸ’…


🫢 ARGUMENTS 🫢

  • docg3 β€” the device. your main character. the whole reason we're here. πŸ‘‘
  • len β€” how many bytes you wanna read. ⚠️ must be a multiple of 4 β€” do not test her on this, fr fr.
  • buf β€” the buffer getting filled in. and yes, NULL is allowed β€” that literally means "forget the bytes," like you're just reading for the plot and not keeping receipts. πŸ™ˆ
  • first β€” 1 if this is the first time reading, in which case DOC_READADDRESS should be set. ⭐
  • last_odd β€” 1 if the last read ended up on an odd byte. she's a little quirky like that. πŸ¦‹

πŸ’– DESCRIPTION πŸ’–

so this function reads bytes from a prepared page. sounds simple, right? no. there's trickery here and I need you to pay attention bestie 😭

here's the situation: if the last read ended up on an odd offset in the 1024 bytes double page β€” that is, between the 2 planes β€” then the first byte has to be read apart. like, separately. on its own. no friends. 🧚

and why? because if a word (16bit) read was used, the read would return the byte of plane 2 as low and high endian, which will mess the read. πŸ’€ so yeah. don't do that. that's the whole trickery. noted and respected.

this is one of those "the hardware said no" situations and the code had to get creative. lowkey obsessed with the workaround ngl.

πŸ”₯ SEE ALSO πŸ”₯

a truly unserious amount of friends. she knows everybody. kernel file ./drivers/mtd/devices/docg3.c β€” go say hi πŸ’œ


and that's the page!! πŸ’… this lil icon lives in ./drivers/mtd/devices and the doc is dated October 2026 β€” go off, calendar. mwah, bye bestie 🫢✨

πŸ“¦ where this page comes from