From: Paweł Szewczyk
Date: Mon, 19 Jun 2017 09:18:19 +0000 (+0200)
Subject: api: Add API for unconfiguring devices
X-Git-Tag: submit/tizen/20170905.070056~1
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2757d43fd15aca6ddc45c2f54aab6289460bcc2e;p=platform%2Fcore%2Fapi%2Fusb-host.git
api: Add API for unconfiguring devices
Change-Id: I52d1521cd1d4e6aee0ca81c56414f8cbd68c52be
Signed-off-by: Paweł Szewczyk
---
diff --git a/include/usb_host.h b/include/usb_host.h
index 669e978..1256345 100644
--- a/include/usb_host.h
+++ b/include/usb_host.h
@@ -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.
diff --git a/src/usb_host.c b/src/usb_host.c
index 0e2356b..14f185b 100644
--- a/src/usb_host.c
+++ b/src/usb_host.c
@@ -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;