From patchwork Tue Dec 11 22:58:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Mathys X-Patchwork-Id: 205334 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 312042C0092 for ; Wed, 12 Dec 2012 09:58:21 +1100 (EST) Received: from localhost ([::1]:40394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiYmJ-00030T-GH for incoming@patchwork.ozlabs.org; Tue, 11 Dec 2012 17:58:19 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiYm9-00030N-5E for qemu-devel@nongnu.org; Tue, 11 Dec 2012 17:58:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TiYm5-00012y-6l for qemu-devel@nongnu.org; Tue, 11 Dec 2012 17:58:09 -0500 Received: from mail-wi0-f171.google.com ([209.85.212.171]:35840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiYm5-00012s-0h for qemu-devel@nongnu.org; Tue, 11 Dec 2012 17:58:05 -0500 Received: by mail-wi0-f171.google.com with SMTP id hn14so2224638wib.10 for ; Tue, 11 Dec 2012 14:58:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=krDiaiCWDC4ONC9LFA1pnYUHg3DgENwC/fof8Z/kssI=; b=eBVSAZx8VHRFX69J6RHunYGuZwRZYZ/mjtblRN/bpFZxOqrCx5zD8osUw7bgLw33q2 bubjxoPK8QJfZmYjOgDPIWVBHAbfLClZBM0U9nC9rVfsgwOTXrbfGuqJaceH/FaXGNDH LQFp7j2iedbENEb8+SCjmAQ7fXrkTquslAQnqJK9RUbAcyWWiARkF+NXMnOk2WFyGFHK xI8GQSI2lihaaXRS+KuQ5BbOFDDFDA/sQy6ILmB3v7JHVAo4DERvd2bLRyHVQDGLT01b CAIbqVM7vWHhP4/gMRQctvFwKYBisHjoCIJyo/RqdDtfMuzT0+Szchi1BnQP/necFz5N 5scg== Received: by 10.194.23.37 with SMTP id j5mr3255581wjf.28.1355266684142; Tue, 11 Dec 2012 14:58:04 -0800 (PST) Received: from [192.168.1.33] (adsl-84-227-232-139.adslplus.ch. [84.227.232.139]) by mx.google.com with ESMTPS id i6sm734670wix.5.2012.12.11.14.58.02 (version=SSLv3 cipher=OTHER); Tue, 11 Dec 2012 14:58:03 -0800 (PST) Message-ID: <50C7BA7A.5060705@gmail.com> Date: Tue, 11 Dec 2012 23:58:02 +0100 From: Antoine Mathys User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: qemu-devel@nongnu.org References: <50C7B767.8020406@gmail.com> In-Reply-To: <50C7B767.8020406@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.212.171 Cc: Peter Maydell , paul@codesourcery.com Subject: [Qemu-devel] [PATCH v2 4/6] hw/ds1338.c: Ensure state is properly initialized. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Antoine Mathys --- hw/ds1338.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/ds1338.c b/hw/ds1338.c index 0f88720..b4d5b74 100644 --- a/hw/ds1338.c +++ b/hw/ds1338.c @@ -179,6 +179,15 @@ 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); +} + static void ds1338_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -188,6 +197,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; }