diff options
author | Antoine Mathys <barsamin@gmail.com> | 2012-12-13 14:05:28 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2012-12-13 14:05:28 +0000 |
commit | ed3d37d287300b7bcdb4605b921e5ec593afd214 (patch) | |
tree | 95c8f48284bda4c23bbbe6a4425ac92cfd4689f2 /hw/ds1338.c | |
parent | 59dda8e05b015471d456177141a7c2eeda3dab14 (diff) |
hw/ds1338.c: Ensure state is properly initialized.
Signed-off-by: Antoine Mathys <barsamin@gmail.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/ds1338.c')
-rw-r--r-- | hw/ds1338.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/ds1338.c b/hw/ds1338.c index 0f887200f3..d2f52fcbed 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -179,6 +179,17 @@ static int ds1338_init(I2CSlave *i2c) return 0; } +static void ds1338_reset(DeviceState *dev) +{ + DS1338State *s = FROM_I2C_SLAVE(DS1338State, I2C_SLAVE_FROM_QDEV(dev)); + + /* The clock is running and synchronized with the host */ + s->offset = 0; + memset(s->nvram, 0, NVRAM_SIZE); + s->ptr = 0; + s->addr_byte = false; +} + static void ds1338_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -188,6 +199,7 @@ static void ds1338_class_init(ObjectClass *klass, void *data) k->event = ds1338_event; k->recv = ds1338_recv; k->send = ds1338_send; + dc->reset = ds1338_reset; dc->vmsd = &vmstate_ds1338; } |