From patchwork Thu Feb 28 18:17:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 159415 Delivered-To: patch@linaro.org Received: by 2002:ac9:18c7:0:0:0:0:0 with SMTP id i7csp982402oce; Thu, 28 Feb 2019 10:27:18 -0800 (PST) X-Google-Smtp-Source: APXvYqx96De6RtZywd/iL4ewNc+G/hNrxq1fZxplPWOsd+DqSqw7bWZLijvd4NfmGGKyKzvIt7rW X-Received: by 2002:a25:4902:: with SMTP id w2mr757382yba.26.1551378438822; Thu, 28 Feb 2019 10:27:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551378438; cv=none; d=google.com; s=arc-20160816; b=DVZVDraFrKkeMzSgAJkNifeGlyGIXEA90Tglxdt1Jfq02ca0vYZgNYgrx/C6scW8wE iGabVGTJDz3BTRZoQ8gx/iIbDGuIpLCcl12cuNosLospRZchObcPGf9iZ8ose17edHkL HAtVo+AukK4u6gZjjAMmqhMkiuLCnwSPIVxxBEGLzJV75i8LY2aW8UJn0Fr/tMRuXjLK aXCUgwZw9ER5nLXzpH952W6lFNZ1rcmgi38pWGXQD4SW5iKAqaQmWDmRVIrikXd0ZfkM w8KtFsuDoDZYbbsr4izzcKK6aSHMlbxWoagZ+kNF97t2h1s5afR+0Xx96hS4hTEgh1Aa QWeA== 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=578+1MXr+/10iSBsluW/Nwhfp8x/6PPyLTwDlnrEJC8=; b=UaWCe1cKsAZYiR5Srf5QSauIZlptMG6eHhm/ynkxGQ1ccdjyhXWEkhR30E8S9OsKq0 Ho4IPwkXSs59i3klaTe+lOph+vyup5Gt20IaENU32a3xWUIwKiHBRT+db9U9Mp/NUjcs N0WjAEaBhMjj+FlF62BrwQcWmBhVrWpNYYEy7uoJkWV8kKLlyhjPWmDag8wytj3QIFkr /OK1E3oH5d21+7z/dzhdcjKlm/6fNFU7udhtUAApoKPNbnPW11fX/E06HM82fSLqN/3f yUd2GzHS+RzB9tbYwLzsuAqVijl8BscGyaVzu9mFobFtK07BAEYlXU0ScrNgZjZnsYKy RSFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qky0b50a; 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 d18si10977126ywh.325.2019.02.28.10.27.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 28 Feb 2019 10:27:18 -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=qky0b50a; 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]:44614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQOs-0006ld-B2 for patch@linaro.org; Thu, 28 Feb 2019 13:27:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQFe-0000VO-BN for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:18:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzQFV-0002Ha-G9 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:44 -0500 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:35201) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzQFV-0002DZ-5v for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:37 -0500 Received: by mail-ot1-x343.google.com with SMTP id z19so18560642otm.2 for ; Thu, 28 Feb 2019 10:17:29 -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=578+1MXr+/10iSBsluW/Nwhfp8x/6PPyLTwDlnrEJC8=; b=qky0b50aJcOrdSjirc6oTNag3iYNWLtRWIH0Dpaef1WPuPiLLxDaKQpTU1QQj6YvwN RF9X4tWnq+IzygXmAMsybw2B/tGJZBEs8q9xohMgzOwDZJbF3pJds0LNMlwu839Blass 7Bo2+mkLT2ISemtjIn0FaM65JG3mYnwMtV6GgQiEbvapGsZIUP8wP20e60QOzQh42ZqD G7H7aRAEePjrsnoDNLHIS0vu0pSrWrGgWm/aHyzADK0GQGR7ZW2AS7oScrsD2kdJvBmB v1DuEx+f33ccGCoCeS+mpOQx3b+eV3SefJ6foAkcGsYZBP9gkGVlaRbZAuQej00fe/jI PFDg== 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=578+1MXr+/10iSBsluW/Nwhfp8x/6PPyLTwDlnrEJC8=; b=L7d2j6oZ8TzOZGAEugaXCdf3wsyVQLMoXUK5cUNbFDvWWO7wQ7RYf2PVyESkLuTSLx shQeDnzZA8XrpGBDUh2u9QzPeB0EA/y1KT1zjPPrl4LsCvMO5+/6nKz9QPirvL6oQPr0 2q3RRptVGdhBJt0zcRxxiCGDxKz1ZTvyyxI0h+E3xuXNhrcRkCTiD5fBadsTDNnRJNog k3b+zmCOMnuMLvsfeY0OMZfR14dPqLyZbTX/F6NDHdwxLAxE0JKDpXjzqMtTjNFb77RY QC16HJIVv8cvrMdR9sHOxkipVxzniYlXgkguyD9Bk7hCygd4TBofWrEMFSsHPzEd/+bw zKdg== X-Gm-Message-State: APjAAAX/iVTmY9RZ3hh9LV8lMJNquya9Mjhh04tMwVEMrpfKkQzVkY/J qKeSjVbluJ1tHf+p8+sZ6Q== X-Received: by 2002:a9d:7cc2:: with SMTP id r2mr702193otn.282.1551377848969; Thu, 28 Feb 2019 10:17:28 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id b131sm5471757oia.28.2019.02.28.10.17.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 10:17:25 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id D7F79180902; Thu, 28 Feb 2019 18:17:14 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id C61783028D0; Thu, 28 Feb 2019 12:17:14 -0600 (CST) From: minyard@acm.org To: Peter Maydell Date: Thu, 28 Feb 2019 12:17:09 -0600 Message-Id: <20190228181710.2477-19-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190228181710.2477-1-minyard@acm.org> References: <20190228181710.2477-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::343 Subject: [Qemu-devel] [PULL 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: Corey Minyard , QEMU Developers , minyard@acm.org 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 5b10c31ae7..0ba5763fc2 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -108,7 +108,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); @@ -116,6 +126,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(), @@ -127,6 +142,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;