---
name: "bus_for_each_dev"
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/bus_for_each_dev"
---

# bus\_for\_each\_dev(9)

device iterator.

## NAME

bus\_for\_each\_dev - device iterator.

## SYNOPSIS

**int bus\_for\_each\_dev(struct bus\_type \*** *bus***, struct device \*** *start***, void \*** *data***, int (\****fn***) (struct device \*, void \*));**

## ARGUMENTS

*bus*

bus type.

*start*

device to start iterating from.

*data*

data for the callback.

*fn*

function to be called for each device.

## DESCRIPTION

Iterate over *bus*'s list of devices, and call *fn* for each, passing it *data*. If *start* is not NULL, we use that device to begin iterating from.

We check the return of *fn* each time. If it returns anything other than 0, we break out and return that value.

## NOTE

The device that returns a non-zero value is not retained in any way, nor is its refcount incremented. If the caller needs to retain this data, it should do so, and increment the reference count in the supplied callback.

## COPYRIGHT
