---
name: "DEVICE_DETACH"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/DEVICE_DETACH"
---

# DEVICE\_DETACH(9)

detach a device

## NAME

**DEVICE\_DETACH** – detach a device

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<sys/bus.h\>**

*int*\

**DEVICE\_DETACH**(*device\_t dev*);

## DESCRIPTION

Detach a device. This can be called if the user is replacing the driver software or if a device is about to be physically removed from the system.

The method should deallocate any system resources allocated during the [DEVICE\_ATTACH(9)](/DEVICE_ATTACH/9.md) method and reset the hardware to a sane state (i.e., disable interrupts etc.)

## RETURN VALUES

Zero is returned on success, otherwise an appropriate error is returned.

## SEE ALSO

[device(9)](/device/9.md), [DEVICE\_ATTACH(9)](/DEVICE_ATTACH/9.md), [DEVICE\_IDENTIFY(9)](/DEVICE_IDENTIFY/9.md), [DEVICE\_PROBE(9)](/DEVICE_PROBE/9.md), [DEVICE\_SHUTDOWN(9)](/DEVICE_SHUTDOWN/9.md)

## AUTHORS

This manual page was written by Doug Rabson.
