STRUCT DEVICE_LINK(9)
π struct device_link(9) π
okay bestie, welcome to the Kernel API Manual β¨ β today's main character is struct device_link, and honestly? it's giving relationship goals but make it kernel plumbing π«Ά this little struct is literally the representation of a device link, and we're gonna go through it line by line, no cap π
πΈ NAME πΈ
struct device_link β Device link representation. β¨
π SYNOPSIS π
like, here's the whole vibe, verbatim, do not touch the formatting bestie π
struct device_link {
struct device *supplier;
struct list_head s_node;
struct device *consumer;
struct list_head c_node;
struct device link_dev;
enum device_link_state status;
u32 flags;
refcount_t rpm_active;
struct kref kref;
struct work_struct rm_work;
bool supplier_preactivated;
};
π Members π
okay so each of these fields has lore, and we're gonna respect the lore π§
supplierβ the device on the supplier end of the link. like, the one doing the supplying πs_nodeβ hook to the supplier device's list of links to consumers. it's the supplier's little hookup list π₯consumerβ the device on the consumer end of the link. the one receiving, the one being fed πc_nodeβ hook to the consumer device's list of links to suppliers. same energy, other direction βlink_devβ device used to expose link details in sysfs. yes, sysfs gets to peek πstatusβ the state of the link (with respect to the presence of drivers). the whole driver-presence vibe check πflagsβ Link flags. that's it, that's the description, iconic πrpm_activeβ whether or not the consumer device is runtime-PM-active. is the consumer awake? that's the question πkrefβ count repeated addition of the same link. keeps track of how many times you added the exact same link, no duplicates sneaking past π¦rm_workβ work structure used for removing the link. cleanup era, we love to see it πsupplier_preactivatedβ Supplier has been made active before consumer probe. yes it got activated first, it was early, it was that girl π
π SEE ALSO π
the whole friend group π«Ά the kernel file is ./include/linux/device.h, and here's everyone hanging out with it:
struct subsys_interface(9)struct device_attribute(9)struct dev_ext_attribute(9)DEVICE_ATTR(9)DEVICE_ATTR_RW(9)DEVICE_ATTR_ADMIN_RW(9)DEVICE_ATTR_RW_NAMED(9)DEVICE_ATTR_RO(9)DEVICE_ATTR_ADMIN_RO(9)DEVICE_ATTR_RO_NAMED(9)DEVICE_ATTR_WO(9)DEVICE_ATTR_WO_NAMED(9)DEVICE_ULONG_ATTR(9)DEVICE_INT_ATTR(9)DEVICE_BOOL_ATTR(9)DEVICE_STRING_ATTR_RO(9)enum device_link_state(9)enum dl_dev_state(9)enum device_removable(9)struct dev_links_info(9)struct dev_msi_info(9)enum device_physical_location_panel(9)enum device_physical_location_vertical_position(9)enum device_physical_location_horizontal_position(9)struct device_physical_location(9)enum struct_device_flags(9)struct device(9)device_set_driver_override(9)device_has_driver_override(9)device_match_driver_override(9)device_iommu_mapped(9)dev_name(9)dev_bus_name(9)device_find_child_by_name(9)device_find_any_child(9)device_lock_set_class(9)device_lock_reset_class(9)
and that's the whole page, periodt π
β¨ this came from ./include/linux, dated October 2026, and it's literally titled struct device_link(9) β go forth and link your devices responsibly bestie ππ«Άπ
π¦ 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