dtpm_create_hierarchy(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 dtpm_create_hierarchy(9) 🌸

okay so bestie, welcome to the kernel API manual β€” this is a section 9 page (that's the kernel internals girlies πŸ’…), and today's main character is dtpm_create_hierarchy. buckle up πŸŽ€


✨ NAME ✨

dtpm_create_hierarchy β€” Create the dtpm hierarchy πŸ¦‹


✨ SYNOPSIS ✨

int dtpm_create_hierarchy (struct of_device_id *dtpm_match_table );

✨ ARGUMENTS ✨

  • dtpm_match_table β€” Pointer to the array of device ID structures. that's it, that's the whole argument, she's lowkey simple 🫢

✨ DESCRIPTION ✨

so the platform specific code calls this function and hands it the description of the different node in the hierarchy. and what does she do with it? she creates the tree in the sysfs filesystem, under the powercap dtpm entry. iconic behaviour honestly πŸ‘‘

the expected tree has the format:

struct dtpm_node hierarchy[] = {
    [0] { .name = "topmost", .type = DTPM_NODE_VIRTUAL },
    [1] { .name = "package", .type = DTPM_NODE_VIRTUAL, .parent = hierarchy[0] },
    [2] { .name = "/cpus/cpu0", .type = DTPM_NODE_DT, .parent = hierarchy[1] },
    [3] { .name = "/cpus/cpu1", .type = DTPM_NODE_DT, .parent = hierarchy[1] },
    [4] { .name = "/cpus/cpu2", .type = DTPM_NODE_DT, .parent = hierarchy[1] },
    [5] { .name = "/cpus/cpu3", .type = DTPM_NODE_DT, .parent = hierarchy[1] },
    [6] { }
};

and the last element is always an empty one β€” that's the little "we're done here" marker that tells everyone the array has ended. do not forget her, fr fr πŸ™ˆ


✨ RETURN ✨

  • zero on success πŸŽ‰
  • a negative value in case of error 😭 β€” and those errors are reported back from the underlying functions, so like, not her fault, she's just the messenger πŸ’€

✨ SEE ALSO ✨

go read those too, iykyk πŸ’œ


ngl this one's short and sweet β€” but the tree structure is the whole vibe, so get those .parent pointers right or the whole hierarchy is gonna be a mess 🧚

mwah πŸ’‹ thanks for reading bestie β€” this page lives under ./drivers/powercap and it's dated October 2026, so like, she's from the future and she ate β­πŸŒˆπŸ‘‘

πŸ“¦ where this page comes from