From e50ba38a7daf353077631e45f4b8c3ac619d6de9 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 12 Apr 2019 11:42:35 -0700 Subject: usb: Simplify imports from usb_util The devices crate imports things from usb_util which is a separate crate. Importing from a crate normally looks like: use name_of_crate::path::to::ThingToImport; In the case it would be e.g.: use usb_util::hotplug::UsbHotplugHandler; Importing these things through crate::usb::usb_util is unnecessary. TEST=cargo check Change-Id: I70554639a71b2423c1e13a30361d5f9d92e9d9a9 Reviewed-on: https://chromium-review.googlesource.com/1565725 Commit-Ready: David Tolnay Commit-Ready: ChromeOS CL Exonerator Bot Tested-by: David Tolnay Tested-by: kokoro Reviewed-by: Jingkui Wang --- devices/src/usb/host_backend/context.rs | 6 +++--- devices/src/usb/host_backend/error.rs | 2 +- devices/src/usb/host_backend/host_device.rs | 20 ++++++++++---------- devices/src/usb/host_backend/hotplug.rs | 4 ++-- devices/src/usb/host_backend/usb_endpoint.rs | 10 +++++----- devices/src/usb/host_backend/utils.rs | 4 ++-- devices/src/usb/xhci/xhci_transfer.rs | 4 ++-- 7 files changed, 25 insertions(+), 25 deletions(-) (limited to 'devices/src/usb') diff --git a/devices/src/usb/host_backend/context.rs b/devices/src/usb/host_backend/context.rs index 5d8b689..4acd752 100644 --- a/devices/src/usb/host_backend/context.rs +++ b/devices/src/usb/host_backend/context.rs @@ -3,14 +3,14 @@ // found in the LICENSE file. use super::error::*; -use crate::usb::usb_util::hotplug::UsbHotplugHandler; -use crate::usb::usb_util::libusb_context::{LibUsbContext, LibUsbPollfdChangeHandler}; -use crate::usb::usb_util::libusb_device::LibUsbDevice; use crate::utils::{EventHandler, EventLoop}; use std::os::raw::c_short; use std::os::unix::io::RawFd; use std::sync::{Arc, Weak}; use sys_util::WatchingEvents; +use usb_util::hotplug::UsbHotplugHandler; +use usb_util::libusb_context::{LibUsbContext, LibUsbPollfdChangeHandler}; +use usb_util::libusb_device::LibUsbDevice; use vm_control::MaybeOwnedFd; /// Context wraps libusb context with libusb event handling. diff --git a/devices/src/usb/host_backend/error.rs b/devices/src/usb/host_backend/error.rs index c9906ca..17ac191 100644 --- a/devices/src/usb/host_backend/error.rs +++ b/devices/src/usb/host_backend/error.rs @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use crate::usb::usb_util::error::Error as UsbUtilError; use crate::usb::xhci::scatter_gather_buffer::Error as BufferError; use crate::usb::xhci::xhci_transfer::Error as XhciTransferError; use crate::utils::Error as UtilsError; use msg_socket::MsgError; use std::fmt::{self, Display}; +use usb_util::error::Error as UsbUtilError; #[derive(Debug)] pub enum Error { diff --git a/devices/src/usb/host_backend/host_device.rs b/devices/src/usb/host_backend/host_device.rs index 8a47037..00cd876 100644 --- a/devices/src/usb/host_backend/host_device.rs +++ b/devices/src/usb/host_backend/host_device.rs @@ -9,22 +9,22 @@ use sync::Mutex; use super::error::*; use super::usb_endpoint::UsbEndpoint; use super::utils::{submit_transfer, update_transfer_state}; -use crate::usb::usb_util::device_handle::DeviceHandle; -use crate::usb::usb_util::error::Error as LibUsbError; -use crate::usb::usb_util::libusb_device::LibUsbDevice; -use crate::usb::usb_util::types::{ - ControlRequestDataPhaseTransferDirection, ControlRequestRecipient, ControlRequestType, - StandardControlRequest, UsbRequestSetup, -}; -use crate::usb::usb_util::usb_transfer::{ - control_transfer, ControlTransferBuffer, TransferStatus, UsbTransfer, -}; use crate::usb::xhci::scatter_gather_buffer::ScatterGatherBuffer; use crate::usb::xhci::xhci_backend_device::{BackendType, UsbDeviceAddress, XhciBackendDevice}; use crate::usb::xhci::xhci_transfer::{XhciTransfer, XhciTransferState, XhciTransferType}; use crate::utils::AsyncJobQueue; use crate::utils::FailHandle; use std::collections::HashMap; +use usb_util::device_handle::DeviceHandle; +use usb_util::error::Error as LibUsbError; +use usb_util::libusb_device::LibUsbDevice; +use usb_util::types::{ + ControlRequestDataPhaseTransferDirection, ControlRequestRecipient, ControlRequestType, + StandardControlRequest, UsbRequestSetup, +}; +use usb_util::usb_transfer::{ + control_transfer, ControlTransferBuffer, TransferStatus, UsbTransfer, +}; #[derive(PartialEq)] pub enum ControlEndpointState { diff --git a/devices/src/usb/host_backend/hotplug.rs b/devices/src/usb/host_backend/hotplug.rs index 8abcfd6..ab1c66d 100644 --- a/devices/src/usb/host_backend/hotplug.rs +++ b/devices/src/usb/host_backend/hotplug.rs @@ -4,9 +4,9 @@ use std::sync::Arc; -use crate::usb::usb_util::hotplug::{HotplugEvent, UsbHotplugHandler}; -use crate::usb::usb_util::libusb_device::LibUsbDevice; use crate::usb::xhci::usb_hub::UsbHub; +use usb_util::hotplug::{HotplugEvent, UsbHotplugHandler}; +use usb_util::libusb_device::LibUsbDevice; pub struct HotplugHandler { hub: Arc, diff --git a/devices/src/usb/host_backend/usb_endpoint.rs b/devices/src/usb/host_backend/usb_endpoint.rs index 7678b88..f562110 100644 --- a/devices/src/usb/host_backend/usb_endpoint.rs +++ b/devices/src/usb/host_backend/usb_endpoint.rs @@ -8,17 +8,17 @@ use sync::Mutex; use super::error::*; use super::utils::{submit_transfer, update_transfer_state}; -use crate::usb::usb_util::device_handle::DeviceHandle; -use crate::usb::usb_util::types::{EndpointDirection, EndpointType, ENDPOINT_DIRECTION_OFFSET}; -use crate::usb::usb_util::usb_transfer::{ - bulk_transfer, interrupt_transfer, BulkTransferBuffer, TransferStatus, UsbTransfer, -}; use crate::usb::xhci::scatter_gather_buffer::ScatterGatherBuffer; use crate::usb::xhci::xhci_transfer::{ TransferDirection, XhciTransfer, XhciTransferState, XhciTransferType, }; use crate::utils::AsyncJobQueue; use crate::utils::FailHandle; +use usb_util::device_handle::DeviceHandle; +use usb_util::types::{EndpointDirection, EndpointType, ENDPOINT_DIRECTION_OFFSET}; +use usb_util::usb_transfer::{ + bulk_transfer, interrupt_transfer, BulkTransferBuffer, TransferStatus, UsbTransfer, +}; /// Isochronous, Bulk or Interrupt endpoint. pub struct UsbEndpoint { diff --git a/devices/src/usb/host_backend/utils.rs b/devices/src/usb/host_backend/utils.rs index 9805f39..d88a1a5 100644 --- a/devices/src/usb/host_backend/utils.rs +++ b/devices/src/usb/host_backend/utils.rs @@ -7,11 +7,11 @@ use std::sync::Arc; use sync::Mutex; use super::error::*; -use crate::usb::usb_util::device_handle::DeviceHandle; -use crate::usb::usb_util::usb_transfer::{TransferStatus, UsbTransfer, UsbTransferBuffer}; use crate::usb::xhci::xhci_transfer::{XhciTransfer, XhciTransferState}; use crate::utils::AsyncJobQueue; use crate::utils::FailHandle; +use usb_util::device_handle::DeviceHandle; +use usb_util::usb_transfer::{TransferStatus, UsbTransfer, UsbTransferBuffer}; /// Helper function to update xhci_transfer state. pub fn update_transfer_state( diff --git a/devices/src/usb/xhci/xhci_transfer.rs b/devices/src/usb/xhci/xhci_transfer.rs index eb50435..421c5b1 100644 --- a/devices/src/usb/xhci/xhci_transfer.rs +++ b/devices/src/usb/xhci/xhci_transfer.rs @@ -10,14 +10,14 @@ use super::xhci_abi::{ TrbCompletionCode, TrbType, }; use super::xhci_regs::MAX_INTERRUPTER; -use crate::usb::usb_util::types::UsbRequestSetup; -use crate::usb::usb_util::usb_transfer::TransferStatus; use std::cmp::min; use std::fmt::{self, Display}; use std::mem; use std::sync::{Arc, Weak}; use sync::Mutex; use sys_util::{Error as SysError, EventFd, GuestMemory}; +use usb_util::types::UsbRequestSetup; +use usb_util::usb_transfer::TransferStatus; #[derive(Debug)] pub enum Error { -- cgit 1.4.1