diff mbox

[3/3] wdt_ib700: Free timer

Message ID 1469112292-30548-3-git-send-email-minyard@acm.org (mailing list archive)
State New, archived
Headers show

Commit Message

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

Add an unrealize 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_ib700.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Marc-André Lureau July 21, 2016, 2:52 p.m. UTC | #1
Hi

----- Original Message -----
> From: Corey Minyard <cminyard@mvista.com>
> 
> Add an unrealize 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_ib700.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c
> index 532afe8..179771a 100644
> --- a/hw/watchdog/wdt_ib700.c
> +++ b/hw/watchdog/wdt_ib700.c
> @@ -117,6 +117,14 @@ 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);
> +}
> +

We may want to call portio_list_del() too here (although this is a dead function today)

>  static void wdt_ib700_reset(DeviceState *dev)
>  {
>      IB700State *s = IB700(dev);
> @@ -136,6 +144,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
> 
>
Richard W.M. Jones July 21, 2016, 3:11 p.m. UTC | #2
On Thu, Jul 21, 2016 at 09:44:52AM -0500, minyard@acm.org wrote:
> From: Corey Minyard <cminyard@mvista.com>
> 
> Add an unrealize 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_ib700.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c
> index 532afe8..179771a 100644
> --- a/hw/watchdog/wdt_ib700.c
> +++ b/hw/watchdog/wdt_ib700.c
> @@ -117,6 +117,14 @@ 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);
> +}
> +
>  static void wdt_ib700_reset(DeviceState *dev)
>  {
>      IB700State *s = IB700(dev);
> @@ -136,6 +144,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);

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_ib700.c b/hw/watchdog/wdt_ib700.c
index 532afe8..179771a 100644
--- a/hw/watchdog/wdt_ib700.c
+++ b/hw/watchdog/wdt_ib700.c
@@ -117,6 +117,14 @@  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);
+}
+
 static void wdt_ib700_reset(DeviceState *dev)
 {
     IB700State *s = IB700(dev);
@@ -136,6 +144,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);