__mdiobus_read(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ __mdiobus_read(9) ✨

okay so this is a page from the Kernel API Manual β€” yes, that manual β€” and today we're talking about __mdiobus_read, the unlocked version of the mdiobus_read function πŸ’… bestie, "unlocked" is doing a LOT of heavy lifting in that sentence, so stay with me.


🌸 SYNOPSIS 🌸

int __mdiobus_read (struct mii_bus *bus , int addr , u32 regnum );

like, that's the whole vibe. three args in, an int out. short and iconic πŸŽ€


πŸ¦‹ ARGUMENTS πŸ¦‹

  • bus β€” the mii_bus struct, aka the whole MDIO bus situation you're working with
  • addr β€” the phy address, i.e. which phy on the bus you're talking to
  • regnum β€” the register number to read, as a u32

πŸ’– RETURN πŸ’–

if everything slays, you get the register value back ✨ if it doesn't, you get a negative error code β€” so like, check for that, don't just assume 😭


🌈 DESCRIPTION 🌈

so what does it actually do? it reads an MDIO bus register. that's it, that's the function 🫢

but here's the part everyone forgets: the caller must hold the mdio bus lock. you. you hold the lock. this function is NOT gonna do it for you β€” that's literally the entire reason it's the __-prefixed one. no cap, that underscore prefix is a whole personality trait πŸ’€


⚠️ NOTE ⚠️

MUST NOT be called from interrupt context. like, do not. not ever. this is not a drill, this is a rule 🚨

πŸ‘‘ SEE ALSO πŸ‘‘

kernel file ./drivers/net/phy/mdio_bus.c β€” go read it, iykyk πŸ“–

that's the whole friend group, fr fr πŸ‘―β€β™€οΈ


and that's the page!! tysm for reading bestie πŸ₯° this little number lives in ./drivers/net/phy, dated October 2026, and it's filed under __mdiobus_read(9) β€” go hold that lock and stay out of interrupt context, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from