### Constructor

# FwupdPlugin DeviceLocker new

#### Declaration [src]

    FuDeviceLocker*
    fu_device_locker_new (
      FuDevice* device,
      GError** error
    )

#### Description [src]

Opens the device for use. When the `FuDeviceLocker` is deallocated the device will be closed and any error will just be directed to the console. This object is typically called using `g_autoptr()` but the device can also be manually closed using g_clear_object().

The functions used for opening and closing the device are set automatically.

NOTE: If the `open_func` failed then the `close_func` will not be called.

Think of this object as the device ownership.

Available since: | 1.0.0

#### Parameters

`device` | `FuDevice`
| A `FuDevice`.
| The data is owned by the caller of the function.
`error` | `GError **`
| The return location for a `GError*`, or `NULL`.

#### Return value

Returns: | `FuDeviceLocker`
| A device locker, or `NULL` if the `open_func` failed.
| The caller of the function takes ownership of the data, and is responsible for freeing it.