Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

deviter(9) [netbsd man page]

DEVITER(9)						   BSD Kernel Developer's Manual						DEVITER(9)

deviter, deviter_first, deviter_init, deviter_next, deviter_release -- machine-independent device iteration API SYNOPSIS
#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); DESCRIPTION
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. DATA TYPES
Kernel subsystems using deviter may make use of the following data types: deviter_flags_t The kernel can iterate over devices for different purposes and in different orders. The following flags affect device iteration: DEVITER_F_RW DEVITER_F_SHUTDOWN DEVITER_F_LEAVES_FIRST DEVITER_F_ROOT_FIRST deviter_t This is a device iteration ``cursor'' or ``iterator''. It holds iteration state such as the next device to visit. FUNCTIONS
deviter_init(di, flags) Initialize the device iterator, di. Set bits in flags to affect the order of iteration. Set 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) Advance the iterator di to the next device. 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) Initialize the iterator di with flags. Return the first device according to the ordering indicated by flags and advance di to the second device, or return NULL if there are no devices. This is equivalent to calling deviter_init(di, flags) and then deviter_next(di). deviter_release(di) Release all resources held by the iterator di. Every iterator that is initialized with deviter_first() or deviter_init() MUST be released. CODE REFERENCES
Device iteration is implemented within the files sys/sys/device.h and sys/kern/subr_autoconf.c. SEE ALSO
autoconf(9), driver(9) HISTORY
deviter appeared in NetBSD 5.0. AUTHORS
David Young <> BSD
November 4, 2009 BSD

Check Out this Related Man Page

DEVICE(9)						   BSD Kernel Developer's Manual						 DEVICE(9)

device -- an abstract representation of a device SYNOPSIS
typedef struct device *device_t; DESCRIPTION
The device object represents a piece of hardware attached to the system such as an expansion card, the bus which that card is plugged into, disk drives attached to the expansion card etc. The system defines one device, root_bus and all other devices are created dynamically during autoconfiguration. Normally devices representing top-level busses in the system (ISA, PCI etc.) will be attached directly to root_bus and other devices will be added as children of their relevant bus. The devices in a system form a tree. All devices except root_bus have a parent (see device_get_parent(9)). In addition, any device can have children attached to it (see device_add_child(9), device_add_child_ordered(9), device_find_child(9), device_get_children(9), and device_delete_child(9)). A device which has been successfully probed and attached to the system will also have a driver (see device_get_driver(9) and driver(9)) and a devclass (see device_get_devclass(9) and devclass(9)). Various other attributes of the device include a unit number (see device_get_unit(9)), verbose description (normally supplied by the driver, see device_set_desc(9) and device_get_desc(9)), a set of bus-spe- cific variables (see device_get_ivars(9)) and a set of driver-specific variables (see device_get_softc(9)). Devices can be in one of several states: DS_NOTPRESENT the device has not been probed for existence or the probe failed DS_ALIVE the device probe succeeded but not yet attached DS_ATTACHED the device has been successfully attached DS_BUSY the device is currently open The current state of the device can be determined by calling device_get_state(9). SEE ALSO
devclass(9), driver(9) AUTHORS
This manual page was written by Doug Rabson. BSD
June 16, 1998 BSD
Man Page