| DEVITER(9) | Kernel Developer's Manual | DEVITER(9) |
deviter,
deviter_first, deviter_init,
deviter_next,
deviter_release —
machine-independent device iteration API
#include
<sys/device.h>
void
deviter_init(deviter_t
*di, deviter_flags_t
flags);
device_t
deviter_first(deviter_t
*di, deviter_flags_t
flags);
device_t
deviter_next(deviter_t
*di);
void
deviter_release(deviter_t
*di);
The machine-independent deviter API lets
interrupt handlers running at any priority level and kernel threads iterate
over the devices attached to the kernel. Using
deviter, it is safe for an interrupt handler or a
thread to iterate over devices attached to the kernel while another thread
attaches or detaches the devices.
Kernel subsystems using deviter may make
use of the following data types:
deviter_init(di,
flags)DEVITER_F_LEAVES_FIRST to visit each device only
after visiting its children (visit the leaves of the device tree, first).
Set DEVITER_F_ROOT_FIRST to visit each device
before visiting its children (visit the root of the device tree, first).
If you set neither DEVITER_F_LEAVES_FIRST nor
DEVITER_F_ROOT_FIRST,
deviter returns devices in an arbitrary order.
Set DEVITER_F_RW if your purpose for
iterating over devices is to modify the device tree by attaching or
detaching devices. Set DEVITER_F_SHUTDOWN if
your purpose for iterating over devices is to detach all of the devices
during system shutdown. DEVITER_F_SHUTDOWN
implies DEVITER_F_RW.
deviter_next(di)deviter_next() returns the current device or
NULL if there are no more devices.
deviter_next() is undefined if
di has not been initialized using
deviter_init() or
deviter_first().deviter_first(di,
flags)NULL if there are no devices. This is equivalent
to calling deviter_init(di,
flags) and then
deviter_next(di).deviter_release(di)deviter_first()
or deviter_init() MUST be released.Device iteration is implemented within the files sys/sys/device.h and sys/kern/subr_autoconf.c.
deviter appeared in
NetBSD 5.0.
David Young <dyoung@NetBSD.org>
| November 4, 2009 | NetBSD 11.0 |