__mdiobus_write(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 __mdiobus_write β€” Kernel API Manual, bestie edition 🌸

okay so you're in the kernel API manual, section 9, and the star of the show is __mdiobus_write. hi bestie, let's get into it πŸ’…


✨ NAME ✨

__mdiobus_write β€” the unlocked version of the mdiobus_write function. yes, the double underscore is doing main character work, it means "no lock, i trust you" 🫢


✨ SYNOPSIS ✨

int __mdiobus_write (struct mii_bus *bus , int addr , u32 regnum , u16
       val );

like look at that signature. iconic. no notes πŸ’–


✨ ARGUMENTS ✨

  • bus β€” the mii_bus struct, aka the whole vibe of the bus you're talking to 🚌
  • addr β€” the phy address, so the kernel knows which phy we're having a moment with πŸ‘€
  • regnum β€” register number to write, like the little mailbox slot πŸ“¬
  • val β€” the value to write to regnum, the actual tea being delivered β˜•

✨ RETURN ✨

Zero if successful β€” slay, zero means we ate πŸ’… β€” and a negative error code on failure 😭 (negative = the universe said no).


✨ DESCRIPTION ✨

so basically you're writing a MDIO bus register. that's the whole thing. but here's the catch and it's a big one, bestie: the caller must hold the mdio bus lock. πŸ”’

not "should". not "maybe". must. you're holding the lock, that's the deal. that's literally the entire reason this function exists separate from the locked one πŸ’€


✨ NOTE ✨

MUST NOT be called from interrupt context.

say it with me: MUST NOT. interrupt context is not the vibe for this one, fr fr. do not do it. πŸ™ˆ


✨ SEE ALSO ✨

Kernel file ./drivers/net/phy/mdio_bus.c β€” that's where the source lives if you wanna go read the raw material πŸ“–

and the whole friend group, no cap, all of them:


okay that's the whole page, go forth and hold that lock πŸ’œ

this lil drop came out of ./drivers/net/phy and it's stamped October 2026 β€” mwah, see u in the next release πŸŽ€βœ¨

πŸ“¦ where this page comes from