From patchwork Thu Dec 7 21:46:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 10101149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1C4DC60329 for ; Thu, 7 Dec 2017 21:52:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F8AF284B9 for ; Thu, 7 Dec 2017 21:52:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 037C128734; Thu, 7 Dec 2017 21:52:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 88DA2284B9 for ; Thu, 7 Dec 2017 21:52:27 +0000 (UTC) Received: from localhost ([::1]:34529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN45i-0000vP-Lv for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Dec 2017 16:52:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN404-00043l-0i for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN403-0006Sa-1B for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:36 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:42325) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN402-0006S6-RU for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:34 -0500 Received: by mail-pf0-x242.google.com with SMTP id d23so5669990pfe.9 for ; Thu, 07 Dec 2017 13:46:34 -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=qT2ZO1W2HJ1DqjfogKzmFB8W9vNRLNA69uvg/MjlRGI=; b=lKkml65FfqekCxi2FY3zi0kFid6fHIZB4lgSIQ5US75UKK3EKA0l62qbQf73ipiyzf kp8SWuqd1LrtMeZtPk3/v/y7FnfyMAzeXxaC9ED+u/CrBQyYys2Y6xkFovnNDre/jOn5 Gmk1HDRNKlBBXMospmNi9TncOtOsHbgzGxgsRCKAWgKYS0P1CHbfkztz/y76be9uuuXC dMGQBMwc4t6OQSkF9DLipvaOnvu/IJAfoZ1mSxekJstSiS8vtmAv3p4CcAIE1ykLC1pM KueCQT7ar83xAMf5riRix4kyRhGfDw7qnbiQtbMO1G4rCouSZ2b6GcpXRqWPsrdw85GE +DPw== 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=qT2ZO1W2HJ1DqjfogKzmFB8W9vNRLNA69uvg/MjlRGI=; b=r0jAj8TlyuXx0UDVCfj4rzcyOa6tv8e9DePe1prsgFkw3i9jp9RR8+vVJxKP/ATmeM qAY3mp2pyA9Ko6rghxQf1A3VcIYetDA/XPPyJ8Hl826h7eAonaq3W0Dw5Bzd0L6cveBo vO/pmWXVAhFcQOWM3wkWVTCjjCcxJIpD+mDpmumMM4ToWGW3idLh9rQL3/yiCOxc0y0C xPi6oTmmQhw8gBBH9M1AM/6e6bbwJD2kX+kZFGjFdFP35D6hMyLymJVqFkgOSTF75nKX Ka05x4qjxSQFxKCyDLCBnzmJBcMRqnBmma3xRvfcN8hEHhx076eCo6ZXjIKhdiIVa2UU Kn1w== X-Gm-Message-State: AJaThX6UuojPuj8PkCYDP7FprdKOAqRbF+j4WB33/IlC3JL4oF1K2S21 OEBSsDLR8f1F7F4PEpqS7g== X-Google-Smtp-Source: AGs4zMYrJmqLXq6C60bOorAWt0+hPLuatFkglVpfnPqoUqvMpsliVRWkEGb2VdaTzxpok5iIkqj1yg== X-Received: by 10.101.88.76 with SMTP id s12mr27216612pgr.215.1512683193780; Thu, 07 Dec 2017 13:46:33 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id k2sm9780683pff.150.2017.12.07.13.46.29 (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 BA03CF87; Thu, 7 Dec 2017 15:46:25 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 5FAD230007E; 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:16 -0600 Message-Id: <1512683181-8420-10-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::242 Subject: [Qemu-devel] [PATCH 09/14] i2c: Add vmstate handling to the smbus eeprom 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Corey Minyard Signed-off-by: Corey Minyard --- hw/i2c/smbus_eeprom.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index b13ec0f..089005d 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -29,6 +29,8 @@ //#define DEBUG +#define TYPE_SMBUS_EEPROM_DEVICE "smbus-eeprom" + typedef struct SMBusEEPROMDevice { SMBusDevice smbusdev; void *data; @@ -97,6 +99,17 @@ static uint8_t eeprom_read_data(SMBusDevice *dev, uint8_t cmd, int n) return eeprom_receive_byte(dev); } +static const VMStateDescription vmstate_smbus_eeprom = { + .name = TYPE_SMBUS_EEPROM_DEVICE, + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_SMBUS_DEVICE(smbusdev, SMBusEEPROMDevice), + VMSTATE_UINT8(offset, SMBusEEPROMDevice), + VMSTATE_END_OF_LIST() + } +}; + static int smbus_eeprom_initfn(SMBusDevice *dev) { SMBusEEPROMDevice *eeprom = (SMBusEEPROMDevice *)dev; @@ -122,12 +135,13 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data) sc->write_data = eeprom_write_data; sc->read_data = eeprom_read_data; dc->props = smbus_eeprom_properties; + dc->vmsd = &vmstate_smbus_eeprom; /* Reason: pointer property "data" */ dc->user_creatable = false; } static const TypeInfo smbus_eeprom_info = { - .name = "smbus-eeprom", + .name = TYPE_SMBUS_EEPROM_DEVICE, .parent = TYPE_SMBUS_DEVICE, .instance_size = sizeof(SMBusEEPROMDevice), .class_init = smbus_eeprom_class_initfn,