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

# libusb20\_dev\_open(3)

open a USB device to retrieve descriptors and initiate transfers

## NAME

**libusb20\_dev\_open** – open a USB device to retrieve descriptors and initiate transfers

## SYNOPSIS

library “libusb”

**#include \<libusb20.h\>**

*int*\

**libusb20\_dev\_open**(*struct libusb20\_device \*pdev*, *uin16\_t transfer\_max*);

## DESCRIPTION

The **libusb20\_dev\_open** function opens a USB device to retrieve descriptors and initiate transfers. **libusb20\_dev\_open** accepts a pointer as *pdev* to a libusb20\_device obtained from **libusb20\_be\_device\_foreach**. A zero for *transfer\_max* limits the device to only control transfers. Call [libusb20\_dev\_close(3)](/libusb20_dev_close/3.md) to free resources taken by the open device handle.

## RETURN VALUES

**libusb20\_dev\_open** returns one of the following to report success or failure:

- LIBUSB20\_SUCCESS,

  The operation succeeds.

- LIBUSB20\_ERROR\_BUSY,

  The device is in use elsewhere.

- LIBUSB20\_ERROR\_ACCESS,

  A permissions issue.

- LIBUSB20\_ERROR\_NO\_DEVICE,

  The device detached.

- LIBUSB20\_ERROR\_NO\_MEM

  The library couldn't allocate memory.

Errors not listed here may be found in [libusb20(3)](/libusb20/3.md) and ⟨libusb20.h⟩.

## EXAMPLES

```
    #include <libusb20.h>
    struct libusb20_backend *be = libusb20_be_alloc_default(NULL);
    struct libusb20_device *device = NULL;
    while ( (device = libusb20_be_device_foreach(be, device)) != NULL ) {
        if (libusb20_dev_open(device, 0) == LIBUSB20_SUCCESS) {
            /* do something */
            libusb20_dev_close(device);
        }
    }
    libusb20_be_free(be);
```

## SEE ALSO

[libusb20(3)](/libusb20/3.md), [libusb20\_be\_device\_foreach(3)](/libusb20_be_device_foreach/3.md), [libusb20\_dev\_close(3)](/libusb20_dev_close/3.md)
