From a49d483cd05507c40db9b3575b32d89a0c861f03 Mon Sep 17 00:00:00 2001 From: Xiaoguang Wu Date: Tue, 17 Jul 2018 21:27:17 +0800 Subject: [PATCH] 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 Reviewed-by: Liang Yang Acked-by: Yu Wang --- devicemodel/hw/platform/usb_pmapper.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/devicemodel/hw/platform/usb_pmapper.c b/devicemodel/hw/platform/usb_pmapper.c index d5d6e8d23..5e31e0290 100644 --- a/devicemodel/hw/platform/usb_pmapper.c +++ b/devicemodel/hw/platform/usb_pmapper.c @@ -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); @@ -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; @@ -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;