api: Add API for unconfiguring devices 32/147632/1
authorlokilee73 <changjoo.lee@samsung.com>
Tue, 5 Sep 2017 07:09:52 +0000 (16:09 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Tue, 5 Sep 2017 07:09:58 +0000 (16:09 +0900)
Change-Id: Ifca8048c37708f331f94e2667350704c61113860
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
include/usb_host.h [changed mode: 0644->0755]
src/usb_host.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 669e978..1256345
@@ -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.
old mode 100644 (file)
new mode 100755 (executable)
index 708e0bc..76dc5b1
@@ -893,6 +893,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;