DEVCLASS_GET_SOFTC(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… DEVCLASS_GET_SOFTC β€” a Kernel Developer's Manual moment (section 9, bestie)

okay so real talk, this is from the Kernel Developer's Manual, section 9 β€” the big-brain kernel-functions section. and the whole vibe of this page is literally one job: turn a unit number into the driver's private little stash of variables. that's it. that's the function. iconic behaviour, honestly. πŸŽ€


✨ NAME ✨

devclass_get_softc β€” translate unit number to driver private structure

like, a little translator between "which unit??" and "here's that driver's personal stuff." πŸ¦‹


✨ SYNOPSIS ✨

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

void *
devclass_get_softc(devclass_t dc, int unit);

so you're pulling in both sys/param.h and sys/bus.h β€” yes both, don't skip one, she needs her whole support system πŸ’– β€” and then you call devclass_get_softc with a devclass_t dc and an int unit, and it hands you back a void *. slay.


✨ DESCRIPTION ✨

okay so here's the whole thing, bestie, and it's lowkey simple:

this function retrieves the driver private instance variables for the device with the given unit number… and returns them. that's the entire plot. 🌸

like β€” you've got a unit number, you've got a devclass, the function goes "yeah I know her" and hands over the driver-private variables for that device. main character retrieval energy, fr fr. πŸ‘‘


✨ RETURN VALUES ✨

vibe check time, and there are exactly two outcomes:

  • if the device exists β†’ its driver-private variables are returned. you ate. πŸ’…
  • otherwise β†’ NULL is returned. 😭 not the null, but okay, at least it's honest.

no cap, that's the whole return value situation.


✨ SEE ALSO ✨

  • device(9) β€” go read that one too, iykyk 🫢

✨ AUTHORS ✨

this manual page was written by Doug Rabson. yes king, thank you for your service. πŸ‘‘πŸŒ·


lowkey a reminder: this page is living in the Debian edition of the Kernel Developer's Manual, and it's dated June 16, 1998 β€” vintage but still serving. β­πŸ’œ

and that's the page, bestie β€” devclass_get_softc(9), written by Doug Rabson, Debian printing edition, June 16, 1998. go translate some unit numbers. you're gonna slay. 🌈✨

πŸ“¦ where this page comes from