device_get_state(9freebsd)

device_get_state9freebsd

Manipulate device state

Part of device_busy(9freebsd).

Usage

#include <sys/param.h>

#include <sys/bus.h>

device_state_t

device_get_state(device_t dev);

void

device_busy(device_t dev);

void

device_unbusy(device_t dev);

int

device_is_alive(device_t dev);

int

device_is_attached(device_t dev);

Overview

The current state of a device is accessed by calling device_get_state() which returns DS_NOTPRESENT, DS_ALIVE, DS_ATTACHED or DS_BUSY (described in device(9)). To test see if a device was successfully probed, call device_is_alive() which simply returns if the state is greater or equal to DS_ALIVE. To test see if a device was successfully attached, call device_is_attached() which simply returns if the state is greater or equal to DS_ATTACHED.

Each device has a busy count which is incremented when device_busy() is called and decremented when device_unbusy() is called. Both routines return an error if the device state is less than DS_ATTACHED.

When device_busy() is called on a device in the DS_ATTACHED state, the device changes to the DS_BUSY state. When device_unbusy() is called and after decrementing, the busy count for the device is zero, the device changes to the DS_ATTACHED state.

Releases

9 releases since Debian 5.0 (Lenny); the text changed 6 times.

  1. 5.0
  2. 6.0
  3. 7
  4. 8
  5. 9
  6. 10
  7. 11–13

Authors

This manual page was written by Doug Rabson.

From freebsd-manpages 12.2-2 in Debian 13 (Trixie). Parsed by carta from the page's mdoc source.