---
name: "bus_attach_children"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/bus_attach_children"
---

# bus\_attach\_children(9)

manage child devices of a bus device

## NAME

**bus\_attach\_children**, **bus\_delayed\_attach\_children**, **bus\_detach\_children**, **bus\_enumerate\_hinted\_children**, **bus\_identify\_children** – manage child devices of a bus device

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<sys/bus.h\>**

*void*\

**bus\_attach\_children**(*device\_t dev*);

*void*\

**bus\_delayed\_attach\_children**(*device\_t bus*);

*int*\

**bus\_detach\_children**(*device\_t dev*);

*void*\

**bus\_enumerate\_hinted\_children**(*device\_t bus*);

*void*\

**bus\_identify\_children**(*device\_t dev*);

## DESCRIPTION

These functions manage state transitions of child devices for *dev*.

**bus\_enumerate\_hinted\_children**() walks the kernel environment to identify any device hints that describe a device attached to *dev*. For each set of matching hints, the [BUS\_HINTED\_CHILD(9)](/BUS_HINTED_CHILD/9.md) method is invoked. This function is typically called from a bus driver's [DEVICE\_ATTACH(9)](/DEVICE_ATTACH/9.md) method to add hinted devices. Note that most bus drivers do not use hints to identify child devices. This is typically used for legacy buses such as ISA that do not provide a mechanism for enumerating devices.

**bus\_identify\_children**() iterates over all eligible device drivers for children of *dev* invoking the [DEVICE\_IDENTIFY(9)](/DEVICE_IDENTIFY/9.md) method. This allows device drivers to add child devices that are enumerated via alternate mechanisms such as firmware tables. This function is typically called from a bus driver's [DEVICE\_ATTACH(9)](/DEVICE_ATTACH/9.md) method.

**bus\_attach\_children**() attaches device drivers to all children of *dev*. This function invokes [device\_probe\_and\_attach(9)](/device_probe_and_attach/9.md) on each child device ignoring errors. It makes a best-effort pass to attach device drivers to all children. Child devices are attached in increasing order. Child devices with the same order are attached in FIFO order based on the time when the device was created via [device\_add\_child(9)](/device_add_child/9.md). This function is typically called from a bus driver's [DEVICE\_ATTACH(9)](/DEVICE_ATTACH/9.md) method after adding devices.

**bus\_delayed\_attach\_children**() attaches device drivers to all children of *dev* after interrupts are enabled. This function schedules a call to **bus\_attach\_children**() after interrupts are enabled via [config\_intrhook\_establish(9)](/config_intrhook_establish/9.md). If interrupts are already enabled (for example, when loading a device driver after booting), **bus\_attach\_children**() is called immediately.

**bus\_detach\_children**() detaches device drivers from all children of *dev* by calling [device\_detach(9)](/device_detach/9.md) on each child device. Unlike **bus\_attach\_children**(), this function does not make a best-effort pass. If a child device fails to detach, **bus\_detach\_children**() immediately fails returning the error from the child's failed detach. Child devices are detached in reverse order compared to **bus\_attach\_children**(). That is, child devices are detached in decreasing order, and child devices with the same order are detached in LIFO order. Detached devices are not deleted.

**bus\_detach\_children**() is typically called at the start of a bus driver's [DEVICE\_DETACH(9)](/DEVICE_DETACH/9.md) method to give child devices a chance to veto the detach request. It is usually paired with a later call to **device\_delete\_children**(*9*) to delete child devices. If no additional logic is required between the two function calls, a bus driver can use [bus\_generic\_detach(9)](/bus_generic_detach/9.md) to detach and delete children.

## RETURN VALUES

## SEE ALSO

[config\_intrhook\_establish(9)](/config_intrhook_establish/9.md), [device\_add\_child(9)](/device_add_child/9.md), [DEVICE\_ATTACH(9)](/DEVICE_ATTACH/9.md), [device\_delete\_children(9)](/device_delete_children/9.md), [DEVICE\_DETACH(9)](/DEVICE_DETACH/9.md), [device\_detach(9)](/device_detach/9.md), [DEVICE\_IDENTIFY(9)](/DEVICE_IDENTIFY/9.md), [device\_probe\_and\_attach(9)](/device_probe_and_attach/9.md)

## HISTORY

**bus\_enumerate\_hinted\_children**() first appeared in FreeBSD 6.2.

**bus\_delayed\_attach\_children**() first appeared in FreeBSD 12.2.

**bus\_identify\_children**() first appeared in FreeBSD 15.0. Its functionality is available in older releases via the deprecated **bus\_generic\_probe**().

**bus\_attach\_children**() first appeared in FreeBSD 15.0. Its functionality is available in older releases via the deprecated **bus\_generic\_attach**().

**bus\_detach\_children**() first appeared in FreeBSD 15.0. Its functionality is available in older releases via **bus\_generic\_detach**().
