BUS_CHILD_PRESENT(9)

πŸ’– BUS_CHILD_PRESENT(9) πŸ’–

okay bestie, welcome to the Kernel Developer's Manual page for bus_child_present β€” yes it's a section 9 function, yes it's giving real low-level energy, and yes you're gonna understand it. let's go ✨


🌸 NAME 🌸

bus_child_present β€” ask the bus driver to see if this device is still really present

like, actually present. not "present in theory". present present. 🫢


πŸŽ€ SYNOPSIS πŸŽ€

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

#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>

int
bus_child_present(device_t dev);

πŸ’… DESCRIPTION πŸ’…

so the way that bus_child_present() works is: it asks the parent device driver of dev to go check whether the hardware that dev represents is still physically accessible right now. like, right this second. ⏰

and ngl, "accessible" is a bit of a vibe-check situation β€” it varies from bus to bus. but generally speaking, hardware that isn't accessible cannot be accessed via the bus_space*() methods that you'd otherwise be using to poke at the device. so if it's not accessible, those methods aren't gonna save you. πŸ’€

🚨 also important bestie: this does not ask the question "does this device have children?" β€” that's a whole different question and it's better answered by device_get_children(9). don't mix them up, i'm begging πŸ™ˆ

⭐ RETURN VALUES ⭐

  • a zero return value means the device is not present in the system. it's gone, she left, no note 😭
  • a non-zero return value means the device is present in the system β€” OR that the state of the device can't be determined. yeah, ambiguous queen. that's just how it is πŸ’…

🌈 EXAMPLES 🌈

here's some example code. it only calls stop when the dc(4) device is actually present β€” iconic behavior, honestly:

device_t dev;
dc_softc *sc;

sc = device_get_softc(dev);
if (bus_child_present(dev))
        dc_stop(sc);

πŸ‘‘ SEE ALSO πŸ‘‘


πŸ¦‹ AUTHORS πŸ¦‹

this manual page was written by Warner Losh <imp@FreeBSD.org>. thank you warner, we appreciate you fr fr πŸ’–


and that's the whole page bestie!! this one came from the Debian crew and it's dated March 27, 2003 β€” a true vintage baddie from the BUS_CHILD_PRESENT(9) archives. periodt. βœ¨πŸŽ€πŸ’œ

πŸ“¦ where this page comes from