---
name: "device_get_state"
section: "9"
platform: "linux"
package: "freebsd-manpages"
version: "6.0-5"
release: "Debian 4.0 (Etch)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/device_get_state"
---

# device\_get\_state(9)

manipulate device state

## NAME

**device\_get\_state**, **device\_busy**, **device\_unbusy**, **device\_is\_alive**, **device\_is\_attached** – manipulate device state

## SYNOPSIS

**#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*);

## DESCRIPTION

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)](/device/9.md)). 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.

## SEE ALSO

[device(9)](/device/9.md)

## AUTHORS

This manual page was written by Doug Rabson.
