From patchwork Thu Nov 15 19:24:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 151251 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7408121ljp; Thu, 15 Nov 2018 11:35:49 -0800 (PST) X-Google-Smtp-Source: AJdET5djmL4KLgfjb40ReiymTVlzXe1Y6xwyTsfTGJJfsFAjFQWtkVZKki+PadBFMJ5kyOY1Zgri X-Received: by 2002:a37:5dc3:: with SMTP id r186mr7413188qkb.90.1542310548912; Thu, 15 Nov 2018 11:35:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542310548; cv=none; d=google.com; s=arc-20160816; b=ii/9YJ6aci0kmrvO77LR2VM6HlFWNZtpbxbYQ1M8zT/jKeRvp0kEhM4CqRktBJVYj4 p15o4RT1w+gl4O23aLRyCPJXZL+Xb/Al018uQvfLjFI85zbAZPmvX361KiQ5z1NrtRrU 25TgDBQEEcSu09Jn3FPk9czuvUjoMwmicjJ1WvCIxqnYHupifVkeVAnq/yqgsUI5Jh/n RU1xdQxwkNXmJlQKDZrwV7r8EJU1HpdGL+1BfBIAUwocQl4SIU5LsrJJ66voUuOtxSTB gevcZzsE+6oI7sjsCbcfXxOX+1frY7OAl3Jin65y5SLEuiD/VJjIrH9G/jD/djlcoSOv gOog== 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; bh=U7PF6PlPdlEej18pUL4e+tkP6MmtKltLyjtOEJeI/bM=; b=gOaT8FjBI5HUguOD2+23gZp9oW/Nr6tCa5oX1Z+rd+cvZ/MktaDB1GB+ktj7Ym/An1 yvqivB0JVOA2xT3vKSnAWGJEUlLMKyv7aRdl4foQLR7u4Urh5YgabYHEqZPg+WdGQwM4 oDg8JjS52fNFUhA1ZvpGLWpCCztEmrKlMfkRI5qApuks88nEJ8EMYjRwpTDYTU0+azti 2dwCuMN2tMCGD97aadNP6/pzVGsp5cFZ7zgGoKYiGw/6OQYf3Y7WvWgUE0n6oJy6MldP nUZaCkL20c0Cdg8fRzapG6H77NBXbjFWkV3JigoWteuHdmZFsghgiHBkWE76pygHhTiw +ORQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=KxTEiWfE; 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 r95si9070324qkh.131.2018.11.15.11.35.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 15 Nov 2018 11:35:48 -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=KxTEiWfE; 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]:40486 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNNQa-0003ho-Dp for patch@linaro.org; Thu, 15 Nov 2018 14:35:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNNGY-0003gT-UF for qemu-devel@nongnu.org; Thu, 15 Nov 2018 14:25:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNNGF-00084M-GC for qemu-devel@nongnu.org; Thu, 15 Nov 2018 14:25:17 -0500 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:42501) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gNNGD-00081u-HB for qemu-devel@nongnu.org; Thu, 15 Nov 2018 14:25:05 -0500 Received: by mail-ot1-x342.google.com with SMTP id n46so19071313otb.9 for ; Thu, 15 Nov 2018 11:25:01 -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=U7PF6PlPdlEej18pUL4e+tkP6MmtKltLyjtOEJeI/bM=; b=KxTEiWfExc53eeEcEd3bAsyas592ZZ93mgm99MFhRqkC8UXaG9Clcr4oIBrHm8XaqA 4rY1/drR/ZSsbaBVHiISg45Aorpn9oWdJRjFNuasZqe/4MU0nFhwqz+8nC9LZki+ekT9 XZC6B7k4lg4DnLjvNo75beEP/wdjWvtmH2EhMQ5SZ8LWEkXf/HL52FyYMNlx/UsdxNB8 0H+niYw+1ePoKk75uZYEFX8WfRFwwKfLuy3mHQxXRX8wFS/hE4i2DOJmGAF331suE/ce WCecQZ6mKvTB+cyD0iMAfLUAURzUNgPIbaVXWSLGu7GMygjfWx3WCtTZymCXZmAwm7ni ETcQ== 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=U7PF6PlPdlEej18pUL4e+tkP6MmtKltLyjtOEJeI/bM=; b=AB5BIUv49MrE0FXiAJkSWXDVcAk7SOsoGZXT/5OUGF/8W+6L8X1/2qj32Fzf2xnFxa 0CFjZy1HCoSW5GWWMv+VJwk6AYSdTtySe9H5hHOAbgpCiN9Uwul2f/0HoceRtVSxiwgb o4NMZ1lZBBkcZmR0jvP0W6OnzidxWqy3Ic1MhcM43hz/be6+cjuEgjSqFwCAM/YSp5gq h8AiC00CM8GsFDXhvbWbze657q6kqvqvxC+woSnrDrJtmcVLui3vdo+cnNNFsnOjwlvq IZpE13etv5wtqrbXY9E5mC28pccl0vl4Mrz9tYUuK3A26oM2T3/g6rAZP5x+nvaSdjSd 3XRw== X-Gm-Message-State: AGRZ1gJVLZvnRxqEC0ySlpoUu372EA1YGZMQsXsqf6JSeLSr0siOp/cY 0H8jTLDBAcK3P0C7103yTQ== X-Received: by 2002:a9d:5413:: with SMTP id j19mr4576609oth.7.1542309901211; Thu, 15 Nov 2018 11:25:01 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id u12sm16090394otf.61.2018.11.15.11.24.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 11:24:57 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 9F1911E62; Thu, 15 Nov 2018 13:24:51 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 3301830146C; Thu, 15 Nov 2018 13:24:49 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 13:24:46 -0600 Message-Id: <20181115192446.17187-13-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181115192446.17187-1-minyard@acm.org> References: <20181115192446.17187-1-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::342 Subject: [Qemu-devel] [PATCH v2 12/12] i2c: Add a reset function to 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: Paolo Bonzini , Corey Minyard , "Dr . David Alan Gilbert" , minyard@acm.org, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Reset the contents to init data and reset the offset on a machine reset. Signed-off-by: Corey Minyard --- hw/i2c/smbus_eeprom.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index 942057dc10..d0a8d63869 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -106,7 +106,7 @@ static const VMStateDescription vmstate_smbus_eeprom = { } }; -static void smbus_eeprom_realize(DeviceState *dev, Error **errp) +static void smbus_eeprom_reset(DeviceState *dev) { SMBusEEPROMDevice *eeprom = SMBUS_EEPROM(dev); @@ -114,6 +114,11 @@ static void smbus_eeprom_realize(DeviceState *dev, Error **errp) eeprom->offset = 0; } +static void smbus_eeprom_realize(DeviceState *dev, Error **errp) +{ + smbus_eeprom_reset(dev); +} + static Property smbus_eeprom_properties[] = { DEFINE_PROP_PTR("data", SMBusEEPROMDevice, init_data), DEFINE_PROP_END_OF_LIST(), @@ -125,6 +130,7 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data) SMBusDeviceClass *sc = SMBUS_DEVICE_CLASS(klass); dc->realize = smbus_eeprom_realize; + dc->reset = smbus_eeprom_reset; sc->receive_byte = eeprom_receive_byte; sc->write_data = eeprom_write_data; dc->props = smbus_eeprom_properties;