From 7f74a56b1416a759c1da0a280e99242662f350c5 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 11 Jan 2012 11:16:20 +0100 Subject: usb: kill handle_packet callback All drivers except usb-hub use usb_generic_handle_packet. The only reason the usb hub has its own function is that it used to be called with packets which are intended for downstream devices. With the new, separate device lookup step this doesn't happen any more, so the need for a different handle_packet callback is gone. So we can kill the handle_packet callback and just call usb_generic_handle_packet directly. The special hub handling in usb_handle_packet() can go away for the same reason. Signed-off-by: Gerd Hoffmann --- hw/usb-hid.c | 1 - 1 file changed, 1 deletion(-) (limited to 'hw/usb-hid.c') diff --git a/hw/usb-hid.c b/hw/usb-hid.c index 3c4e45d..c648980 100644 --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -557,7 +557,6 @@ static void usb_hid_class_initfn(ObjectClass *klass, void *data) { USBDeviceClass *uc = USB_DEVICE_CLASS(klass); - uc->handle_packet = usb_generic_handle_packet; uc->handle_reset = usb_hid_handle_reset; uc->handle_control = usb_hid_handle_control; uc->handle_data = usb_hid_handle_data; -- cgit v1.1 From 079d0b7f1eedcc634c371fe05b617fdc55c8b762 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 12 Jan 2012 13:23:01 +0100 Subject: usb: Set USBEndpoint in usb_packet_setup(). With the separation of the device lookup (via usb_find_device) and packet processing we can lookup device and endpoint before setting up the usb packet. So we can initialize USBPacket->ep early and keep it valid for the whole lifecycle of the USBPacket. Also the devaddr and devep fields are not needed any more. Signed-off-by: Gerd Hoffmann --- hw/usb-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/usb-hid.c') diff --git a/hw/usb-hid.c b/hw/usb-hid.c index c648980..4d00c28 100644 --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -463,7 +463,7 @@ static int usb_hid_handle_data(USBDevice *dev, USBPacket *p) switch (p->pid) { case USB_TOKEN_IN: - if (p->devep == 1) { + if (p->ep->nr == 1) { int64_t curtime = qemu_get_clock_ns(vm_clock); if (!hid_has_events(hs) && (!hs->idle || hs->next_idle_clock - curtime > 0)) { -- cgit v1.1 From 7567b51fbe92e1300a672eaddd413c4a7e807d90 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 17 Jan 2012 13:25:46 +0100 Subject: usb: pass USBEndpoint to usb_wakeup Devices must specify which endpoint has data to transfer now. The plan is to use the usb_wakeup() not only for remove wakeup support, but for "data ready" signaling in general, so we can move away from constant polling to event driven usb device emulation. Signed-off-by: Gerd Hoffmann --- hw/usb-hid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'hw/usb-hid.c') diff --git a/hw/usb-hid.c b/hw/usb-hid.c index 4d00c28..53353d3 100644 --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -44,6 +44,7 @@ typedef struct USBHIDState { USBDevice dev; + USBEndpoint *intr; HIDState hid; } USBHIDState; @@ -360,7 +361,7 @@ static void usb_hid_changed(HIDState *hs) { USBHIDState *us = container_of(hs, USBHIDState, hid); - usb_wakeup(&us->dev); + usb_wakeup(us->intr); } static void usb_hid_handle_reset(USBDevice *dev) @@ -501,6 +502,7 @@ static int usb_hid_initfn(USBDevice *dev, int kind) USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev); usb_desc_init(dev); + us->intr = usb_ep_get(dev, USB_TOKEN_IN, 1); hid_init(&us->hid, kind, usb_hid_changed); return 0; } -- cgit v1.1