DM USB: xHCI: refine the de-init logic of xHCI vdevice

Add 'full' and 'non-full' de-initialize support for xHCI virtual
device. The non-full de-initialization mainly release usb_dev
structure and unbind the usbfs with native device. And the full
de-initialize will release all the resources allocated for xHCI
virtual device including the unbinding operation mentioned above

Tracked-On: #2576
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Xiaoguang Wu
2019-02-18 13:30:53 +08:00
committed by wenlingz
parent 76a5131b37
commit b77755cd58
4 changed files with 50 additions and 31 deletions

View File

@@ -1054,22 +1054,27 @@ errout:
}
void
usb_dev_deinit(void *pdata)
usb_dev_deinit(void *pdata, bool full)
{
int rc = 0;
struct usb_dev *udev;
udev = pdata;
if (udev) {
if (udev->handle) {
rc = usb_dev_native_toggle_if_drivers(udev, 1);
if (rc)
UPRINTF(LWRN, "fail to attach if drv rc:%d\r\n",
rc);
libusb_close(udev->handle);
}
if (!udev)
return;
if (!udev->handle)
goto out;
rc = usb_dev_native_toggle_if_drivers(udev, 1);
if (rc)
UPRINTF(LWRN, "fail to attach if drv rc:%d\r\n", rc);
libusb_close(udev->handle);
udev->handle = NULL;
out:
if (full)
free(udev);
}
}
int