DEVCLASS_GET_DEVICE(9)

πŸ’… DEVCLASS_GET_DEVICE πŸ’…

okay bestie, welcome to the Kernel Developer's Manual corner of the internet, where we're talking about devclass_get_device β€” literally the glow-up translator between unit numbers and actual device instances. no cap. ✨


🌸 NAME 🌸

devclass_get_device β€” translate unit number to device

like, that's the whole job. number in, device out. iconic.


πŸŽ€ SYNOPSIS πŸŽ€

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

device_t
devclass_get_device(devclass_t dc, int unit);

yes bestie, both headers, don't skip one, that's the vibe check πŸ¦‹


✨ DESCRIPTION ✨

so this function retrieves the device instance that has the given unit number, and returns it. that's it. that's the function. she does one thing and she does it well. πŸ‘‘

you hand her a devclass_t dc and an int unit, and she goes and finds the matching device instance for you. main character energy, honestly. πŸ’…


πŸ’– RETURN VALUES πŸ’–

  • if the device exists, it gets returned to you 🫢
  • otherwise, you get NULL 😭

that's the whole deal. no in-between. no half-returns. just device or NULL.


πŸ‘€ SEE ALSO πŸ‘€

go read those too, iykyk πŸ“š


πŸ¦‹ AUTHORS πŸ¦‹

This manual page was written by Doug Rabson. 🫑 absolute legend behavior.


Debian β€” June 16, 1998 β€” that's the version/date stamp on this one bestie, from the DEVCLASS_GET_DEVICE(9) page in the Kernel Developer's Manual. mwah, go forth and translate those unit numbers πŸ’‹πŸŒˆβ­

πŸ“¦ where this page comes from