From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQgTB-0005d0-Ky for qemu-devel@nongnu.org; Fri, 22 Jul 2016 15:50:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQgTA-00005R-P7 for qemu-devel@nongnu.org; Fri, 22 Jul 2016 15:50:49 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:32945) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQgTA-00005F-Kj for qemu-devel@nongnu.org; Fri, 22 Jul 2016 15:50:48 -0400 Received: by mail-oi0-x243.google.com with SMTP id l9so11280505oih.0 for ; Fri, 22 Jul 2016 12:50:48 -0700 (PDT) Sender: Corey Minyard From: minyard@acm.org Date: Fri, 22 Jul 2016 14:50:40 -0500 Message-Id: <1469217041-15358-4-git-send-email-minyard@acm.org> In-Reply-To: <1469217041-15358-1-git-send-email-minyard@acm.org> References: <1469217041-15358-1-git-send-email-minyard@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v3 3/4] wdt_ib700: Free timer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , minyard@acm.org, Corey Minyard , "Richard W . M . Jones" From: Corey Minyard Add an unrealize function to free the timer allocated in the realize function and to delete the port memory added there, too. Signed-off-by: Corey Minyard Cc: Richard W.M. Jones Cc: Marc-André Lureau Reviewed-by: Richard W.M. Jones --- hw/watchdog/wdt_ib700.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c index 532afe8..6d5fc4c 100644 --- a/hw/watchdog/wdt_ib700.c +++ b/hw/watchdog/wdt_ib700.c @@ -117,6 +117,17 @@ static void wdt_ib700_realize(DeviceState *dev, Error **errp) portio_list_add(&s->port_list, isa_address_space_io(&s->parent_obj), 0); } +static void wdt_ib700_unrealize(DeviceState *dev, Error **errp) +{ + IB700State *s = IB700(dev); + + timer_del(s->timer); + timer_free(s->timer); + s->timer = NULL; + portio_list_del(&s->port_list); + portio_list_destroy(&s->port_list); +} + static void wdt_ib700_reset(DeviceState *dev) { IB700State *s = IB700(dev); @@ -136,6 +147,7 @@ static void wdt_ib700_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = wdt_ib700_realize; + dc->unrealize = wdt_ib700_unrealize; dc->reset = wdt_ib700_reset; dc->vmsd = &vmstate_ib700; set_bit(DEVICE_CATEGORY_MISC, dc->categories); -- 2.7.4