DEVICE_FIND_CHILD(9)

πŸ’– DEVICE_FIND_CHILD(9) πŸ’–

okay bestie, so this is a Kernel Developer's Manual page, section 9, and it's all about device_find_child β€” literally just searching for a child of a device. that's it, that's the vibe. πŸ¦‹


✨ NAME ✨

device_find_child β€” search for a child of a device πŸ‘‘


🌸 SYNOPSIS 🌸

#include <sys/param.h>
#include <sys/bus.h>

device_t
device_find_child(device_t dev, const char *classname, int unit);

like, yes, you gotta pull in both of those headers first, no skipping. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

so this function goes looking for a specific child of dev, matching on the given classname and unit. very "i know exactly who i'm looking for" energy. πŸ•΅οΈβ€β™€οΈ

and here's the cute part β€” if unit is -1, it doesn't need an exact unit match. it just returns the first child of dev with a matching classname β€” and by "first" we mean the one with the lowest unit. lowest unit wins, periodt. ✨


πŸ’œ RETURN VALUES πŸ’œ

if that child exists, boom, the child device gets returned to you. if not? NULL. that's the whole story. 😭

fr fr, check for NULL before you go using it, bestie.

🫢 SEE ALSO 🫢


🌈 AUTHORS 🌈

this manual page was written by Doug Rabson. iconic of them honestly. πŸ‘‘


and that's the whole page!! this one came from the Debian crew, dated February 8, 2005 β€” so yeah, vintage, but the knowledge still slays. mwah, go find those children, i believe in you πŸ’‹πŸ’–

πŸ“¦ where this page comes from