From patchwork Mon Aug 20 20:26:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 10570763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A8B6920 for ; Mon, 20 Aug 2018 20:32:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4790B29BF2 for ; Mon, 20 Aug 2018 20:32:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39DDD29BF5; Mon, 20 Aug 2018 20:32:52 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,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 D932A29BF2 for ; Mon, 20 Aug 2018 20:32:51 +0000 (UTC) Received: from localhost ([::1]:49164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frqr5-0007Z8-4e for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Aug 2018 16:32:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frqlF-0002rL-1n 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-0002WO-BI for qemu-devel@nongnu.org; Mon, 20 Aug 2018 16:26:46 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:43036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frqkw-0002Km-R7 for qemu-devel@nongnu.org; Mon, 20 Aug 2018 16:26:32 -0400 Received: by mail-oi0-x244.google.com with SMTP id b15-v6so28119896oib.10 for ; Mon, 20 Aug 2018 13:26:30 -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=j+Yp0UZkajf5t3AswMPnhMvJanDi0W7vrct2f1lQk/o=; b=EVND+yG09g50NpeKjLTHIc6nbpBWuwmAoq4K/Rwsg32I690+StXFhFahg4/78zYop/ 0gY1MeSHXl0nCntwxC5Nzqk350haG7wLIOlh8Jqu2P4vQsInhc+xB252Je/ekpEBpwrG xle7u/s9F/PqsiRcxLTO10DwfgKrgRDPGnoUxL+BfHqIop1GX/J6B9D0F37LlX30GJDC eeaGtdTEcVLYvyXPdurIDijGULltvBYvnoz8WF+G9+expKv3lSx00thufbIBxt3zucY6 W3CFdXnv6H9Xaa/GhifX+a/1z3FGDTNl1PKP+X7o2a4HWKTIHdnOv4D38pF5+GviDrns +tHA== 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=j+Yp0UZkajf5t3AswMPnhMvJanDi0W7vrct2f1lQk/o=; b=XlMJPDrOzgRX4s17tOQPmLFzDs5yi+JGKVMfPH3bs2NjGykQ+AJb5wYrfML2XqnBYD hYfCQSnRQ7N3N3DCS+aW2l+1NGbCw9a01EXovmG8g2nBPlKDDH4tNabIPRVf8Z23NzT3 yMHPNyDw4baC0A9nQmZZosaX9/VXGPk+o+4pAdYAUqfXdSpK2Vl+sLHUlQLkvXsS6KAj zwJq1u0kfIyJrKCLUWBDElXGDYoI8LniYqEmMZYfxnjclPvbXXxcBYUUVXKarCR5yC9N X5JpDQfoOBgq/HSY+sVUD/xW0tupsd5hFNwHY+7u2UIFq52qN15CVyAPzcAEcR+OPR4o NLHQ== X-Gm-Message-State: AOUpUlHZZThe1PmTVg1t3bZbiT6Ac3/TDDHCNM/2i+njFVGx96qXYBGF PEXjZVGck/aYN9xf54kx7A== X-Google-Smtp-Source: AA+uWPy+NyjODHdktmeBKi6IZSDdDmQx+hNb8cOXpGzA8y0fQdEzJei+IBvcZvN0cqx8MG9eozPv9Q== X-Received: by 2002:aca:b885:: with SMTP id i127-v6mr15817630oif.180.1534796789861; Mon, 20 Aug 2018 13:26:29 -0700 (PDT) Received: from serve.minyard.net ([47.184.170.128]) by smtp.gmail.com with ESMTPSA id 16-v6sm7205849oin.5.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 D4C2B1453; Mon, 20 Aug 2018 15:26:24 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 2E88030010D; Mon, 20 Aug 2018 15:26:22 -0500 (CDT) From: minyard@acm.org To: Paolo Bonzini , qemu-devel@nongnu.org Date: Mon, 20 Aug 2018 15:26:10 -0500 Message-Id: <1534796770-10295-11-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::244 Subject: [Qemu-devel] [PATCH v2 10/10] 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 , "Dr . David Alan Gilbert" , "Michael S . Tsirkin" 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 Cc: Paolo Bonzini Cc: "Michael S . Tsirkin" Cc: Dr. David Alan Gilbert --- 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 f18aa3d..d4430b0 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 void smbus_eeprom_realize(DeviceState *dev, Error **errp) { SMBusEEPROMDevice *eeprom = (SMBusEEPROMDevice *)dev; @@ -121,12 +134,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,