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

# bus\_setup\_intr(9)

create, attach and teardown an interrupt handler

## NAME

**BUS\_SETUP\_INTR**, **bus\_setup\_intr**, **BUS\_TEARDOWN\_INTR**, **bus\_teardown\_intr** – create, attach and teardown an interrupt handler

## SYNOPSIS

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

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

*int*\

**BUS\_SETUP\_INTR**(*device\_t dev*, *device\_t child*, *struct resource \*irq*, *int flags*, *driver\_intr\_t \*intr*, *void \*arg*, *void \*\*cookiep*);

*int*\

**bus\_setup\_intr**(*device\_t dev*, *struct resource \*r*, *int flags*, *driver\_intr\_t handler*, *void \*arg*, *void \*\*cookiep*);

*int*\

**BUS\_TEARDOWN\_INTR**(*device\_t dev*, *device\_t child*, *struct resource \*irq*, *void \*cookiep*);

*int*\

**bus\_teardown\_intr**(*device\_t dev*, *struct resource \*r*, *void \*cookiep*);

## DESCRIPTION

The **BUS\_SETUP\_INTR**() method will create and attach an interrupt handler to an interrupt previously allocated by the resource manager's BUS\_ALLOC\_RESOURCE(9) method. The *flags* are found in ⟨sys/bus.h⟩, and give the broad category of interrupt. The *flags* also tell the interrupt handlers about certain device driver characteristics. INTR\_FAST means the handler is for a timing-critical function. Extra care is take to speed up these handlers. Use of this implies INTR\_EXCL. INTR\_EXCL marks the handler as being an exclusive handler for this interrupt. INTR\_MPSAFE tells the scheduler that the interrupt handler is well behaved in a preemptive environment (\`\`SMP safe''), and does not need to be protected by the \`\`Giant Lock'' mutex. INTR\_ENTROPY marks the interrupt as being a good source of entropy - this may be used by the entropy device */dev/random*. The handler *intr* will be called with the value *arg* as its only argument.

The *cookiep* argument is a pointer to a *void \** that **BUS\_SETUP\_INTR**() will write a cookie for the parent bus' use to if it is successful in establishing an interrupt. Driver writers may assume that this cookie will be non-zero. The nexus driver will write 0 on failure to *cookiep*.

The interrupt handler will be detached by **BUS\_TEARDOWN\_INTR**(). The cookie needs to be passed to **BUS\_TEARDOWN\_INTR**() in order to tear down the correct interrupt handler. Once **BUS\_TEARDOWN\_INTR**() returns, it is guaranteed that the interrupt function is not active and will no longer be called.

Mutexes are not allowed to be held across calls to these functions.

## RETURN VALUES

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

## SEE ALSO

[random(4)](/random/4.md), [device(9)](/device/9.md), [driver(9)](/driver/9.md)

## AUTHORS

This manual page was written by Jeroen Ruigrok van der Werven ⟨asmodai@FreeBSD.org⟩ based on the manual pages for **BUS\_CREATE\_INTR**() and **BUS\_CONNECT\_INTR**() written by Doug Rabson ⟨dfr@FreeBSD.org⟩.
