From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNKuc-0007rj-7t for qemu-devel@nongnu.org; Fri, 29 Aug 2014 08:04:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XNKuX-0003Z0-4E for qemu-devel@nongnu.org; Fri, 29 Aug 2014 08:04:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNKuW-0003YZ-Sy for qemu-devel@nongnu.org; Fri, 29 Aug 2014 08:04:09 -0400 From: Gerd Hoffmann Date: Fri, 29 Aug 2014 14:03:46 +0200 Message-Id: <1409313832-2514-12-git-send-email-kraxel@redhat.com> In-Reply-To: <1409313832-2514-1-git-send-email-kraxel@redhat.com> References: <1409313832-2514-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 11/17] usb-ehci: add ehci unrealize funciton List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gonglei , Gerd Hoffmann From: Gonglei cleanup ehci controller resource, both pci and sysbus if they're necessary. Signed-off-by: Gonglei Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ehci.c | 25 +++++++++++++++++++++++++ hw/usb/hcd-ehci.h | 1 + 2 files changed, 26 insertions(+) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index ef26f36..2aa06bb 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2471,6 +2471,31 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp) s->vmstate = qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s); } +void usb_ehci_unrealize(EHCIState *s, DeviceState *dev, Error **errp) +{ + if (s->frame_timer) { + timer_del(s->frame_timer); + timer_free(s->frame_timer); + s->frame_timer = NULL; + } + if (s->async_bh) { + qemu_bh_delete(s->async_bh); + } + + ehci_queues_rip_all(s, 0); + ehci_queues_rip_all(s, 1); + + memory_region_del_subregion(&s->mem, &s->mem_caps); + memory_region_del_subregion(&s->mem, &s->mem_opreg); + memory_region_del_subregion(&s->mem, &s->mem_ports); + + usb_bus_release(&s->bus); + + if (s->vmstate) { + qemu_del_vm_change_state_handler(s->vmstate); + } +} + void usb_ehci_init(EHCIState *s, DeviceState *dev) { /* 2.2 host controller interface version */ diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index 594d9d3..4858b7e 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -323,6 +323,7 @@ extern const VMStateDescription vmstate_ehci; void usb_ehci_init(EHCIState *s, DeviceState *dev); void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp); +void usb_ehci_unrealize(EHCIState *s, DeviceState *dev, Error **errp); #define TYPE_PCI_EHCI "pci-ehci-usb" #define PCI_EHCI(obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI) -- 1.8.3.1