From patchwork Wed Feb 20 13:59:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 158829 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5078555jaa; Wed, 20 Feb 2019 07:50:59 -0800 (PST) X-Google-Smtp-Source: AHgI3IbLM76oxC+PKyn86sJS1ogmOAVyY5Ef9q7Jcoc7+rPDBcdOnQxz6ZXnx8b18Er7abZPL6y6 X-Received: by 2002:a81:5a86:: with SMTP id o128mr26781161ywb.205.1550677859664; Wed, 20 Feb 2019 07:50:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550677859; cv=none; d=google.com; s=arc-20160816; b=nbxq5BuGclF9if9wwde6XgW2JiXM6DA9Lqd5QEjOipVLbjZ2dXHCxhh7M5Ju8D4oq/ IXFp26b3Tpsrmb6v4/GH6EcE+M3Nho+yq8KFoARJ8zK9KEj1LJGoAHpAIzam394hujp8 yGwESg8hWfpbRKW5BNiGjwvUBoLY0vLTDP9TqtpeMj5JtHzs7+VGbBuH8+HcaK0hkBW0 RObDDfHc9y31A2qWBiuL5Esgz1bpAG4oA64n4c8C6sFQceClzasmgtBNkCB23f7bLXVf AP3HFQpGmDX8gkcA/ctK85yJQzUuANY5kzrkqM18PhlAZrEj8ZBBkn3iTb+wSoh347k8 6RCA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=WonWmYMnT8u7LZWW1RNFTm76th+WgxeztPZLRKTOfE4=; b=svFWRYkmbdwqgf4LRRgD/9BhWqpy/1Abi25DzZ5+tO3I2s//xXlmuw+YlOxyP/3oPe oXtjb02a1Xwy0Njci+D5mpRpFZ/s2maiN539Tt9j05Hj8MODzS7uTJl0wxNpgUa4N2gv l2MTqyUnoErzRARa7/oyJ/Ap2He94GTnLPGKedkeBeeV5kwshBTPv8zG6k49CJutVBlh 8v574UTU65lv4NbUAY5K2xQ1z5UBeM2yPvb/vK7sbLXFDlYQbg/BL6sZVzXCOWjaVuVI 735BQxxRoSmEU4AvS3Klec2yAZ5yWP9+W2PNJVXpOaPmATW1Rf7rlDqbvg4+MBkoKLuQ hXJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=dskQAQcM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v127si11032732ybv.113.2019.02.20.07.50.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 20 Feb 2019 07:50:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=dskQAQcM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:41254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwU9D-0003qF-3T for patch@linaro.org; Wed, 20 Feb 2019 10:50:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwTvu-000200-6z for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:37:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwTvq-0005u9-3Z for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:37:13 -0500 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:43372) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwTvn-0005UN-8a for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:37:09 -0500 Received: by mail-ot1-x344.google.com with SMTP id n71so40778176ota.10 for ; Wed, 20 Feb 2019 07:36: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 :mime-version:content-transfer-encoding; bh=WonWmYMnT8u7LZWW1RNFTm76th+WgxeztPZLRKTOfE4=; b=dskQAQcMSKCTpMNshfMFyHEton0vbBwqjFEisPnrrQJZ8SwGIvP7SOTE+34/t5d3jo K4Pv7hpEWvl+EvjhW2BlxLPDeNCI5Ax5eiCoT7YHBbGMgAv3KOw8Xe/dSoIkhVvJyUSP Nq9qymjd4SL3fRcvgLMCeIsFK5fMkZzDfSn5frKnBmwjTegjGKk/Bvqd3smPK4ZU92ue yenYiMhVJar/ojNa6nTDVK+sKOI+eXVyvY3J3Pr/QxQKOHjDdKsbDU+mLPi/Q3WP0uJU EExboCNdRr+GNI62XkO7Hrj44zKwONyf4gAQFAwZcgtRnmuHXBenJp3uhWo8oAYQZFJQ OpUQ== 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:mime-version:content-transfer-encoding; bh=WonWmYMnT8u7LZWW1RNFTm76th+WgxeztPZLRKTOfE4=; b=OwOWrNSxh+6aPU6uB177WKwIAkaRbllj1v9eIchlSR37npJEaJA50CSoMA7NCdy9E/ spYP7/g4L8veuDLfRcRshjqX5zOdMbRn222ndzOf4LfmjCaacRquy6wtVp5BwzeAprMd vd/lVcJWOW1cdBRyaqByyLFL7NRHMiJpnAYrDkv+VkhJKAynPgCvZUH20tcS/PYR5E6Q /gVdzosN8uvadoonEMEuTpM6MpjQ3BdQ9N+gkL2Tcj2o5qFIiBUe7B24UtKiZ5PmtwNK bEXQAMuYxt74hVx1mRgrz+2VGlC8n3DtSXbq7wXM2TQ0e81cENA/r7R7kvIpXqAokN8E ko6g== X-Gm-Message-State: AHQUAubMGZLuAfx4DBjHQ6U05ZpojCo0gk11XPcq2bpQY3TmN49ZUIlo fy7S5/9j69ZiT2hAdNECjCLOHBPeqA== X-Received: by 2002:a9d:5617:: with SMTP id e23mr22212269oti.193.1550671222553; Wed, 20 Feb 2019 06:00:22 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id q24sm8037917otk.46.2019.02.20.06.00.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Feb 2019 06:00:20 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 4F8BE1808FE; Wed, 20 Feb 2019 14:00:11 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id 23A7F302812; Wed, 20 Feb 2019 08:00:10 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 07:59:55 -0600 Message-Id: <20190220135956.22589-19-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190220135956.22589-1-minyard@acm.org> References: <20190220135956.22589-1-minyard@acm.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::344 Subject: [Qemu-devel] [PATCH 18/19] i2c:smbus_eeprom: 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: Peter Maydell , Corey Minyard , Corey Minyard , "Michael S . Tsirkin" , "Dr . David Alan Gilbert" , Paolo Bonzini 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 Reviewed-by: Philippe Mathieu-Daudé --- hw/i2c/smbus_eeprom.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index c0a0c4d501..44887b4a27 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -106,7 +106,17 @@ static const VMStateDescription vmstate_smbus_eeprom = { } }; -static void smbus_eeprom_realize(DeviceState *dev, Error **errp) +/* + * Reset the EEPROM contents to the initial state on a reset. This + * isn't really how an EEPROM works, of course, but the general + * principle of QEMU is to restore function on reset to what it would + * be if QEMU was stopped and started. + * + * The proper thing to do would be to have a backing blockdev to hold + * the contents and restore that on startup, and not do this on reset. + * But until that time, act as if we had been stopped and restarted. + */ +static void smbus_eeprom_reset(DeviceState *dev) { SMBusEEPROMDevice *eeprom = SMBUS_EEPROM(dev); @@ -114,6 +124,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 +140,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;