diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2012-01-12 13:23:01 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2012-02-10 11:31:57 +0100 |
commit | 079d0b7f1eedcc634c371fe05b617fdc55c8b762 (patch) | |
tree | 60ee42f36b295edb49fcb62af5912f769efa9991 /hw/usb-ehci.c | |
parent | 63095ab54c1ce554b1fc825fc678394ccb129e5b (diff) |
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 <kraxel@redhat.com>
Diffstat (limited to 'hw/usb-ehci.c')
-rw-r--r-- | hw/usb-ehci.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c index f0213adec2..6c01ca93a9 100644 --- a/hw/usb-ehci.c +++ b/hw/usb-ehci.c @@ -1357,6 +1357,7 @@ err: static int ehci_execute(EHCIQueue *q) { USBDevice *dev; + USBEndpoint *ep; int ret; int endp; int devadr; @@ -1387,13 +1388,13 @@ static int ehci_execute(EHCIQueue *q) endp = get_field(q->qh.epchar, QH_EPCHAR_EP); devadr = get_field(q->qh.epchar, QH_EPCHAR_DEVADDR); - ret = USB_RET_NODEV; + /* TODO: associating device with ehci port */ + dev = ehci_find_device(q->ehci, devadr); + ep = usb_ep_get(dev, q->pid, endp); - usb_packet_setup(&q->packet, q->pid, devadr, endp); + usb_packet_setup(&q->packet, q->pid, ep); usb_packet_map(&q->packet, &q->sgl); - // TO-DO: associating device with ehci port - dev = ehci_find_device(q->ehci, q->packet.devaddr); ret = usb_handle_packet(dev, &q->packet); DPRINTF("submit: qh %x next %x qtd %x pid %x len %zd " "(total %d) endp %x ret %d\n", @@ -1415,6 +1416,7 @@ static int ehci_process_itd(EHCIState *ehci, EHCIitd *itd) { USBDevice *dev; + USBEndpoint *ep; int ret; uint32_t i, len, pid, dir, devaddr, endp; uint32_t pg, off, ptr1, ptr2, max, mult; @@ -1454,10 +1456,11 @@ static int ehci_process_itd(EHCIState *ehci, pid = dir ? USB_TOKEN_IN : USB_TOKEN_OUT; - usb_packet_setup(&ehci->ipacket, pid, devaddr, endp); + dev = ehci_find_device(ehci, devaddr); + ep = usb_ep_get(dev, pid, endp); + usb_packet_setup(&ehci->ipacket, pid, ep); usb_packet_map(&ehci->ipacket, &ehci->isgl); - dev = ehci_find_device(ehci, ehci->ipacket.devaddr); ret = usb_handle_packet(dev, &ehci->ipacket); usb_packet_unmap(&ehci->ipacket); |