of_find_compatible_node(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

ok so of_find_compatible_node β€” bestie, this is the function that finds a node for you based on the type and one of the tokens in its "compatible" property. like it's literally matching vibes across device tree nodes. slay.

(this is the of_find_compatible_node(9) page btw, from the Kernel API Manual β€” folder it under "kernel lore i need to remember" ✨)


πŸ¦‹ SYNOPSIS πŸ¦‹

struct device_node * of_find_compatible_node (struct device_node *from ,
const char *type , const char *compatible );

that's the whole signature, no cap. three args, one node pointer back πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • from β€” the node you start searching from, or NULL. ok and hear me on this one: the node you pass will not be searched, only the next one will. typically you pass whatever the previous call returned (yes, cursor-core 😌). and heads up β€” of_node_put will be called on it.
  • type β€” the type string that gets matched against "device_type", or NULL if you literally want to ignore it and not care.
  • compatible β€” the string that gets matched to one of the tokens in the device's "compatible" list. this is the main character of the match, fr fr.

🌸 RETURN 🌸

you get back a node pointer with its refcount incremented πŸ”₯ β€” so it's not just a freebie, bestie. when you're done with it, use of_node_put on it. that's the whole deal. don't forget, or it's giving leak energy πŸ’€


⭐ SEE ALSO ⭐

the kernel file is ./drivers/of/base.c, and here's the whole friend group β€” yes, all of them, i'm not skipping a single one 🫢:

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_compatible_child(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_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)

like genuinely an iconic lineup, iykyk πŸ’œ


ngl the whole point is: match type + a compatible token, get a refcounted node back, of_node_put when done. that's it, that's the vibe check βœ…

ok bye bestie, this page lives in ./drivers/of, dated October 2026, and it's of_find_compatible_node(9) β€” go forth and find some nodes πŸ‘‘πŸŒˆ 🧚

πŸ“¦ where this page comes from