Skip to content

Commit a49d483

Browse files
xiaoguangwulijinxia
authored andcommitted
DM USB: process LIBUSB_TRANSFER_STALL error
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>
1 parent 640d896 commit a49d483

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

devicemodel/hw/platform/usb_pmapper.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ usb_dev_comp_req(struct libusb_transfer *libusb_xfer)
5555
int len, do_intr = 0, short_data = 0;
5656
int i, idx, buf_idx, done;
5757
int bstart, bcount;
58+
int is_stalled = 0;
5859

5960
assert(libusb_xfer);
6061

@@ -85,14 +86,16 @@ usb_dev_comp_req(struct libusb_transfer *libusb_xfer)
8586
switch (libusb_xfer->status) {
8687
case LIBUSB_TRANSFER_STALL:
8788
xfer->status = USB_ERR_STALLED;
88-
goto out;
89+
is_stalled = 1;
90+
goto stall_out;
8991
case LIBUSB_TRANSFER_NO_DEVICE:
9092
/* avoid short packet warnings when devices are plugged out. */
9193
xfer->status = USB_ERR_SHORT_XFER;
9294
goto out;
9395
case LIBUSB_TRANSFER_ERROR:
96+
is_stalled = 1;
9497
xfer->status = USB_ERR_STALLED;
95-
goto out;
98+
goto stall_out;
9699
case LIBUSB_TRANSFER_CANCELLED:
97100
xfer->status = USB_ERR_IOERROR;
98101
goto out;
@@ -156,6 +159,14 @@ usb_dev_comp_req(struct libusb_transfer *libusb_xfer)
156159
idx = (idx + 1) % USB_MAX_XFER_BLOCKS;
157160
}
158161

162+
stall_out:
163+
if (is_stalled) {
164+
for (i = 0, idx = req->blk_start; i < req->blk_count; ++i) {
165+
block = &xfer->data[idx % USB_MAX_XFER_BLOCKS];
166+
block->processed = USB_XFER_BLK_HANDLED;
167+
}
168+
}
169+
159170
if (short_data)
160171
xfer->status = USB_ERR_SHORT_XFER;
161172

0 commit comments

Comments
 (0)