STRUCT DEVICE_LINK(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

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:


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