diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2019-06-25 12:47:31 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-27 17:51:06 +0000 |
commit | 6160e479f6a5aad9cabf7d831ff63f4dd14e9704 (patch) | |
tree | f7f451a5ad82a3fb80680db4a833df9632e908e8 /devices/src/usb/host_backend/host_backend_device_provider.rs | |
parent | 6a8cd101b2e81e0478fb0fe6659759bad470e213 (diff) | |
download | crosvm-6160e479f6a5aad9cabf7d831ff63f4dd14e9704.tar crosvm-6160e479f6a5aad9cabf7d831ff63f4dd14e9704.tar.gz crosvm-6160e479f6a5aad9cabf7d831ff63f4dd14e9704.tar.bz2 crosvm-6160e479f6a5aad9cabf7d831ff63f4dd14e9704.tar.lz crosvm-6160e479f6a5aad9cabf7d831ff63f4dd14e9704.tar.xz crosvm-6160e479f6a5aad9cabf7d831ff63f4dd14e9704.tar.zst crosvm-6160e479f6a5aad9cabf7d831ff63f4dd14e9704.zip |
usb: switch to new libusb_wrap_sys_device API
Replace use of our custom, patched libusb APIs with the new libusb_wrap_sys_device() function, which has been submitted to libusb upstream. This allows us to drop the bindings for the custom APIs (and will also allow us to drop the libusb patch that introduces them). For now, keep this path behind the sandboxed-libusb feature to allow crosvm to build against older libusb versions that do not have the new API. This should be cleaned up eventually once we are comfortable with raising the minimum libusb version required. BUG=b:133773289 TEST=Attach Android device to Linux VM; deploy app via adb Change-Id: Ie249c6f3f3b4c63210dd163ca7ad03e2de8a8872 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1676601 Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'devices/src/usb/host_backend/host_backend_device_provider.rs')
-rw-r--r-- | devices/src/usb/host_backend/host_backend_device_provider.rs | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/devices/src/usb/host_backend/host_backend_device_provider.rs b/devices/src/usb/host_backend/host_backend_device_provider.rs index 01fd84c..f479bcb 100644 --- a/devices/src/usb/host_backend/host_backend_device_provider.rs +++ b/devices/src/usb/host_backend/host_backend_device_provider.rs @@ -209,9 +209,7 @@ impl ProviderInner { } }; - let device_fd = usb_file.as_raw_fd(); - - let device = match self.ctx.get_device(usb_file) { + let device_handle = match self.ctx.get_device_handle(usb_file) { Some(d) => d, None => { error!( @@ -228,22 +226,7 @@ impl ProviderInner { } }; - let device_handle = { - // This is safe only when fd is an fd of the current device. - match unsafe { device.open_fd(device_fd) } { - Ok(handle) => handle, - Err(e) => { - error!("fail to open device: {:?}", e); - // The send failure will be logged, but event loop still think - // the event is handled. - let _ = self - .sock - .send(&UsbControlResult::FailedToOpenDevice) - .map_err(Error::WriteControlSock); - return Ok(()); - } - } - }; + let device = device_handle.get_device(); // Resetting the device is used to make sure it is in a known state, but it may // still function if the reset fails. |