Skip to content

Commit b12527f

Browse files
xiaoguangwulijinxia
authored andcommitted
DM USB: add libusb error conversion function
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>
1 parent 2d1fb7e commit b12527f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

devicemodel/hw/platform/usb_pmapper.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@
4444

4545
static struct usb_dev_sys_ctx_info g_ctx;
4646

47+
static inline int
48+
usb_dev_err_convert(int err)
49+
{
50+
switch (err) {
51+
case LIBUSB_ERROR_TIMEOUT: return USB_ERR_TIMEOUT;
52+
case LIBUSB_ERROR_PIPE: return USB_ERR_STALLED;
53+
case LIBUSB_ERROR_NO_DEVICE: return USB_ERR_INVAL;
54+
case LIBUSB_ERROR_BUSY: return USB_ERR_IN_USE;
55+
case LIBUSB_ERROR_OVERFLOW: return USB_ERR_TOO_DEEP;
56+
default:
57+
break; /* add more when required */
58+
}
59+
return USB_ERR_IOERROR;
60+
}
61+
4762
static int
4863
usb_dev_native_toggle_if_drivers(struct usb_dev *udev, int attach)
4964
{

0 commit comments

Comments
 (0)