From nobody Wed Nov 5 14:23:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534797122174485.02830857044273; Mon, 20 Aug 2018 13:32:02 -0700 (PDT) Received: from localhost ([::1]:49162 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frqqF-0006Ww-QP for importer@patchew.org; Mon, 20 Aug 2018 16:31:59 -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) 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) 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-Google-Smtp-Source: AA+uWPypozLfbUmxK3fEmB6sj3eh0OlMmRBeTOGPrkqlshM9QH05nJu5KO8U6oYa5HraRQqkDYUzOw== X-Received: by 2002:aca:68da:: with SMTP id o87-v6mr14234110oik.96.1534796791341; Mon, 20 Aug 2018 13:26:31 -0700 (PDT) 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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; } =20 +const VMStateDescription vmstate_smbus_device =3D { + .name =3D TYPE_SMBUS_DEVICE, + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (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 =3D 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; =20 +#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; =20 /* 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; }; =20 @@ -93,4 +95,14 @@ void smbus_eeprom_init_one(I2CBus *smbus, uint8_t addres= s, uint8_t *eeprom_buf); void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom, const uint8_t *eeprom_spd, int size); =20 +extern const VMStateDescription vmstate_smbus_device; + +#define VMSTATE_SMBUS_DEVICE(_field, _state) { \ + .name =3D (stringify(_field)), \ + .size =3D sizeof(SMBusDevice), \ + .vmsd =3D &vmstate_smbus_device, \ + .flags =3D VMS_STRUCT, \ + .offset =3D vmstate_offset_value(_state, _field, SMBusDevice), \ +} + #endif --=20 2.7.4