From patchwork Fri Sep 11 10:10:30 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 33437 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 CF2E7B6F34 for ; Fri, 11 Sep 2009 20:49:04 +1000 (EST) Received: from localhost ([127.0.0.1]:45151 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mm3gb-0003qc-1S for incoming@patchwork.ozlabs.org; Fri, 11 Sep 2009 06:49:01 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mm38S-0004UZ-3w for qemu-devel@nongnu.org; Fri, 11 Sep 2009 06:13:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mm38N-0004SD-GY for qemu-devel@nongnu.org; Fri, 11 Sep 2009 06:13:43 -0400 Received: from [199.232.76.173] (port=36115 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mm38N-0004Rx-0G for qemu-devel@nongnu.org; Fri, 11 Sep 2009 06:13:39 -0400 Received: from mx20.gnu.org ([199.232.41.8]:9655) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mm38M-0001EH-Jv for qemu-devel@nongnu.org; Fri, 11 Sep 2009 06:13:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mm38L-0006kT-OO for qemu-devel@nongnu.org; Fri, 11 Sep 2009 06:13:38 -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 n8BADVHi001414 for ; Fri, 11 Sep 2009 06:13:32 -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 n8BADJVb025817; Fri, 11 Sep 2009 06:13:31 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 11 Sep 2009 12:10:30 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by mx20.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [Qemu-devel] [PATCH 10/20] vmstate: port pxa2xx_i2c 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/pxa2xx.c | 54 ++++++++++++++++++++++++++---------------------------- 1 files changed, 26 insertions(+), 28 deletions(-) diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c index e38a125..f8292e7 100644 --- a/hw/pxa2xx.c +++ b/hw/pxa2xx.c @@ -1452,33 +1452,32 @@ static CPUWriteMemoryFunc * const pxa2xx_i2c_writefn[] = { pxa2xx_i2c_write, }; -static void pxa2xx_i2c_save(QEMUFile *f, void *opaque) -{ - PXA2xxI2CState *s = (PXA2xxI2CState *) opaque; - - qemu_put_be16s(f, &s->control); - qemu_put_be16s(f, &s->status); - qemu_put_8s(f, &s->ibmr); - qemu_put_8s(f, &s->data); - - i2c_slave_save(f, &s->slave->i2c); -} - -static int pxa2xx_i2c_load(QEMUFile *f, void *opaque, int version_id) -{ - PXA2xxI2CState *s = (PXA2xxI2CState *) opaque; - - if (version_id != 1) - return -EINVAL; - - qemu_get_be16s(f, &s->control); - qemu_get_be16s(f, &s->status); - qemu_get_8s(f, &s->ibmr); - qemu_get_8s(f, &s->data); +static const VMStateDescription vmstate_pxa2xx_i2c_slave = { + .name = "pxa2xx_i2c_slave", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField []) { + VMSTATE_I2C_SLAVE(i2c, PXA2xxI2CSlaveState), + VMSTATE_END_OF_LIST() + } +}; - i2c_slave_load(f, &s->slave->i2c); - return 0; -} +static const VMStateDescription vmstate_pxa2xx_i2c = { + .name = "pxa2xx_i2c", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField []) { + VMSTATE_UINT16(control, PXA2xxI2CState), + VMSTATE_UINT16(status, PXA2xxI2CState), + VMSTATE_UINT8(ibmr, PXA2xxI2CState), + VMSTATE_UINT8(data, PXA2xxI2CState), + VMSTATE_STRUCT_POINTER(slave, PXA2xxI2CState, + vmstate_pxa2xx_i2c, PXA2xxI2CSlaveState *), + VMSTATE_END_OF_LIST() + } +}; static int pxa2xx_i2c_slave_init(i2c_slave *i2c) { @@ -1516,8 +1515,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(target_phys_addr_t base, cpu_register_physical_memory(base & ~region_size, region_size + 1, iomemtype); - register_savevm("pxa2xx_i2c", base, 1, - pxa2xx_i2c_save, pxa2xx_i2c_load, s); + vmstate_register(base, &vmstate_pxa2xx_i2c, s); return s; }