mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
usb: use iovecs in USBPacket
Zap data pointer from USBPacket, add a QEMUIOVector instead. Add a bunch of helper functions to manage USBPacket data. Switch over users to the new interface. Note that USBPacket->len was used for two purposes: First to pass in the buffer size and second to return the number of transfered bytes or the status code on async transfers. There is a new result variable for the latter. A new status code was added to catch uninitialized result. Nobody creates iovecs with more than one element (yet). Some users are (temporarely) limited to iovecs with a single element to keep the patch size as small as possible. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
d35bf9ade5
commit
4f4321c11f
21 changed files with 338 additions and 222 deletions
|
@ -777,18 +777,17 @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
|
|||
}
|
||||
|
||||
if (completion) {
|
||||
ret = ohci->usb_packet.len;
|
||||
ret = ohci->usb_packet.result;
|
||||
} else {
|
||||
ret = USB_RET_NODEV;
|
||||
for (i = 0; i < ohci->num_ports; i++) {
|
||||
dev = ohci->rhport[i].port.dev;
|
||||
if ((ohci->rhport[i].ctrl & OHCI_PORT_PES) == 0)
|
||||
continue;
|
||||
ohci->usb_packet.pid = pid;
|
||||
ohci->usb_packet.devaddr = OHCI_BM(ed->flags, ED_FA);
|
||||
ohci->usb_packet.devep = OHCI_BM(ed->flags, ED_EN);
|
||||
ohci->usb_packet.data = ohci->usb_buf;
|
||||
ohci->usb_packet.len = len;
|
||||
usb_packet_setup(&ohci->usb_packet, pid,
|
||||
OHCI_BM(ed->flags, ED_FA),
|
||||
OHCI_BM(ed->flags, ED_EN));
|
||||
usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, len);
|
||||
ret = usb_handle_packet(dev, &ohci->usb_packet);
|
||||
if (ret != USB_RET_NODEV)
|
||||
break;
|
||||
|
@ -959,7 +958,7 @@ static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed)
|
|||
}
|
||||
#endif
|
||||
if (completion) {
|
||||
ret = ohci->usb_packet.len;
|
||||
ret = ohci->usb_packet.result;
|
||||
ohci->async_td = 0;
|
||||
ohci->async_complete = 0;
|
||||
} else {
|
||||
|
@ -980,11 +979,10 @@ static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed)
|
|||
#endif
|
||||
return 1;
|
||||
}
|
||||
ohci->usb_packet.pid = pid;
|
||||
ohci->usb_packet.devaddr = OHCI_BM(ed->flags, ED_FA);
|
||||
ohci->usb_packet.devep = OHCI_BM(ed->flags, ED_EN);
|
||||
ohci->usb_packet.data = ohci->usb_buf;
|
||||
ohci->usb_packet.len = len;
|
||||
usb_packet_setup(&ohci->usb_packet, pid,
|
||||
OHCI_BM(ed->flags, ED_FA),
|
||||
OHCI_BM(ed->flags, ED_EN));
|
||||
usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, len);
|
||||
ret = usb_handle_packet(dev, &ohci->usb_packet);
|
||||
if (ret != USB_RET_NODEV)
|
||||
break;
|
||||
|
@ -1761,6 +1759,7 @@ static int usb_ohci_init(OHCIState *ohci, DeviceState *dev,
|
|||
ohci->localmem_base = localmem_base;
|
||||
|
||||
ohci->name = dev->info->name;
|
||||
usb_packet_init(&ohci->usb_packet);
|
||||
|
||||
ohci->async_td = 0;
|
||||
qemu_register_reset(ohci_reset, ohci);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue