of_get_compatible_child(9)
πΈ of_get_compatible_child(9) β Kernel API Manual πΈ
okay bestie, sit down, we're learning about of_get_compatible_child today and honestly? it's a little cutie. this is from the Kernel API Manual, and it's gonna take like two minutes, you got this π
β¨ NAME β¨
of_get_compatible_child β find a compatible child node π
β¨ SYNOPSIS β¨
struct device_node * of_get_compatible_child (const struct device_node
*parent , const char *compatible );
like, look at that signature. struct device_node * out front, two args in the back. we love a return type that's a pointer, ngl π
β¨ ARGUMENTS β¨
parentβ the parent node π«Ά that's it, that's the whole thing, it's the node you're looking inside of.compatibleβ the compatible string β this is the thing you're hunting for, bestie.
β¨ DESCRIPTION β¨
so here's the vibe: you look up the child node whose compatible property contains the given compatible string. that's the whole quest. no cap. π₯
like, you hand it a parent, you hand it a string, and it goes digging through the children looking for one whose compatible property has your string in it. iconic behavior honestly π¦
β¨ RETURN β¨
you get back a node pointer with its refcount incremented π β and bestie, listen to me β when you're done with it, you must call of_node_put on it. that's not optional, that's not a suggestion, that's the rule π
or you get NULL if it's not found. sad but valid π
β οΈ the refcount is incremented on the way out, so if you forget of_node_put you're leaking. do not be that girlie. π
β¨ SEE ALSO β¨
the kernel file ./drivers/of/base.c is where this lives, and here's the whole friend group π§:
of_find_all_nodes(9)__of_device_is_compatible(9)of_machine_compatible_match(9)of_machine_read_compatible(9)of_machine_read_model(9)of_machine_get_match(9)of_machine_get_match_data(9)__of_device_is_available(9)__of_device_is_reserved(9)of_device_is_available(9)__of_device_is_fail(9)of_device_is_big_endian(9)of_get_parent(9)of_get_next_parent(9)of_get_next_child(9)of_get_next_child_with_prefix(9)of_get_next_available_child(9)of_get_next_reserved_child(9)of_get_next_cpu_node(9)of_get_child_by_name(9)of_get_available_child_by_name(9)of_find_node_opts_by_path(9)of_find_node_by_name(9)of_find_node_by_type(9)of_find_compatible_node(9)of_find_node_with_property(9)of_match_node(9)of_find_matching_node_and_match(9)of_alias_from_compatible(9)of_find_node_by_phandle(9)of_parse_phandle_with_args_map(9)of_count_phandle_with_args(9)__of_add_property(9)of_add_property(9)of_remove_property(9)of_alias_scan(9)of_alias_get_id(9)of_alias_get_highest_id(9)of_console_check(9)of_find_next_cache_node(9)of_find_last_cache_level(9)of_map_id(9)of_map_iommu_id(9)of_map_msi_id(9)
that's a lot of siblings but we love them all equally π
and that's the page, bestie!! π it lives over in ./drivers/of and this particular glow-up is dated October 2026 β slay, see you in the next one ππ¦β¨
π¦ 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