DEVICE_GET_DEVCLASS(9)

πŸ’– DEVICE_GET_DEVCLASS πŸ’–

okay bestie, so this is a page from the Kernel Developer's Manual (section 9, iykyk) and it's literally the tiniest little bop β€” one function, in and out, no drama. ✨


🌸 NAME 🌸

device_get_devclass β€” access the devclass of a device

like... it gets you the devclass. of a device. that's the whole vibe. πŸŽ€


✨ SYNOPSIS ✨

first you gotta pull in the headers, no skipping:

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

and then the moment we've all been waiting for:

devclass_t
device_get_devclass(device_t dev);

look at her. she's iconic. she takes one device_t dev and she gives you back a devclass_t. that's it. that's the function. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's what's happening: device_get_devclass returns the current devclass that's associated with the device. like, whatever devclass that device is vibing with right now? that's what you get back. simple. clean. no cap. πŸ’–

but β€” and this is the important bit, don't skip it β€” if the device has no devclass, then NULL is returned. not an error, not a crash, just NULL. so fr fr, check your return value before you go using it, bestie. 😭

lowkey a "no devclass" situation is just a thing that can happen, and the function handles it by handing you NULL. that's not a bug, that's the documented behaviour. periodt.

πŸ‘‘ SEE ALSO πŸ‘‘

go read those too, they're the supporting cast and they ate. πŸ”₯


🌈 AUTHORS 🌈

this manual page was written by Doug Rabson. thank you Doug, you legend, we appreciate you 🫢


and that's the whole page, bestie!! short, sweet, and honestly kind of a serve for how small it is. now go forth and get those devclasses. mwah πŸ’‹

this lil cutie comes from the Debian distro, dated June 16, 1998 β€” yeah she's vintage, she's been serving the kernel girlies since before we were born and she's still relevant. slay πŸ’œβœ¨

πŸ“¦ where this page comes from