api: Add API for unconfiguring devices 87/135487/2
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Mon, 19 Jun 2017 09:18:19 +0000 (11:18 +0200)
committerPaweł Szewczyk <p.szewczyk@samsung.com>
Thu, 24 Aug 2017 09:03:07 +0000 (11:03 +0200)
Change-Id: I52d1521cd1d4e6aee0ca81c56414f8cbd68c52be
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
include/usb_host.h
src/usb_host.c

index 669e97841add0d6961c77da343e1de50aeeb7891..12563457b18759065f23836260ccb8a25dc0956c 100644 (file)
@@ -438,6 +438,19 @@ int usb_host_get_active_config(usb_host_device_h dev, usb_host_config_h *config)
  */
 int usb_host_set_config(usb_host_config_h configuration);
 
+/**
+ * @ingroup CAPI_USB_HOST_DEV_MODULE
+ * @brief Puts a device in unconfigured state.
+ * @since_tizen 4.0
+ * @param[in] dev Device to be unconfigured
+ * @return 0 on success, otherwise a negative error value
+ * @retval #USB_HOST_ERROR_NONE Successful
+ * @retval #USB_HOST_ERROR_NOT_SUPPORTED Not supported
+ * @retval #USB_HOST_ERROR_RESOURCE_BUSY Interfaces are currently claimed
+ * @retval #USB_HOST_ERROR_NO_SUCH_DEVICE Device has beed disconnected
+ */
+int usb_host_device_unconfigure(usb_host_device_h dev);
+
 /**
  * @ingroup CAPI_USB_HOST_DEV_MODULE
  * @brief Gets USB specification release number.
index 0e2356b50442ee8e9f611e5dd5a92ac48365455c..14f185bda484ec38161f38e39140b49e8fd72941 100644 (file)
@@ -899,6 +899,27 @@ int usb_host_set_config(usb_host_config_h configuration)
        return ret;
 }
 
+int usb_host_device_unconfigure(usb_host_device_h dev)
+{
+       int ret;
+
+       if (!usb_host_feature_enabled())
+               return USB_HOST_ERROR_NOT_SUPPORTED;
+
+       if (!dev) {
+               _E("Ivalid parameter was passed");
+               return USB_HOST_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = libusb_set_configuration(dev->lusb_dev_handle, -1);
+       if (ret < 0) {
+               _E("Could not put device in unconfigured state");
+               return translate_error(ret);
+       }
+
+       return USB_HOST_ERROR_NONE;
+}
+
 int usb_host_claim_interface(usb_host_interface_h interface, bool force)
 {
        int ret = USB_HOST_ERROR_INVALID_PARAMETER;