From patchwork Thu Dec 7 21:46:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121096 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8903493qgn; Thu, 7 Dec 2017 13:52:14 -0800 (PST) X-Google-Smtp-Source: AGs4zMZVRhO8t+ldLNan06Z5Btpy1rIXwM78L+ckFYNe2/2ObIgZmGwBrY0JtX9jUp+NbdxxwqiD X-Received: by 10.129.90.194 with SMTP id o185mr19843452ywb.274.1512683534391; Thu, 07 Dec 2017 13:52:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512683534; cv=none; d=google.com; s=arc-20160816; b=fPdfYEngyQuhQfBeBZolgW/eioPa8FUk339rzEFt57aEUsdTce/QxsH3Muhfdkp3SZ 8iupgM8WGlXiwe7TAQzN6Ut/tWo1CSlmPvLbOEwIJveTfmAwrpbf20PyQiChLq4Aeje1 rummBRzT4XnmdaEPYMWeelim2YpmJ/TNoZxNY2T/Eg8+ULlH3femZbYixD1B0zFPRmd6 pwsiPtqe+lx9dEKJuBcrVz6dVuxnE5x1BS9/8rFGO+pHQWPJWF5s3oy6n/HEIFDGv2qx yYYopLiAoJUWIbAmJXKt++Ypq5sXAowMgq+XtrhqjGkLcBnZQWgT9z5IYrTItYXK5AEh 9ySQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=NA08dy/kaR5uBsMTC17SfMbDCJfWDF1R8gD8SDh/I4A=; b=p1HtGzpIwosjdSkGaoSQYx/BOlZP6tSCnY1/VY8zLl9rRh4GgBMn/BMz2pRVqyjzZ0 i0xTZP8kCHGCMCizB3/0JuTTAcHTC4gqlClcSblwM8cmJ98/xpJFdntCXwywvKsH0g0x O1TmAabqxg+q7UfW7cXeVrGdRvM8tSJFg5FUanvZ/FsPAWHSi5cNd4h4QuVlMy9BDMds CwWLlSHOCWfjWUtJavi+CXLAGKkD23rIF3BO8pdmJUzXLNFfuR6jnCz4YQ8uXeNyCQUh BduB9WyTG9mkFzCLvmS/4tKcSSeNbyLILH3jBeI3btlqHrQNnDDqvqyqE5wwuvPfAo/7 93Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=exQRKH/4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a184si1339555ywg.612.2017.12.07.13.52.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:52:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=exQRKH/4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:34520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN45V-0007vG-Tc for patch@linaro.org; Thu, 07 Dec 2017 16:52:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN403-00042v-0F for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN401-0006Rh-VK for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:35 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:36364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN401-0006Qe-Oq for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:33 -0500 Received: by mail-pf0-x244.google.com with SMTP id p84so5683269pfd.3 for ; Thu, 07 Dec 2017 13:46:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=NA08dy/kaR5uBsMTC17SfMbDCJfWDF1R8gD8SDh/I4A=; b=exQRKH/4VTk3CVmB8L9pDj4zopS/+pI0cvuNF5X6CTC1to8rY7/ZXPyPowbg0TWk6l +Z8bSrOT8PFXnHVloyNHrxRN0cUDzskOFLa4WJFk96ym0WgoKUoz8PIljhT10SdvT5wf 0v7SRfliwecOhAdLKjNorIKBBXp+dh1kKT2YLTnp0q8QA2BjzsogafdL8q/NAFbLR/pf FyPjDHemHdGKRXGU+/aVZjvJGP4OSEIgL9bb2LcxfBQk1MnoHcIJpVMQoWnKZFN7PoZG 5m8zCddMF9+vJooJ2at3Sdwr6rSBI3e7VCJSdFvAfa8/41IhNcJtG+xu/dHcS4YO4HNC ZKtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=NA08dy/kaR5uBsMTC17SfMbDCJfWDF1R8gD8SDh/I4A=; b=ksfKAeZ/sd1Yu78WcfuQK6lcp1/FeLagwWSz5Pi8UZa3md/K+twRPoE5ibH2nvv39g O9/sPFDBLsvUTdBqQmOfPodkvrvAf9mVoiOgVZpp8+mgsrf1+CNzZ9ZPYmCz/0xbqKbE 8fvkQjqBul5FDLdqvoHZapR55ss48vt9JY9mb1Y+E/jrogkAIIJPW4GjT/l44rADxqZG 51nbjtigCEza/m48PisfAJFxS9m1Wvpx6f5j9Iaqn1LGulZk6oAng//CLIjG5BrHCfCg vVi/aZtFcmitapnil5hUY68nc/FFCH0RfVuTUAoVeVb46J24UPXEiropPIr/XZ2ktwmH pawA== X-Gm-Message-State: AJaThX6Vo/FQl98Fx0gIZggy0yBPLj9WrSoLjnG5B6lDBakOjf4NCt1z VZWL3+huxBNTJ1YMvH4MDg== X-Received: by 10.101.64.130 with SMTP id t2mr26026925pgp.299.1512683192747; Thu, 07 Dec 2017 13:46:32 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id l21sm10936820pfg.156.2017.12.07.13.46.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:29 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 5D847EB7; Thu, 7 Dec 2017 15:46:25 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 51672302368; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:15 -0600 Message-Id: <1512683181-8420-9-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-1-git-send-email-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH 08/14] i2c: Add an SMBus vmstate structure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Signed-off-by: Corey Minyard --- hw/i2c/smbus.c | 14 ++++++++++++++ include/hw/i2c/smbus.h | 18 +++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/hw/i2c/smbus.c b/hw/i2c/smbus.c index 4b0e264..e15f3f2 100644 --- a/hw/i2c/smbus.c +++ b/hw/i2c/smbus.c @@ -357,6 +357,20 @@ int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data, return 0; } +const VMStateDescription vmstate_smbus_device = { + .name = TYPE_SMBUS_DEVICE, + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_I2C_SLAVE(i2c, SMBusDevice), + VMSTATE_INT32(mode, SMBusDevice), + VMSTATE_INT32(data_len, SMBusDevice), + VMSTATE_UINT8_ARRAY(data_buf, SMBusDevice, SMBUS_DATA_MAX_LEN), + VMSTATE_UINT8(command, SMBusDevice), + VMSTATE_END_OF_LIST() + } +}; + static void smbus_device_class_init(ObjectClass *klass, void *data) { I2CSlaveClass *sc = I2C_SLAVE_CLASS(klass); diff --git a/include/hw/i2c/smbus.h b/include/hw/i2c/smbus.h index f1b8078..7794026 100644 --- a/include/hw/i2c/smbus.h +++ b/include/hw/i2c/smbus.h @@ -54,14 +54,16 @@ typedef struct SMBusDeviceClass uint8_t (*read_data)(SMBusDevice *dev, uint8_t cmd, int n); } SMBusDeviceClass; +#define SMBUS_DATA_MAX_LEN 34 /* command + len + 32 bytes of data. */ + struct SMBusDevice { /* The SMBus protocol is implemented on top of I2C. */ I2CSlave i2c; /* Remaining fields for internal use only. */ - int mode; - int data_len; - uint8_t data_buf[34]; /* command + len + 32 bytes of data. */ + int32_t mode; + int32_t data_len; + uint8_t data_buf[SMBUS_DATA_MAX_LEN]; uint8_t command; }; @@ -93,4 +95,14 @@ int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data, void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom, const uint8_t *eeprom_spd, int size); +extern const VMStateDescription vmstate_smbus_device; + +#define VMSTATE_SMBUS_DEVICE(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(SMBusDevice), \ + .vmsd = &vmstate_smbus_device, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, SMBusDevice), \ +} + #endif