diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2011-05-23 17:37:12 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2011-06-14 12:56:49 +0200 |
commit | 07771f6fcebdb12de6dca537423f56299ed9b4b9 (patch) | |
tree | 374f2b5049bf5dc38984921b76250c590ab65403 /hw/usb-bus.c | |
parent | 8e4faf3de9d1a8bd3289e5cc69d4ed206e2ed0cf (diff) |
usb: cancel async packets on unplug
This patch adds USBBusOps struct with (for now) only a single callback
which is called when a device is about to be destroyed. The USB Host
adapters are implementing this callback and use it to cancel any async
requests which might be in flight before the device actually goes away.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb-bus.c')
-rw-r--r-- | hw/usb-bus.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/hw/usb-bus.c b/hw/usb-bus.c index abc7e61a59..874c253f76 100644 --- a/hw/usb-bus.c +++ b/hw/usb-bus.c @@ -39,9 +39,10 @@ const VMStateDescription vmstate_usb_device = { } }; -void usb_bus_new(USBBus *bus, DeviceState *host) +void usb_bus_new(USBBus *bus, USBBusOps *ops, DeviceState *host) { qbus_create_inplace(&bus->qbus, &usb_bus_info, host, NULL); + bus->ops = ops; bus->busnr = next_usb_bus++; bus->qbus.allow_hotplug = 1; /* Yes, we can */ QTAILQ_INIT(&bus->free); @@ -81,8 +82,10 @@ static int usb_qdev_init(DeviceState *qdev, DeviceInfo *base) static int usb_qdev_exit(DeviceState *qdev) { USBDevice *dev = DO_UPCAST(USBDevice, qdev, qdev); + USBBus *bus = usb_bus_from_device(dev); usb_device_detach(dev); + bus->ops->device_destroy(bus, dev); if (dev->info->handle_destroy) { dev->info->handle_destroy(dev); } |