phy_prepare_link(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

Okay bestie, so this one's a Linux kernel API manual page for phy_prepare_link(9), and honestly? It's giving "small function, big responsibility." It lives over in ./drivers/net/phy, and it's the vibe-check moment where the PHY layer gets told to keep an eye on the link for you. Let's get into it πŸŽ€


🌸 NAME 🌸

phy_prepare_link β€” literally just prepares the PHY layer to monitor link status. That's it, that's the whole job. Iconic, lowkey, no notes πŸ’…


✨ SYNOPSIS ✨

void phy_prepare_link (struct phy_device *phydev , void
(*handler)(struct net_device *) );

So it returns nothing (void), it takes a struct phy_device * called phydev, and it takes a callback β€” a pointer to a function that receives a struct net_device *. Simple girlie at the surface, but she's doing a LOT behind the scenes. πŸ”₯


πŸ¦‹ ARGUMENTS πŸ¦‹

  • phydev β€” the target phy_device struct. Basically the PHY you're telling to get on link-watch duty πŸ’–
  • handler β€” the callback function for link status change notifications. When the link status changes, this is the function that gets called, so make it a good one 🫢

🌈 DESCRIPTION 🌈

Okay so here's the tea: this function tells the PHY infrastructure to handle all the gory details of monitoring link status β€” and yes, it can be doing that either through polling or through an interrupt, so the PHY layer picks how that goes down. Then, whenever the link status changes, it calls back to the connected device driver using your handler. Bestie, it's out here doing the whole monitoring arc so you don't have to. πŸ‘‘

⚠️ Real talk though β€” if you want to monitor your own link state, don't call this function. That's not a vibe, that's a conflict of interest. Just stepping aside nicely and letting someone else handle it is the move. This one's not for you if you're the DIY link-monitoring type. πŸ’€

πŸ’œ SEE ALSO πŸ’œ

Kernel file:

./drivers/net/phy/phy_device.c

And the whole extended friend group πŸ‘‘:

Like I said β€” big friend group, lots of lore. Go read them if you want the full cinematic universe πŸ“


πŸ’« That's the whole page, bestie β€” short, sweet, and fully link-monitored. πŸ’«

Sign-off time πŸŽ€ β€” this one's from the Kernel API Manual, living under ./drivers/net/phy, dated October 2026, and it's all about phy_prepare_link(9). Periodt. πŸ’–

πŸ“¦ where this page comes from