From patchwork Fri Aug 29 12:03:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 384202 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BD3DD14010B for ; Fri, 29 Aug 2014 22:07:26 +1000 (EST) Received: from localhost ([::1]:41684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNKxg-0004O8-OC for incoming@patchwork.ozlabs.org; Fri, 29 Aug 2014 08:07:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNKud-0007rq-3I for qemu-devel@nongnu.org; Fri, 29 Aug 2014 08:04:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XNKuY-0003Zx-6o for qemu-devel@nongnu.org; Fri, 29 Aug 2014 08:04:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNKuY-0003ZY-04 for qemu-devel@nongnu.org; Fri, 29 Aug 2014 08:04:10 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7TC45Fo032132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 29 Aug 2014 08:04:05 -0400 Received: from nilsson.home.kraxel.org (ovpn-116-58.ams2.redhat.com [10.36.116.58]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s7TC43g5007216; Fri, 29 Aug 2014 08:04:04 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 2A7028075F; Fri, 29 Aug 2014 14:04:02 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 29 Aug 2014 14:03:47 +0200 Message-Id: <1409313832-2514-13-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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gonglei , Gerd Hoffmann Subject: [Qemu-devel] [PULL 12/17] usb-ehci: add ehci-pci device exit function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Gonglei clean up ehci resource when ehci pci device exit. Signed-off-by: Gonglei Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ehci-pci.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c index 505741a..289ca3b 100644 --- a/hw/usb/hcd-ehci-pci.c +++ b/hw/usb/hcd-ehci-pci.c @@ -84,6 +84,19 @@ static void usb_ehci_pci_init(Object *obj) usb_ehci_init(s, DEVICE(obj)); } +static void usb_ehci_pci_exit(PCIDevice *dev) +{ + EHCIPCIState *i = PCI_EHCI(dev); + EHCIState *s = &i->ehci; + + usb_ehci_unrealize(s, DEVICE(dev), NULL); + + if (s->irq) { + g_free(s->irq); + s->irq = NULL; + } +} + static void usb_ehci_pci_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int l) { @@ -121,6 +134,7 @@ static void ehci_class_init(ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->init = usb_ehci_pci_initfn; + k->exit = usb_ehci_pci_exit; k->class_id = PCI_CLASS_SERIAL_USB; k->config_write = usb_ehci_pci_write_config; dc->hotpluggable = false;