diff options
| author | Anthony Liguori <aliguori@us.ibm.com> | 2012-11-14 08:50:18 -0600 |
|---|---|---|
| committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-11-14 08:50:18 -0600 |
| commit | ce5e5b522e8d3b848b6445c34226b69c77c46403 (patch) | |
| tree | 9cd13246a20784e657c3d6d686e0282d1da5ffba /hw/usb/dev-audio.c | |
| parent | bf0dfb69f860a7894958068fba45f5268dddd6be (diff) | |
| parent | 9d1530470bba5d8bec4796c0b43b874d5f9ef017 (diff) | |
| download | focaccia-qemu-ce5e5b522e8d3b848b6445c34226b69c77c46403.tar.gz focaccia-qemu-ce5e5b522e8d3b848b6445c34226b69c77c46403.zip | |
Merge remote-tracking branch 'kraxel/usb.70' into staging
* kraxel/usb.70: ehci: fix migration xhci: Fix some DMA host endian bugs usb/combined-packet: Move freeing of combined to usb_combined_packet_remove() xhci: Add support for packets with both data and an error status ehci: Add support for packets with both data and an error status ehci: Get rid of the magical PROC_ERR status usb-redir: Allow packets to have both data and an error-status usb: split packet result into actual_length + status Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/usb/dev-audio.c')
| -rw-r--r-- | hw/usb/dev-audio.c | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index 2594c78104..b669601c92 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -503,7 +503,7 @@ static int usb_audio_set_control(USBAudioState *s, uint8_t attrib, return ret; } -static int usb_audio_handle_control(USBDevice *dev, USBPacket *p, +static void usb_audio_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { @@ -518,7 +518,7 @@ static int usb_audio_handle_control(USBDevice *dev, USBPacket *p, ret = usb_desc_handle_control(dev, p, request, value, index, length, data); if (ret >= 0) { - return ret; + return; } switch (request) { @@ -534,6 +534,7 @@ static int usb_audio_handle_control(USBDevice *dev, USBPacket *p, } goto fail; } + p->actual_length = ret; break; case ClassInterfaceOutRequest | CR_SET_CUR: @@ -557,10 +558,9 @@ fail: "request 0x%04x value 0x%04x index 0x%04x length 0x%04x\n", request, value, index, length); } - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } static void usb_audio_set_interface(USBDevice *dev, int iface, @@ -583,50 +583,35 @@ static void usb_audio_handle_reset(USBDevice *dev) usb_audio_set_output_altset(s, ALTSET_OFF); } -static int usb_audio_handle_dataout(USBAudioState *s, USBPacket *p) +static void usb_audio_handle_dataout(USBAudioState *s, USBPacket *p) { - int rc; - if (s->out.altset == ALTSET_OFF) { - return USB_RET_STALL; + p->status = USB_RET_STALL; + return; } - rc = streambuf_put(&s->out.buf, p); - if (rc < p->iov.size && s->debug > 1) { + streambuf_put(&s->out.buf, p); + if (p->actual_length < p->iov.size && s->debug > 1) { fprintf(stderr, "usb-audio: output overrun (%zd bytes)\n", - p->iov.size - rc); + p->iov.size - p->actual_length); } - - return 0; } -static int usb_audio_handle_data(USBDevice *dev, USBPacket *p) +static void usb_audio_handle_data(USBDevice *dev, USBPacket *p) { USBAudioState *s = (USBAudioState *) dev; - int ret = 0; - switch (p->pid) { - case USB_TOKEN_OUT: - switch (p->ep->nr) { - case 1: - ret = usb_audio_handle_dataout(s, p); - break; - default: - goto fail; - } - break; - - default: -fail: - ret = USB_RET_STALL; - break; + if (p->pid == USB_TOKEN_OUT && p->ep->nr == 1) { + usb_audio_handle_dataout(s, p); + return; } - if (ret == USB_RET_STALL && s->debug) { + + p->status = USB_RET_STALL; + if (s->debug) { fprintf(stderr, "usb-audio: failed data transaction: " "pid 0x%x ep 0x%x len 0x%zx\n", p->pid, p->ep->nr, p->iov.size); } - return ret; } static void usb_audio_handle_destroy(USBDevice *dev) |