From patchwork Fri Sep 11 10:10:28 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 33435 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id E4334B707B for ; Fri, 11 Sep 2009 20:42:57 +1000 (EST) Received: from localhost ([127.0.0.1]:56845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mm3af-0005T2-Tt for incoming@patchwork.ozlabs.org; Fri, 11 Sep 2009 06:42:53 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mm38P-0004TI-Lm for qemu-devel@nongnu.org; Fri, 11 Sep 2009 06:13:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mm38J-0004PW-6p for qemu-devel@nongnu.org; Fri, 11 Sep 2009 06:13:40 -0400 Received: from [199.232.76.173] (port=36112 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mm38I-0004PP-RU for qemu-devel@nongnu.org; Fri, 11 Sep 2009 06:13:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40859) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mm38H-00012i-QO for qemu-devel@nongnu.org; Fri, 11 Sep 2009 06:13:34 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8BADTwS022339 for ; Fri, 11 Sep 2009 06:13:29 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8BADJVZ025817; Fri, 11 Sep 2009 06:13:28 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 11 Sep 2009 12:10:28 +0200 Message-Id: <152d80af45a5ebfb6562b52bac75c5d9466c619c.1252662256.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 08/20] vmstate: port max7310 device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Juan Quintela --- hw/max7310.c | 51 ++++++++++++++++++--------------------------------- 1 files changed, 18 insertions(+), 33 deletions(-) diff --git a/hw/max7310.c b/hw/max7310.c index e737133..0ce6ac9 100644 --- a/hw/max7310.c +++ b/hw/max7310.c @@ -143,38 +143,23 @@ static void max7310_event(i2c_slave *i2c, enum i2c_event event) } } -static void max7310_save(QEMUFile *f, void *opaque) -{ - MAX7310State *s = (MAX7310State *) opaque; - - qemu_put_be32(f, s->i2c_command_byte); - qemu_put_be32(f, s->len); - - qemu_put_8s(f, &s->level); - qemu_put_8s(f, &s->direction); - qemu_put_8s(f, &s->polarity); - qemu_put_8s(f, &s->status); - qemu_put_8s(f, &s->command); - - i2c_slave_save(f, &s->i2c); -} - -static int max7310_load(QEMUFile *f, void *opaque, int version_id) -{ - MAX7310State *s = (MAX7310State *) opaque; - - s->i2c_command_byte = qemu_get_be32(f); - s->len = qemu_get_be32(f); - - qemu_get_8s(f, &s->level); - qemu_get_8s(f, &s->direction); - qemu_get_8s(f, &s->polarity); - qemu_get_8s(f, &s->status); - qemu_get_8s(f, &s->command); - - i2c_slave_load(f, &s->i2c); - return 0; -} +static const VMStateDescription vmstate_max7310 = { + .name = "max7310", + .version_id = 0, + .minimum_version_id = 0, + .minimum_version_id_old = 0, + .fields = (VMStateField []) { + VMSTATE_INT32(i2c_command_byte, MAX7310State), + VMSTATE_INT32(len, MAX7310State), + VMSTATE_UINT8(level, MAX7310State), + VMSTATE_UINT8(direction, MAX7310State), + VMSTATE_UINT8(polarity, MAX7310State), + VMSTATE_UINT8(status, MAX7310State), + VMSTATE_UINT8(command, MAX7310State), + VMSTATE_I2C_SLAVE(i2c, MAX7310State), + VMSTATE_END_OF_LIST() + } +}; static void max7310_gpio_set(void *opaque, int line, int level) { @@ -199,7 +184,7 @@ static int max7310_init(i2c_slave *i2c) max7310_reset(&s->i2c); - register_savevm("max7310", -1, 0, max7310_save, max7310_load, s); + vmstate_register(-1, &vmstate_max7310, s); return 0; }