Skip to content

Commit

Permalink
DM USB: add libusb error conversion function
Browse files Browse the repository at this point in the history
Add a function to covert libusb error to the common USB core
error type.

Change-Id: Icb03fae2acdc914b3d32a5942faf7d79793a4bee
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
  • Loading branch information
xiaoguangwu authored and lijinxia committed May 29, 2018
1 parent 2d1fb7e commit b12527f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions devicemodel/hw/platform/usb_pmapper.c
Expand Up @@ -44,6 +44,21 @@

static struct usb_dev_sys_ctx_info g_ctx;

static inline int
usb_dev_err_convert(int err)
{
switch (err) {
case LIBUSB_ERROR_TIMEOUT: return USB_ERR_TIMEOUT;
case LIBUSB_ERROR_PIPE: return USB_ERR_STALLED;
case LIBUSB_ERROR_NO_DEVICE: return USB_ERR_INVAL;
case LIBUSB_ERROR_BUSY: return USB_ERR_IN_USE;
case LIBUSB_ERROR_OVERFLOW: return USB_ERR_TOO_DEEP;
default:
break; /* add more when required */
}
return USB_ERR_IOERROR;
}

static int
usb_dev_native_toggle_if_drivers(struct usb_dev *udev, int attach)
{
Expand Down

0 comments on commit b12527f

Please sign in to comment.