---
name: "device_attach"
section: "9"
platform: "linux"
package: "linux-manual-3.16"
version: "3.16.56-1+deb8u1"
release: "Debian 8 (Jessie)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/device_attach"
---

# device\_attach(9)

try to attach device to a driver.

## NAME

device\_attach - try to attach device to a driver.

## SYNOPSIS

**int device\_attach(struct device \*** *dev***);**

## ARGUMENTS

*dev*

device.

## DESCRIPTION

Walk the list of drivers that the bus has and call **driver\_probe\_device** for each pair. If a compatible pair is found, break out and return.

Returns 1 if the device was bound to a driver; 0 if no matching driver was found; -ENODEV if the device is not registered.

When called for a USB interface, *dev*-\>parent lock must be held.

## COPYRIGHT
