Message ID | 1469119749-31181-4-git-send-email-minyard@acm.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi ----- Original Message ----- > From: Corey Minyard <cminyard@mvista.com> > > 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 <cminyard@mvista.com> > Cc: Richard W.M. Jones <rjones@redhat.com> > Cc: Marc-André Lureau <mlureau@redhat.com> > Reviewed-by: Richard W.M. Jones <rjones@redhat.com> > --- > hw/watchdog/wdt_ib700.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c > index 532afe8..23d4857 100644 > --- a/hw/watchdog/wdt_ib700.c > +++ b/hw/watchdog/wdt_ib700.c > @@ -117,6 +117,15 @@ 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); > + portio_list_del(&s->port_list); actually portio_list_destroy() seems to be more appropriate (cleaning up allocations) btw, I do not how to test this yet either. > +} > + > static void wdt_ib700_reset(DeviceState *dev) > { > IB700State *s = IB700(dev); > @@ -136,6 +145,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 > >
On Fri, Jul 22, 2016 at 05:26:27AM -0400, Marc-André Lureau wrote:
> btw, I do not how to test this yet either.
I have a little test framework for the watchdog device which cuts
through a lot of the BS with running the full watchdog daemon, and
also has some simple instructions to follow:
http://git.annexia.org/?p=watchdog-test-framework.git;a=tree
Rich.
On 07/22/2016 05:12 AM, Richard W.M. Jones wrote: > On Fri, Jul 22, 2016 at 05:26:27AM -0400, Marc-André Lureau wrote: >> btw, I do not how to test this yet either. > I have a little test framework for the watchdog device which cuts > through a lot of the BS with running the full watchdog daemon, and > also has some simple instructions to follow: > > http://git.annexia.org/?p=watchdog-test-framework.git;a=tree > > Rich. > Thanks, but unfortunately, I need to be able to test unrealizing the device in qemu. These changes don't affect the function of the watchdog. Nice little program, though, I'll point our testers at it. -corey
diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c index 532afe8..23d4857 100644 --- a/hw/watchdog/wdt_ib700.c +++ b/hw/watchdog/wdt_ib700.c @@ -117,6 +117,15 @@ 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); + portio_list_del(&s->port_list); +} + static void wdt_ib700_reset(DeviceState *dev) { IB700State *s = IB700(dev); @@ -136,6 +145,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);