From df7ea6a5445e24d560cc068d6c349e2330df2b42 Mon Sep 17 00:00:00 2001 From: hechaofan Date: Tue, 23 Jul 2024 11:02:14 +0800 Subject: [PATCH 1/7] =?UTF-8?q?releaseInterface=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hechaofan --- usb/hdi_service/src/usb_impl.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/usb/hdi_service/src/usb_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index 9161fc4096..4a111e30b7 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -1381,7 +1381,14 @@ int32_t UsbImpl::ReleaseInterface(const UsbDev &dev, uint8_t interfaceId) HDF_LOGE("%{public}s:ReleaseInterface failed.", __func__); return HDF_ERR_INVALID_PARAM; } - port->initFlag = false; + int32_t ret = 0; + if (port->ctrDevHandle != nullptr) { + ret = UsbCloseInterface(port->ctrDevHandle, true); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%{public}s:usbCloseInterface ctrDevHandle failed.", __func__); + return HDF_FAILURE; + } + } return HDF_SUCCESS; } -- Gitee From e97517c14cf5e6ce85e2121f6f3cf39e9cb64d4f Mon Sep 17 00:00:00 2001 From: hechaofan Date: Tue, 23 Jul 2024 12:25:08 +0000 Subject: [PATCH 2/7] update usb/hdi_service/src/usb_impl.cpp. Signed-off-by: hechaofan --- usb/hdi_service/src/usb_impl.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/usb/hdi_service/src/usb_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index 4a111e30b7..15c9b2176f 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -1381,13 +1381,12 @@ int32_t UsbImpl::ReleaseInterface(const UsbDev &dev, uint8_t interfaceId) HDF_LOGE("%{public}s:ReleaseInterface failed.", __func__); return HDF_ERR_INVALID_PARAM; } - int32_t ret = 0; - if (port->ctrDevHandle != nullptr) { - ret = UsbCloseInterface(port->ctrDevHandle, true); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s:usbCloseInterface ctrDevHandle failed.", __func__); - return HDF_FAILURE; - } + + UsbInterfaceHandleEntity *handle = reinterpret_cast(port->ctrDevHandle); + int32_t ret = RawReleaseInterface(handle->devHandle, interfaceId); + if (ret != 0) { + HDF_LOGE("%{public}s:ReleaseInterface failed, ret = %{public}d", __func__, ret); + return HDF_ERR_INVALID_PARAM; } return HDF_SUCCESS; } -- Gitee From a0251413f2ae20386b8df8f98b8a544ae16744f4 Mon Sep 17 00:00:00 2001 From: hechaofan Date: Tue, 23 Jul 2024 13:31:29 +0000 Subject: [PATCH 3/7] update usb/hdi_service/src/usb_impl.cpp. Signed-off-by: hechaofan --- usb/hdi_service/src/usb_impl.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/usb/hdi_service/src/usb_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index 15c9b2176f..2761e2cc24 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -1381,14 +1381,28 @@ int32_t UsbImpl::ReleaseInterface(const UsbDev &dev, uint8_t interfaceId) HDF_LOGE("%{public}s:ReleaseInterface failed.", __func__); return HDF_ERR_INVALID_PARAM; } - + + struct UsbInterface *interface = nullptr; UsbInterfaceHandleEntity *handle = reinterpret_cast(port->ctrDevHandle); - int32_t ret = RawReleaseInterface(handle->devHandle, interfaceId); + const UsbInterfaceHandle *interfaceHandle = (const UsbInterfaceHandle *)handle; + int32_t ret = GetInterfaceByHandle(interfaceHandle, &interface); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%{public}s get interface failed %{public}d", __func__, ret); + return ret; + } + + ret = UsbCloseInterface(interfaceHandle, false); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%{public}s close interface failed %{public}d", __func__, ret); + return ret; + } + + ret = UsbReleaseInterface(interface); if (ret != 0) { HDF_LOGE("%{public}s:ReleaseInterface failed, ret = %{public}d", __func__, ret); return HDF_ERR_INVALID_PARAM; } - return HDF_SUCCESS; + return ret; } int32_t UsbImpl::SetInterface(const UsbDev &dev, uint8_t interfaceId, uint8_t altIndex) -- Gitee From b12056b8e0db5772449e2257c4467364fd064c06 Mon Sep 17 00:00:00 2001 From: hechaofan Date: Wed, 24 Jul 2024 01:49:05 +0000 Subject: [PATCH 4/7] update usb/hdi_service/src/usb_impl.cpp. Signed-off-by: hechaofan --- usb/hdi_service/src/usb_impl.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/usb/hdi_service/src/usb_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index 2761e2cc24..5d7e088b94 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -1377,14 +1377,14 @@ int32_t UsbImpl::ReleaseInterface(const UsbDev &dev, uint8_t interfaceId) return HDF_DEV_ERR_NO_DEVICE; } - if (interfaceId >= USB_MAX_INTERFACES) { - HDF_LOGE("%{public}s:ReleaseInterface failed.", __func__); - return HDF_ERR_INVALID_PARAM; + struct UsbInterface *interface = nullptr; + UsbInterfaceHandle *interfaceHandle = InterfaceIdToHandle(port, interfaceId); + if (interfaceHandle == nullptr || interfaceId >= USB_MAX_INTERFACES) { + HDF_LOGE("%{public}s:interfaceId failed busNum:%{public}u devAddr:%{public}u interfaceId:%{public}u", __func__, + port->busNum, port->devAddr, interfaceId); + return HDF_FAILURE; } - struct UsbInterface *interface = nullptr; - UsbInterfaceHandleEntity *handle = reinterpret_cast(port->ctrDevHandle); - const UsbInterfaceHandle *interfaceHandle = (const UsbInterfaceHandle *)handle; int32_t ret = GetInterfaceByHandle(interfaceHandle, &interface); if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s get interface failed %{public}d", __func__, ret); -- Gitee From 723f9f7b7ad343b07417e349c038d4bb3a92071a Mon Sep 17 00:00:00 2001 From: hechaofan Date: Wed, 24 Jul 2024 03:04:04 +0000 Subject: [PATCH 5/7] update usb/hdi_service/src/usb_impl.cpp. Signed-off-by: hechaofan --- usb/hdi_service/src/usb_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usb/hdi_service/src/usb_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index 5d7e088b94..8402df7482 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -1398,9 +1398,9 @@ int32_t UsbImpl::ReleaseInterface(const UsbDev &dev, uint8_t interfaceId) } ret = UsbReleaseInterface(interface); - if (ret != 0) { + if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s:ReleaseInterface failed, ret = %{public}d", __func__, ret); - return HDF_ERR_INVALID_PARAM; + return ret; } return ret; } -- Gitee From ec416880038d06c37c1bc3f6acb3a33d925541af Mon Sep 17 00:00:00 2001 From: hechaofan Date: Wed, 24 Jul 2024 03:05:43 +0000 Subject: [PATCH 6/7] update usb/hdi_service/src/usb_impl.cpp. Signed-off-by: hechaofan --- usb/hdi_service/src/usb_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usb/hdi_service/src/usb_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index 8402df7482..ed98c3a1e3 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -1377,14 +1377,14 @@ int32_t UsbImpl::ReleaseInterface(const UsbDev &dev, uint8_t interfaceId) return HDF_DEV_ERR_NO_DEVICE; } - struct UsbInterface *interface = nullptr; UsbInterfaceHandle *interfaceHandle = InterfaceIdToHandle(port, interfaceId); if (interfaceHandle == nullptr || interfaceId >= USB_MAX_INTERFACES) { HDF_LOGE("%{public}s:interfaceId failed busNum:%{public}u devAddr:%{public}u interfaceId:%{public}u", __func__, port->busNum, port->devAddr, interfaceId); return HDF_FAILURE; } - + + struct UsbInterface *interface = nullptr; int32_t ret = GetInterfaceByHandle(interfaceHandle, &interface); if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s get interface failed %{public}d", __func__, ret); -- Gitee From 9acd2f0a215ee69898a486ee0c67d14fc21c6487 Mon Sep 17 00:00:00 2001 From: hechaofan Date: Wed, 24 Jul 2024 03:07:38 +0000 Subject: [PATCH 7/7] update usb/hdi_service/src/usb_impl.cpp. Signed-off-by: hechaofan --- usb/hdi_service/src/usb_impl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/usb/hdi_service/src/usb_impl.cpp b/usb/hdi_service/src/usb_impl.cpp index ed98c3a1e3..3a054d638b 100644 --- a/usb/hdi_service/src/usb_impl.cpp +++ b/usb/hdi_service/src/usb_impl.cpp @@ -1400,7 +1400,6 @@ int32_t UsbImpl::ReleaseInterface(const UsbDev &dev, uint8_t interfaceId) ret = UsbReleaseInterface(interface); if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s:ReleaseInterface failed, ret = %{public}d", __func__, ret); - return ret; } return ret; } -- Gitee