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

# device\_add(9)

add device to device hierarchy.

## NAME

device\_add - add device to device hierarchy.

## SYNOPSIS

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

## ARGUMENTS

*dev*

device.

## DESCRIPTION

This is part 2 of **device\_register**, though may be called separately \_iff\_ **device\_initialize** has been called separately.

This adds *dev* to the kobject hierarchy via **kobject\_add**, adds it to the global and sibling lists for the device, then adds it to the other relevant subsystems of the driver model.

Do not call this routine or **device\_register** more than once for any device structure. The driver model core is not designed to work with devices that get unregistered and then spring back to life. (Among other things, it's very hard to guarantee that all references to the previous incarnation of *dev* have been dropped.) Allocate and register a fresh new struct device instead.

## NOTE

\_Never\_ directly free *dev* after calling this function, even if it returned an error! Always use **put\_device** to give up your reference instead.

## COPYRIGHT
