From patchwork Tue Aug 14 08:09:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peter A. G. Crosthwaite" X-Patchwork-Id: 177181 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 ACF9F2C0092 for ; Tue, 14 Aug 2012 18:11:39 +1000 (EST) Received: from localhost ([::1]:43980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1CDx-0005X0-Np for incoming@patchwork.ozlabs.org; Tue, 14 Aug 2012 04:11:37 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34808) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1CDo-0005Wt-Qi for qemu-devel@nongnu.org; Tue, 14 Aug 2012 04:11:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T1CDm-0006Fi-44 for qemu-devel@nongnu.org; Tue, 14 Aug 2012 04:11:28 -0400 Received: from mail-gg0-f173.google.com ([209.85.161.173]:42790) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1CDl-0006Fe-Vv for qemu-devel@nongnu.org; Tue, 14 Aug 2012 04:11:26 -0400 Received: by ggna5 with SMTP id a5so117404ggn.4 for ; Tue, 14 Aug 2012 01:11:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=7JxuPFSUQWj9xZQg+oAwWVCglcdW9Vf22Rok4FXkcm0=; b=W1QjsWq6ipCqoxQKzVph5zxc/FvMAeR8kVP6a5OUig5oLPcdQz5UfZCyaKuYVzKEIW JaAL9FMndOUJtEQCyW8c24YmId8N/MbwbSluMmP673eMrsa4OQqYOp3OqOZBaY4OS9yX ZMlJymgM9U7UZoqlSdsFvH8+SctYwF6PrUHANgdPycQ+jwsUOEpc1ddLSMu5TMKpG/8c Ydo0x5ZmISVY3SPnd75l1biM4HwdpNHFg4yHc2+9aQWLK4mq2VlHVVhp23wKd74DZveU hx3PqPja8ux6JbKbrtNRCnCi7MidUZlazB76GwGG860UmGWI/eFW7DtQy7Oq6OfvHmaA cXxQ== Received: by 10.50.196.197 with SMTP id io5mr10052074igc.12.1344931885054; Tue, 14 Aug 2012 01:11:25 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id pp4sm19822344igb.5.2012.08.14.01.11.21 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Aug 2012 01:11:24 -0700 (PDT) From: "Peter A. G. Crosthwaite" To: qemu-devel@nongnu.org, paul@codesourcery.com, peter.maydell@linaro.org, quintela@redhat.com, aliguori@us.ibm.com Date: Tue, 14 Aug 2012 18:09:47 +1000 Message-Id: <1344931787-27056-1-git-send-email-peter.crosthwaite@petalogix.com> X-Mailer: git-send-email 1.7.0.4 X-Gm-Message-State: ALoCoQk7wvJJo+weE3JHsXeyteb3f/zCFbJtjN+PaCNfQ7k6KVfPiUvalj9dYX9Qy5t7jJqlTr5Z X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.161.173 Cc: peter.crosthwaite@petalogix.com Subject: [Qemu-devel] [PATCH] i2c: factor out VMSD to parent class 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 Hi All. PMM raised a query on a recent series of mine (the SSI series) about handling VMSD for devices which define state at multiple levels of the QOM heirachy. Rather than complicate the discussion over in my series im trying to start the discussion with an existing subsystem - i2c. This patch is a first attempt at trying to get the VMSD for generic I2C state factored out of the individual devices and handled transparently by the super class (I2C_SLAVE). I have applied the change to only the one I2C device (max7310). If we were going to run with this, the change pattern would be applied to all I2C devices. This patch is not a merge proposal it is RFC only. Please review and let us know if this is flawed or not. What needs to be done to get this multi-level VMSD going? I will use whatever review I get to fix my SSI series as well as fix I2C. Signed-off-by: Peter A. G. Crosthwaite --- hw/i2c.c | 2 ++ hw/i2c.h | 8 -------- hw/max7310.c | 1 - 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/i2c.c b/hw/i2c.c index 296bece..17e1633 100644 --- a/hw/i2c.c +++ b/hw/i2c.c @@ -207,6 +207,8 @@ static int i2c_slave_qdev_init(DeviceState *dev) I2CSlave *s = I2C_SLAVE_FROM_QDEV(dev); I2CSlaveClass *sc = I2C_SLAVE_GET_CLASS(s); + vmstate_register(NULL, 0, &vmstate_i2c_slave, s); + return sc->init(s); } diff --git a/hw/i2c.h b/hw/i2c.h index 0f5682b..5b75ecc 100644 --- a/hw/i2c.h +++ b/hw/i2c.h @@ -81,12 +81,4 @@ void lm832x_key_event(DeviceState *dev, int key, int state); extern const VMStateDescription vmstate_i2c_slave; -#define VMSTATE_I2C_SLAVE(_field, _state) { \ - .name = (stringify(_field)), \ - .size = sizeof(I2CSlave), \ - .vmsd = &vmstate_i2c_slave, \ - .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, I2CSlave), \ -} - #endif diff --git a/hw/max7310.c b/hw/max7310.c index 1ed18ba..9375691 100644 --- a/hw/max7310.c +++ b/hw/max7310.c @@ -156,7 +156,6 @@ static const VMStateDescription vmstate_max7310 = { VMSTATE_UINT8(polarity, MAX7310State), VMSTATE_UINT8(status, MAX7310State), VMSTATE_UINT8(command, MAX7310State), - VMSTATE_I2C_SLAVE(i2c, MAX7310State), VMSTATE_END_OF_LIST() } };