doc_read_page_getbytes(9)
π 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,NULLis allowed β that literally means "forget the bytes," like you're just reading for the plot and not keeping receipts. πfirstβ1if this is the first time reading, in which caseDOC_READADDRESSshould be set. βlast_oddβ1if 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 π
doc_delay(9)doc_read_data_area(9)doc_write_data_area(9)doc_set_reliable_mode(9)doc_set_asic_mode(9)doc_set_device_id(9)doc_set_extra_page_mode(9)doc_setup_addr_sector(9)doc_setup_writeaddr_sector(9)doc_read_seek(9)doc_write_seek(9)doc_read_page_ecc_init(9)doc_write_page_ecc_init(9)doc_ecc_disable(9)doc_hamming_ecc_init(9)doc_ecc_bch_fix_data(9)doc_read_page_prepare(9)doc_write_page_putbytes(9)doc_get_bch_hw_ecc(9)doc_page_finish(9)doc_read_page_finish(9)calc_block_sector(9)doc_read_oob(9)doc_block_isbad(9)doc_get_erase_count(9)doc_get_op_status(9)doc_write_erase_wait_status(9)doc_erase_block(9)doc_erase(9)doc_write_page(9)doc_guess_autoecc(9)doc_fill_autooob(9)doc_backup_oob(9)doc_write_oob(9)doc_set_driver_info(9)doc_probe_device(9)doc_release_device(9)docg3_resume(9)docg3_suspend(9)docg3_probe(9)docg3_release(9)
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
- 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