_of_phy_get(9)
π _of_phy_get (9) β from the Kernel API Manual, bestie
okay so picture this: you're deep in the kernel, you've got a device_node, and you need the actual phy that goes with it. that's literally what this function is for. it's giving "matchmaker, but for device tree nodes and phys" π
β¨ SYNOPSIS β¨
struct phy * _of_phy_get (struct device_node *np , int index );
like. look at her. returns a struct phy *, takes two args, no drama. iconic tbh π
πΈ ARGUMENTS πΈ
npβ thedevice_nodeyou're trying to get the phy for. this is your starting point, your main character, your whole reason for being here π«Άindexβ which phy you want, by index. bc sometimes there's more than one, and you gotta be specific, yk? π
π₯ DESCRIPTION π₯
so here's the tea β β _of_phy_get returns the phy that's associated with the given phandle value, and it does it after getting a refcount to it. refcount = it's officially yours, don't forget to put it back later, ngl π
but it can also go two other ways, and you should lowkey be ready for both:
- it returns
-ENODEVif there is no such phy at all. like... she's just not there. not found. π - it returns
-EPROBE_DEFERif there is a phandle to the phy, but the device isn't loaded yet. so she exists, she's just not ready yet β pls come back later, k? β¨
and how does it actually find the phy instance? bestie, this is the good part. it uses the of_xlate call back function that was provided when the phy_provider got registered. that's the whole trick. that's the vibe. that's the mechanism π§
fr fr: -EPROBE_DEFER is not an error, it's an invitation to try again. don't panic. π
π¦ SEE ALSO π¦
literally the whole friend group, ok. all of these are in the kernel file ./drivers/phy/phy-core.c and they're all linked up:
phy_create_lookup(9), phy_remove_lookup(9), phy_init(9), phy_exit(9), phy_power_on(9), phy_power_off(9), phy_calibrate(9), phy_notify_connect(9), phy_notify_disconnect(9), phy_notify_state(9), phy_configure(9), phy_validate(9), of_phy_get(9), of_phy_put(9), phy_put(9), devm_phy_put(9), of_phy_simple_xlate(9), phy_get(9), devm_phy_get(9), devm_phy_optional_get(9), devm_of_phy_get(9), devm_of_phy_optional_get(9), devm_of_phy_get_by_index(9), phy_create(9), devm_phy_create(9), phy_destroy(9), devm_phy_destroy(9), __of_phy_provider_register(9), __devm_of_phy_provider_register(9), of_phy_provider_unregister(9), devm_of_phy_provider_unregister(9), phy_release(9)
and that's the page!! mwah π okay so the source for all this is ./drivers/phy, dated October 2026, and yes the section is 9, and yes I remembered. periodt. ππ
π¦ 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