get_phy_device(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– get_phy_device(9) β€” Kernel API Manual πŸ’–

okay so bestie, welcome to the glow-up of get_phy_device from the Kernel API Manual β€” she reads the PHY device you point at and hands you back her @phy_device struct. genuinely iconic behaviour. let's get into it 🫢


✨ SYNOPSIS ✨

struct phy_device * get_phy_device (struct mii_bus *bus , int addr ,
       bool is_c45 );

πŸŽ€ ARGUMENTS πŸŽ€

  • bus β€” the target MII bus. like, the bus she's gonna go snoop on ✨
  • addr β€” PHY address on the MII bus. that's where on the bus, bestie πŸ“
  • is_c45 β€” if this is true, the PHY uses the 802.3 clause 45 protocol. true = clause 45 energy, false = not that πŸ’…

🌸 DESCRIPTION 🌸

So the whole vibe is: probe for a PHY at addr on bus. that's the assignment, and she ate.

When you're probing for a clause 22 PHY, she reads the ID registers. if we find a valid ID, she allocates and returns a struct phy_device. periodt πŸ’…

When you're probing for a clause 45 PHY, she reads the "devices in package" registers. if the "devices in package" appears valid, she reads the ID registers for each MMD, then allocates and returns a struct phy_device. multiple MMDs, one struct, no notes πŸ¦‹

And what does she give back? listen closely bestie:

  • an allocated struct phy_device on success πŸ‘‘
  • -ENODEV if there is no PHY present 😭
  • -EIO on bus access error πŸ’€
ngl, those two error codes matter β€” -ENODEV means "nobody home", -EIO means "the bus itself fumbled". don't mix them up fr fr.

🌈 SEE ALSO 🌈

Kernel file ./drivers/net/phy/phy_device.c, plus this whole friend group of (9) pages β€” every single one, no skipping 🧚:


that's the whole page, bestie β€” go probe something valid πŸ’–

source/version: ./drivers/net/phy · dated October 2026 · and yeah, the title up top is get_phy_device(9), slay 🌟
πŸ“¦ where this page comes from