__of_device_is_compatible(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– __of_device_is_compatible β€” the Kernel API Manual glow-up πŸ’–

okay so bestie, welcome to the kernel API manual, where we're checking if a node matches constraints and honestly? it's giving matchmaker energy. let's get into it πŸŽ€


✨ NAME ✨

__of_device_is_compatible β€” literally just checks if the node matches the constraints you gave it, no cap πŸ¦‹


🌸 SYNOPSIS 🌸

int __of_device_is_compatible (const struct device_node *device , const
       char *compat , const char *type , const char *name );

πŸŽ€ ARGUMENTS πŸŽ€

  • device β€” pointer to node, like the actual thing we're vibe-checking πŸ’…
  • compat β€” the required compatible string. pass NULL or "" and it's like "any match works bestie" ✨
  • type β€” the required device_type value. again, NULL or "" means any match, we're flexible like that 🫢
  • name β€” the required node name. yep, NULL or "" = any match, main character energy 😭

πŸ’œ DESCRIPTION πŸ’œ

So what it does is, it checks if the given compat, type and name strings match the properties of the given device. Any one of the constraints can be skipped entirely by passing NULL or an empty string as that constraint β€” lowkey iconic of it honestly πŸ™ˆ

It returns 0 for no match, and a positive integer on match. and here's the slay part: that return value is a relative score, and larger values mean better matches πŸ”₯

The score is weighted so the most specific compatible value gets the highest score. after that comes matching type, and then matching name. Practically speaking, this gives you the following priority order for matches, bestie:

  1. specific compatible && type && name πŸ‘‘
  2. specific compatible && type
  3. specific compatible && name
  4. specific compatible
  5. general compatible && type && name
  6. general compatible && type
  7. general compatible && name
  8. general compatible
  9. type && name
  10. type
  11. name

like, the ranking ate, fr fr πŸ’€βœ¨


πŸ¦‹ SEE ALSO πŸ¦‹

kernel file ./drivers/of/base.c β€” and the whole friend group πŸ’–


and that's the whole page!! 🧚 this one lives in ./drivers/of, dated October 2026 β€” mwah, go read some device tree nodes, ily, bye πŸ’œπŸ“

πŸ“¦ where this page comes from