From 4706ab6cc0af86d3f38806664420cc3eb8999bd9 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 24 Jun 2011 12:31:11 +0200 Subject: usb: Replace device_destroy bus op with a child_detach port op Note this fixes 2 things in one go, first of all the device_destroy bus op should be a device_detach bus op, as pending async packets from the device should be cancelled on detach not on destroy. Secondly having this as a bus op won't work with companion controllers, since then there will be 1 bus driven by the ehci controller and thus 1 set of bus ops, but the device being detached may be downstream of a handed over port. Making the detach of a downstream device a port op allows the ehci controller to forward this to the companion controller port for handed over ports. Signed-off-by: Hans de Goede Signed-off-by: Gerd Hoffmann --- hw/usb-ehci.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'hw/usb-ehci.c') diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c index 428c90bcf3..96451f334d 100644 --- a/hw/usb-ehci.c +++ b/hw/usb-ehci.c @@ -751,6 +751,8 @@ static void ehci_detach(USBPort *port) trace_usb_ehci_port_detach(port->index); + ehci_queues_rip_device(s, port->dev); + *portsc &= ~PORTSC_CONNECT; *portsc |= PORTSC_CSC; @@ -764,6 +766,13 @@ static void ehci_detach(USBPort *port) } } +static void ehci_child_detach(USBPort *port, USBDevice *child) +{ + EHCIState *s = port->opaque; + + ehci_queues_rip_device(s, child); +} + /* 4.1 host controller initialization */ static void ehci_reset(void *opaque) { @@ -2117,23 +2126,16 @@ static void ehci_map(PCIDevice *pci_dev, int region_num, cpu_register_physical_memory(addr, size, s->mem); } -static void ehci_device_destroy(USBBus *bus, USBDevice *dev) -{ - EHCIState *s = container_of(bus, EHCIState, bus); - - ehci_queues_rip_device(s, dev); -} - static int usb_ehci_initfn(PCIDevice *dev); static USBPortOps ehci_port_ops = { .attach = ehci_attach, .detach = ehci_detach, + .child_detach = ehci_child_detach, .complete = ehci_async_complete_packet, }; static USBBusOps ehci_bus_ops = { - .device_destroy = ehci_device_destroy, }; static PCIDeviceInfo ehci_info = { -- cgit v1.2.3