of_phy_connect(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– of_phy_connect(9) πŸ’–

okay bestie, so this is a page from the Kernel API Manual (section 9, the kernel developer one, iykyk) and it's literally about wiring your network device up to a PHY that the device tree told you about. it's giving "matchmaker but for hardware" πŸŽ€


✨ NAME ✨

of_phy_connect β€” connect to the phy described in the device tree πŸ¦‹


🌸 SYNOPSIS 🌸

struct phy_device * of_phy_connect (struct net_device *dev , struct
       device_node *phy_np , void (*hndlr)(struct net_device *) , u32 flags ,
       phy_interface_t iface );

πŸ’… ARGUMENTS πŸ’…

  • dev β€” pointer to the net_device that's claiming the phy. like, this is the one putting a ring on it πŸ’
  • phy_np β€” pointer to the device tree node for the PHY. your PHY's little birth certificate, fr fr 🌳
  • hndlr β€” the link state callback for the network device. so it can hit you up when the link status changes πŸ“ž
  • flags β€” flags to pass to the PHY 🚩
  • iface β€” the PHY data interface type. the whole vibe check of how data flows πŸ”Œ

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea: if it works, you get back a pointer to the phy_device, and the embedded struct device refcount is incremented by one ✨

if it doesn't work? you get NULL. no cap, that's the failure case 😭

⚠️ bestie listen β€” you must drop that refcount by calling phy_disconnect or phy_detach. don't just leave it hanging, that's leaked refcount energy and it's not cute πŸ’€

πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, periodt πŸ’œ this lil icon lives over in ./drivers/net/mdio, dated October 2026 β€” go off bestie, may your refcounts always balance 🫢🌸

πŸ“¦ where this page comes from