From patchwork Mon Aug 20 20:26:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 144660 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4409236ljj; Mon, 20 Aug 2018 13:30:16 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwRrZKkbjPsv1SesX8WHlYj0IjAWU3GcZXPjNlf5icrZE+FQmxbnlVixl57ZyF356x9aslM X-Received: by 2002:ac8:4983:: with SMTP id f3-v6mr10944496qtq.411.1534797016526; Mon, 20 Aug 2018 13:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534797016; cv=none; d=google.com; s=arc-20160816; b=vsGTdJERpZP6vrEZFEzAVnmgWSRdOjsax5LIDOQfi4KIlL1Szqp3syqexzdjOCGyHA 1uXdTy9t4Dvev17Qgr5i7wGtvXK5b/CVCwbaJkYgCvY7Yhm85626wJjlGWXEzQCaSBoD QzLGVkAFcfw/ac/H1wZBx7Ve+6rHVhA1l0LP1C0ZF+Gd+kO6Hk3aUBezUWzyXP0cpsj9 FJz5qpjUh89qqQIC1hUvURSHeD3EJ/Fz+CyhxVtQbpXmbRIQWxX2bZD/6gepjOWJavQT FRM4czBRWxwHktfH5q6aqHwYB6YCHYcO1lVSLjzOJMEsmIslfL1FpVE84C0+eMGCtsKu 2gFg== 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=PjwLZzEhNIGCQw37hFyqw777IOcUEZ03GRWlf0ddFl4=; b=u8yXut6u425x+CS10Jlh9clve4ouwGbeU8lnExbRhku3GKuOOeK6T8uvfCQ9ep8dYN rvL28gt/6EG1W2tdQOtgDe4qyWKqAV1mMfmn0i1a2irxsop+Sw2c/40DykAKDzu+S7qz v1qXga//gu0mFbv/VXq3ZZoPMt6E7DYKX68grtcjKeX2HRt/AmDvwrZo+VdlEleridf7 4M21mNhfw5rtsLvQGLjtuN08LQJwFmKudFiz541ULkAUm/jTWos6C4T2tIhYs1Bzrw2K kfQEADTi/G7MCaG8rGlmi3ZEagk9lf/Pg5VChBPdtuWcaJOp6Gk7WAYQN6UJ/oNUYEKu JDAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Ii4mzlFV; 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 f9-v6si9853667qvd.37.2018.08.20.13.30.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 20 Aug 2018 13:30:16 -0700 (PDT) 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=Ii4mzlFV; 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]:49151 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frqoa-0005Lp-1L for patch@linaro.org; Mon, 20 Aug 2018 16:30:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frqlF-0002rH-0b for qemu-devel@nongnu.org; Mon, 20 Aug 2018 16:26:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frql2-0002Wm-EV for qemu-devel@nongnu.org; Mon, 20 Aug 2018 16:26:46 -0400 Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]:33747) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frqky-0002NE-Sd for qemu-devel@nongnu.org; Mon, 20 Aug 2018 16:26:34 -0400 Received: by mail-oi0-x22c.google.com with SMTP id 8-v6so28221104oip.0 for ; Mon, 20 Aug 2018 13:26:31 -0700 (PDT) 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=PjwLZzEhNIGCQw37hFyqw777IOcUEZ03GRWlf0ddFl4=; b=Ii4mzlFVnxlkB5PINoOJbN4aulbia/Ns5mHqcr9Rtu6UccmwfqODwCoeMvF0xWLU92 Eygh8l/+Nhpvc5i6kcPG9E4tJjZSUB6D2VaUCBV3EpTPhYK1C6fVJRTyjDoVlYq51jv3 HJmva5EZMcTjXfZZdJJsiEWlWDTrhklL5w3TKmmLQ8/8v+yW9CPOCzgJOldDL6JRW5aL R3oe+DfFrQofl5EKaRIV+NNpV8g6obB10+6243nQzT3UrYVUjI8CKhBoHvIKTG9FkO+P mpKM6kAAV5JPv/1tsLCTzTFXMPV9y/ntijZV5xIu8a+32JbADVW600/fDgq5iVmRn06G bixQ== 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=PjwLZzEhNIGCQw37hFyqw777IOcUEZ03GRWlf0ddFl4=; b=Ltqb2vc8TJ8P9nPxTaZiZsrcxoR33+BMGWrCHc5UzNiJmpmVBreit17OkpS1jxNMEJ 0nGowLedZ/zyS1DQ1JGTveHaDyjcTgPP2K9Z9qB1a/AaF+RBEVnjuzs/3WFdRYTfqStG E9qAJuTi9u6ELU76vlUq4D9WprClV/fT9qqekTwGuQvZFeiGIVHp1R6FcdNJWRvwKlsP IWU2HQfSxtoJEX/AIHjdVJ4wyFn7cHSeS3he8ms+lxJvOlWWAF5nzxbKMy+zLlH0unaZ JTkJgDpAxFpJLJQh6990tiWI9x1UGYWqVS5zNvL8uopwWE9344tj9HB1N7G8L0yO2ufF JSkA== X-Gm-Message-State: AOUpUlFmUCTjPu35zG7O+IdMiffGrtkh4Ee2Bow7l8pw48LA2fu/M0/J U5TKje8YG/7byUtWh7UP6+1ugyY= X-Received: by 2002:aca:68da:: with SMTP id o87-v6mr14234110oik.96.1534796791341; Mon, 20 Aug 2018 13:26:31 -0700 (PDT) Received: from serve.minyard.net ([47.184.170.128]) by smtp.gmail.com with ESMTPSA id m24-v6sm5670702oic.26.2018.08.20.13.26.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 13:26:28 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:7d98:76b7:e7fd:495f]) by serve.minyard.net (Postfix) with ESMTPA id E1E511547; Mon, 20 Aug 2018 15:26:24 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 07B4A30010C; Mon, 20 Aug 2018 15:26:21 -0500 (CDT) From: minyard@acm.org To: Paolo Bonzini , qemu-devel@nongnu.org Date: Mon, 20 Aug 2018 15:26:09 -0500 Message-Id: <1534796770-10295-10-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534796770-10295-1-git-send-email-minyard@acm.org> References: <1534796770-10295-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:4003:c06::22c Subject: [Qemu-devel] [PATCH v2 09/10] 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 , "Dr . David Alan Gilbert" , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Signed-off-by: Corey Minyard Cc: Paolo Bonzini Cc: "Michael S . Tsirkin" Cc: Dr. David Alan Gilbert --- 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 6ff77c5..b0774d7 100644 --- a/hw/i2c/smbus.c +++ b/hw/i2c/smbus.c @@ -349,6 +349,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 d8b1b9e..7b52020 100644 --- a/include/hw/i2c/smbus.h +++ b/include/hw/i2c/smbus.h @@ -53,14 +53,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 @@ void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf); 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