device_get_state(9)

device_get_state9

Manipulate device state

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

77 releases since FreeBSD 3.0-RELEASE; the text changed 40 times.

  1. 3.0–3.2
  2. 3.3–3.5.1
  3. 4.0–4.2
  4. 4.3
  5. 4.4
  6. 4.5–4.11
  7. 5.0
  8. 5.1
  9. 5.2–6.3
  10. 6.4
  11. 7.0
  12. 7.1
  13. 7.2
  14. 7.3
  15. 7.4
  16. 8.0
  17. 8.1
  18. 8.2
  19. 8.3
  20. 8.4
  21. 9.0
  22. 9.1
  23. 9.2
  24. 9.3
  25. 10.0
  26. 10.1
  27. 10.2
  28. 10.3
  29. 10.4
  30. 11.0
  31. 11.1
  32. 11.2
  33. 11.3
  34. 11.4
  35. 12.0
  36. 12.1
  37. 12.2
  38. 12.3
  39. 12.4
  40. 13.0–13.2
  41. 13.3–16.0

Authors

This manual page was written by Doug Rabson.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.