STRUCT PHY_OPS(9)
π struct phy_ops(9) β the kernel API manual, bestie edition
okay so picture this: it's struct phy_ops(9) from the Kernel API Manual, and it's literally just a big ol' bundle of function pointers for doing phy operations. that's it. that's the whole vibe. think of it as the group chat of callbacks a phy driver signs up for β every member is a little "hey bestie can you handle this for me" π«Ά
β¨ NAME β¨
struct phy_ops β the set of function pointers for performing phy operations. no cap, that's the entire job description π
πΈ SYNOPSIS πΈ
struct phy_ops {
int (*init)(struct phy *phy);
int (*exit)(struct phy *phy);
int (*power_on)(struct phy *phy);
int (*power_off)(struct phy *phy);
int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
int (*set_media)(struct phy *phy, enum phy_media media);
int (*set_speed)(struct phy *phy, int speed);
int (*configure)(struct phy *phy, union phy_configure_opts *opts);
int (*validate)(struct phy *phy, enum phy_mode mode, int submode,
union phy_configure_opts *opts);
int (*reset)(struct phy *phy);
int (*calibrate)(struct phy *phy);
int (*connect)(struct phy *phy, int port);
int (*disconnect)(struct phy *phy, int port);
int (*notify_phystate)(struct phy *phy, union phy_notify state);
void (*release)(struct phy *phy);
struct module *owner;
};
look at all those little pointer besties lined up. iconic lineup honestly π
π¦ Members π¦
okay let's go down the list one by one, i gotchu:
initβ the operation to be performed for initializing the phy. the "hi nice to meet you" moment β¨exitβ the operation to be performed while exiting. the goodbye, the "ok bye love you" πpower_onβ powering on the phy. waking it up, giving it a little stretch π₯power_offβ powering off the phy. nap time fr fr π΄set_modeβ set the mode of the phy. main character energy, choose your era π«set_mediaβ set the media type of the phy (optional). lowkey optional, highkey useful πset_speedβ set the speed of the phy (optional). also optional! zoom zoom βconfigureβ Optional.
Used to change the PHY parameters. phy_init must have been called on the phy first β like, no skipping steps bestie, that's the whole prerequisite π«Ά
Returns: 0 if successful, an negative error code otherwise. (yes it says "an negative", i'm just the messenger π)
validateβ Optional.
Used to check that the current set of parameters can be handled by the phy. implementations are free to tune the parameters passed as arguments if needed by some implementation detail or constraints. important part: it must not change any actual configuration of the PHY β so calling it as many times as deemed fit by the consumer must have no side effect. it's giving "look but don't touch" π
Returns: 0 if the configuration can be applied, an negative error code otherwise.
resetβ resetting the phy. factory reset but make it cute πcalibrateβ calibrate the phy. tuning it up until it's serving exactly right πnotify_phystateβ notify and configure the phy for a particular state. it does both!! overachiever behavior πreleaseβ ops to be performed while the consumer relinquishes the PHY. the hand-it-back moment π«΄ownerβ the module owner containing the ops. every struct needs a parent, periodt.
ngl the synopsis also showsconnect(takesstruct phy *phyandint port) anddisconnect(same signature) β and the members list here does not spell out what they do. so i'm not gonna make anything up. they're in the struct, that's what we know, iykyk π§
π SEE ALSO π
- Kernel file
./include/linux/phy/phy.h union phy_configure_opts(9)struct phy_attrs(9)struct phy(9)struct phy_provider(9)struct phy_lookup(9)
go read those too, they're all friends of this struct and they all slay πΈ
that's the whole page bestie, you ate it up π and before you go β this cutie lives at ./include/linux/phy, dated October 2026, and yeah it's struct phy_ops(9), we been knew π¦ mwah, go write some slay callbacks β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms