DEVICE_PROBE(9)
π DEVICE_PROBE(9) β probe for device existence π
ok so this is a page from the Kernel Developer's Manual, and bestie, if you're writing drivers you're gonna meet this one. it's literally the vibe-check function for hardware. no cap.
β¨ SYNOPSIS β¨
#include <sys/param.h>
#include <sys/bus.h>
int
DEVICE_PROBE(device_t dev);
like. that's the whole signature. she's simple. she's iconic. π
πΈ DESCRIPTION πΈ
okay so DEVICE_PROBE() is the method that goes "hey, is this device actually here??" β it probes for the device's existence. that's the whole job.
and it returns:
0if the device exists π«ΆENXIOif it cannot be found π- some other appropriate error code if something else goes sideways during the probe (a memory allocation failure, for example β rude)
but WAIT, there's more, because sometimes more than one driver matches the same device, and then it turns into a lil competition. in that case you return a priority value. here's the lore:
- success codes are values less than or equal to zero, and the highest value is the best match
- failure codes are positive values, and you should use the regular Unix error codes for that
β οΈ and now the serious part, bestie, listen up: if a driver returns a success code less than zero, it must not assume it's gonna be the same driver that gets attached to the device. in particular, it must not assume that any values stored in the softc structure will be available for its attach method β and any resources allocated during probe must be released and re-allocated if the attach method is called. also it is an absolute requirement that the probe routine have no side effects whatsoever. zero. none. the probe routine may be called more than once before the attach routine is called. so don't be out here leaving mess everywhere π
if a success code of zero is returned, then the driver can assume it will be the one attached β but it must not hold any resources when the probe routine returns. a driver may assume that the softc is preserved when it returns a success code of zero. π
π₯ RETURN VALUES π₯
- a value equal to or less than zero means success
- a value greater than zero means an error (
errno)
for the values equal to or less than zero:
- zero means highest priority, and no further probing is done
- for a value less than zero, the lower the value, the lower the priority β e.g.
-100indicates a lower priority than-50
π¦ the convention values (the matching-strength menu) π¦
these are the values used by convention to indicate different strengths of matching in a probe routine. except as noted, these are just suggested values, and there's nothing magical about them. fr fr, they're vibes, not law.
BUS_PROBE_SPECIFICβ the device that cannot be reprobed, and that no possible other driver may exist for. typically the legacy drivers who don't follow all the rules, or the special-needs drivers πBUS_PROBE_VENDORβ the device is supported by a vendor driver. this is for source or binary drivers that are not yet integrated into the FreeBSD tree. > its use in the base OS is prohibited. π«BUS_PROBE_DEFAULTβ the device is a normal device matching some plug and play ID. this is the normal return value for drivers to use, and it is intended that nearly all of the drivers in the tree should return this value. she's the default for a reason bestie πBUS_PROBE_LOW_PRIORITYβ the driver is a legacy driver, or an otherwise less desirable driver for a given plug and play ID. the driver has special requirements, like when there are two drivers that support overlapping series of hardware devices. in that case the one that supports the older part of the line would return this value, while the one that supports the newer ones would returnBUS_PROBE_DEFAULT. generational drama, honestly πBUS_PROBE_GENERICβ the driver matches the type of device generally. this allows drivers to match all serial ports generally, with specialized drivers matching particular types of serial ports that need special treatment for some reason β¨BUS_PROBE_HOOVERβ the driver matches all unclaimed devices on a bus. theugen(4)device is one example. she's hoovering up everything, no crumbs left πBUS_PROBE_NOWILDCARDβ the driver expects its parent to tell it which children to manage, and no probing is really done. the device only matches if its parent bus specifically said to use this driver. no guessing games, only direct instructions π«Ά
π SEE ALSO π
π AUTHORS π
this manual page was written by Doug Rabson. ty king π«‘
ok that's the whole page, you're basically a kernel dev now, mwah π
this came out of the Debian edition, dated February 8, 2012 β yes she's an elder but she still ate and left no crumbs. go probe something responsibly, bestie πΈπ¦β¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1998 Doug Rabson
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms