Skip to content

Commit

Permalink
DM USB: process LIBUSB_TRANSFER_STALL error
Browse files Browse the repository at this point in the history
Handle the LIBUSB_TRANSFER_STALL error comes from libusb.

Change-Id: Id6911e9aaffafb256def5265a0ed9778b147d99a
Tracked-On:
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Liang Yang <liang3.yang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
  • Loading branch information
xiaoguangwu authored and lijinxia committed Jul 20, 2018
1 parent 640d896 commit a49d483
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions devicemodel/hw/platform/usb_pmapper.c
Expand Up @@ -55,6 +55,7 @@ usb_dev_comp_req(struct libusb_transfer *libusb_xfer)
int len, do_intr = 0, short_data = 0;
int i, idx, buf_idx, done;
int bstart, bcount;
int is_stalled = 0;

assert(libusb_xfer);

Expand Down Expand Up @@ -85,14 +86,16 @@ usb_dev_comp_req(struct libusb_transfer *libusb_xfer)
switch (libusb_xfer->status) {
case LIBUSB_TRANSFER_STALL:
xfer->status = USB_ERR_STALLED;
goto out;
is_stalled = 1;
goto stall_out;
case LIBUSB_TRANSFER_NO_DEVICE:
/* avoid short packet warnings when devices are plugged out. */
xfer->status = USB_ERR_SHORT_XFER;
goto out;
case LIBUSB_TRANSFER_ERROR:
is_stalled = 1;
xfer->status = USB_ERR_STALLED;
goto out;
goto stall_out;
case LIBUSB_TRANSFER_CANCELLED:
xfer->status = USB_ERR_IOERROR;
goto out;
Expand Down Expand Up @@ -156,6 +159,14 @@ usb_dev_comp_req(struct libusb_transfer *libusb_xfer)
idx = (idx + 1) % USB_MAX_XFER_BLOCKS;
}

stall_out:
if (is_stalled) {
for (i = 0, idx = req->blk_start; i < req->blk_count; ++i) {
block = &xfer->data[idx % USB_MAX_XFER_BLOCKS];
block->processed = USB_XFER_BLK_HANDLED;
}
}

if (short_data)
xfer->status = USB_ERR_SHORT_XFER;

Expand Down

0 comments on commit a49d483

Please sign in to comment.