From 4f4321c11ff6e98583846bfd6f0e81954924b003 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 12 Jul 2011 15:22:25 +0200 Subject: 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 --- hw/usb-hid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'hw/usb-hid.c') diff --git a/hw/usb-hid.c b/hw/usb-hid.c index 9008320c8..541644a06 100644 --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -816,6 +816,7 @@ static int usb_hid_handle_control(USBDevice *dev, USBPacket *p, static int usb_hid_handle_data(USBDevice *dev, USBPacket *p) { USBHIDState *s = (USBHIDState *)dev; + uint8_t buf[p->iov.size]; int ret = 0; switch(p->pid) { @@ -826,11 +827,12 @@ static int usb_hid_handle_data(USBDevice *dev, USBPacket *p) return USB_RET_NAK; usb_hid_set_next_idle(s, curtime); if (s->kind == USB_MOUSE || s->kind == USB_TABLET) { - ret = usb_pointer_poll(s, p->data, p->len); + ret = usb_pointer_poll(s, buf, p->iov.size); } else if (s->kind == USB_KEYBOARD) { - ret = usb_keyboard_poll(s, p->data, p->len); + ret = usb_keyboard_poll(s, buf, p->iov.size); } + usb_packet_copy(p, buf, ret); s->changed = s->n > 0; } else { goto fail; -- cgit v1.2.3