From: Hans de Goede Date: Fri, 2 Mar 2012 20:27:18 +0000 (+0100) Subject: usb-ehci: Cleanup itd error handling X-Git-Tag: v1.1-rc0~262^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5eafd438c9e3b7b698c4a4ec755f52d8dfb870ae;p=thirdparty%2Fqemu.git usb-ehci: Cleanup itd error handling All error statuses except for NAK are handled in a switch case, move the handling of NAK into the same switch case. Signed-off-by: Hans de Goede Signed-off-by: Gerd Hoffmann --- diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c index 9197298e45f..825fcc05b31 100644 --- a/hw/usb-ehci.c +++ b/hw/usb-ehci.c @@ -1466,20 +1466,7 @@ static int ehci_process_itd(EHCIState *ehci, } qemu_sglist_destroy(&ehci->isgl); - if (ret == USB_RET_NAK) { - /* no data for us, so do a zero-length transfer */ - ret = 0; - } - - if (ret >= 0) { - if (!dir) { - /* OUT */ - set_field(&itd->transact[i], len - ret, ITD_XACT_LENGTH); - } else { - /* IN */ - set_field(&itd->transact[i], ret, ITD_XACT_LENGTH); - } - } else { + if (ret < 0) { switch (ret) { default: fprintf(stderr, "Unexpected iso usb result: %d\n", ret); @@ -1495,6 +1482,19 @@ static int ehci_process_itd(EHCIState *ehci, itd->transact[i] |= ITD_XACT_BABBLE; ehci_record_interrupt(ehci, USBSTS_ERRINT); break; + case USB_RET_NAK: + /* no data for us, so do a zero-length transfer */ + ret = 0; + break; + } + } + if (ret >= 0) { + if (!dir) { + /* OUT */ + set_field(&itd->transact[i], len - ret, ITD_XACT_LENGTH); + } else { + /* IN */ + set_field(&itd->transact[i], ret, ITD_XACT_LENGTH); } } if (itd->transact[i] & ITD_XACT_IOC) {