diff mbox

[2/3] wdt_i6300esb: Free timer

Message ID 1469112292-30548-2-git-send-email-minyard@acm.org
State New
Headers show

Commit Message

Corey Minyard July 21, 2016, 2:44 p.m. UTC
From: Corey Minyard <cminyard@mvista.com>

Add an exit function to free the timer allocated in the
realize function.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: Richard W.M. Jones <rjones@redhat.com>
Cc: Marc-André Lureau <mlureau@redhat.com>
---
 hw/watchdog/wdt_i6300esb.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Marc-Andre Lureau July 21, 2016, 2:56 p.m. UTC | #1
Hi

----- Original Message -----
> From: Corey Minyard <cminyard@mvista.com>
> 
> Add an exit function to free the timer allocated in the
> realize function.
> 
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> Cc: Richard W.M. Jones <rjones@redhat.com>
> Cc: Marc-André Lureau <mlureau@redhat.com>
> ---
>  hw/watchdog/wdt_i6300esb.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
> index a83d951..49b3cd1 100644
> --- a/hw/watchdog/wdt_i6300esb.c
> +++ b/hw/watchdog/wdt_i6300esb.c
> @@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error
> **errp)
>      /* qemu_register_coalesced_mmio (addr, 0x10); ? */
>  }
>  
> +static void i6300esb_exit(PCIDevice *dev)
> +{
> +    I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev);
> +
> +    timer_del(d->timer);
> +    timer_free(d->timer);
> +}

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> +
>  static WatchdogTimerModel model = {
>      .wdt_name = "i6300esb",
>      .wdt_description = "Intel 6300ESB",
> @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void
> *data)
>      k->config_read = i6300esb_config_read;
>      k->config_write = i6300esb_config_write;
>      k->realize = i6300esb_realize;
> +    k->exit = i6300esb_exit;
>      k->vendor_id = PCI_VENDOR_ID_INTEL;
>      k->device_id = PCI_DEVICE_ID_INTEL_ESB_9;
>      k->class_id = PCI_CLASS_SYSTEM_OTHER;
> --
> 2.7.4
> 
>
Richard W.M. Jones July 21, 2016, 3:11 p.m. UTC | #2
On Thu, Jul 21, 2016 at 09:44:51AM -0500, minyard@acm.org wrote:
> From: Corey Minyard <cminyard@mvista.com>
> 
> Add an exit function to free the timer allocated in the
> realize function.
> 
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> Cc: Richard W.M. Jones <rjones@redhat.com>
> Cc: Marc-André Lureau <mlureau@redhat.com>
> ---
>  hw/watchdog/wdt_i6300esb.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
> index a83d951..49b3cd1 100644
> --- a/hw/watchdog/wdt_i6300esb.c
> +++ b/hw/watchdog/wdt_i6300esb.c
> @@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp)
>      /* qemu_register_coalesced_mmio (addr, 0x10); ? */
>  }
>  
> +static void i6300esb_exit(PCIDevice *dev)
> +{
> +    I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev);
> +
> +    timer_del(d->timer);
> +    timer_free(d->timer);
> +}
> +
>  static WatchdogTimerModel model = {
>      .wdt_name = "i6300esb",
>      .wdt_description = "Intel 6300ESB",
> @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data)
>      k->config_read = i6300esb_config_read;
>      k->config_write = i6300esb_config_write;
>      k->realize = i6300esb_realize;
> +    k->exit = i6300esb_exit;
>      k->vendor_id = PCI_VENDOR_ID_INTEL;
>      k->device_id = PCI_DEVICE_ID_INTEL_ESB_9;
>      k->class_id = PCI_CLASS_SYSTEM_OTHER;

With the caveat that I only examined the code and compile-tested it:

Reviewed-by: Richard W.M. Jones <rjones@redhat.com>

Rich.
diff mbox

Patch

diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
index a83d951..49b3cd1 100644
--- a/hw/watchdog/wdt_i6300esb.c
+++ b/hw/watchdog/wdt_i6300esb.c
@@ -428,6 +428,14 @@  static void i6300esb_realize(PCIDevice *dev, Error **errp)
     /* qemu_register_coalesced_mmio (addr, 0x10); ? */
 }
 
+static void i6300esb_exit(PCIDevice *dev)
+{
+    I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev);
+
+    timer_del(d->timer);
+    timer_free(d->timer);
+}
+
 static WatchdogTimerModel model = {
     .wdt_name = "i6300esb",
     .wdt_description = "Intel 6300ESB",
@@ -441,6 +449,7 @@  static void i6300esb_class_init(ObjectClass *klass, void *data)
     k->config_read = i6300esb_config_read;
     k->config_write = i6300esb_config_write;
     k->realize = i6300esb_realize;
+    k->exit = i6300esb_exit;
     k->vendor_id = PCI_VENDOR_ID_INTEL;
     k->device_id = PCI_DEVICE_ID_INTEL_ESB_9;
     k->class_id = PCI_CLASS_SYSTEM_OTHER;