From patchwork Mon Jan 28 17:54:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 156834 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3723610jaa; Mon, 28 Jan 2019 10:08:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN7TzVDhkaOiuxrd5+RM/W5hoJtovMLigSzxd0KOvVFvEftOgw5rWox9ih9aWj2SqTJ3ddzE X-Received: by 2002:a1c:87cc:: with SMTP id j195mr17804794wmd.2.1548698920563; Mon, 28 Jan 2019 10:08:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548698920; cv=none; d=google.com; s=arc-20160816; b=aTYZn6lzLGTGnKZ1MFyjvmSu/dRPhYKI/mQXEHPHzxPfeu3Q3MERvgqfSMV3qflMDu wM8htbgjVp9OTar1XjiEQtXOBl/lBwnML0LdcBvlOs0/XraPJ4nzexzhpfRMUNVNwkkY ci5nZGzwAtKQdSmdOpYwYWAcm6mK7o8fzJORvIAo3Jf+ejAvVeH0tLz5+Jq+KxjzrznQ AywzHUY1v6plQclwoGIV/qVXCvLuEff8WQmqOVtvm9pgm4ax0srcaUg2kPDk0w2dRTzP mCoq5+qz5Qvo7ASmskyij5Z0PMK54PNk9ISSmA9l44r9JwNuuUeOp/RYsr+Fkfghgvis iphQ== 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=NombUi5IPvjkVCE/seVpNbqWxT6/YGHreeiD1f06gn8M8OhIBtn/1CMtrJsYNZVAGN 4BCvMlombKjy1ZR6iujXk5O5yKa+51GxyGMxAi9d6Eoq/kZH2WMmz42qIvztTe8xuIvn ALui/Aqy0yYk58GYzllei34v/W+je8WPmvXXYIgF0JfN9YxJtdc6nMH9m5eKL4ynEgES AcRAIIc6LLZzsm68mwH8tQDqPh8T0H8ALJW4Izcfp5HcMUUcbWj0KFRtW6Ne5kPmoGcB /+IdSHrdQJdFHSoFf0QLEYiD4hgjbVcqF4VLIjuQ0yCXC0VpsYTwXoPMT6UaOCxW8bz6 5kvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="JmH/T84G"; 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 v76si88373wmf.105.2019.01.28.10.08.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 10:08:40 -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="JmH/T84G"; 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]:36290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBKl-0007q6-Et for patch@linaro.org; Mon, 28 Jan 2019 13:08:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBEC-0003Zq-K0 for qemu-devel@nongnu.org; Mon, 28 Jan 2019 13:01:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goB8U-0005tU-Vr for qemu-devel@nongnu.org; Mon, 28 Jan 2019 12:56:04 -0500 Received: from mail-it1-x142.google.com ([2607:f8b0:4864:20::142]:38418) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goB8U-0005eu-Pj for qemu-devel@nongnu.org; Mon, 28 Jan 2019 12:55:54 -0500 Received: by mail-it1-x142.google.com with SMTP id z20so20674869itc.3 for ; Mon, 28 Jan 2019 09:55:25 -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=JmH/T84G/XlZ/0h8GK5SIo7bqvVFU/nja/i8J0RAExoWyxSKvnjH91MJXETDx5d4Wd qRQ1CqW2puQD360YTjlsYPxpD6/WOZBGefOPsIKtDT7O417yTmH4c+69O5vwApCUc0Ft 22+ekcQWnb+VDJM7JzrspvovYXu8My4ucBi1PtPZXUl34M7FL6/jj+UXYj0apxVAxJh7 CrfK68lzlbYSRHYhXQyEwYgo+fK79j70Qha68CsiDVRIVR+4Rk97mcr/iw+ldp70Nn+B i1rPzmM6CETRVqRuZiZkCkTtuPBQusYadBznC68hQRSuYRijaIsUji6Cj16wmSBHG6BI PR4Q== 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=fbtj/D0oYlLHNbUelFwfW47Zn33R9odbVxnb9WT1SDa6bXObyju9AK3KDjFXtEq4kT zLAS6PxSDc6aaZeG4Wkg+BgkZtqDQUOHvHoczaZdYb7BxtRw0eXhjoNYODJJomBCHVxm VzdbDlo2v0XdZCHm8hOEXRIKUgz3Vt1fPUF2AvRAUJiobYlk+dc3lfvl7qEoym6PltUv WBlKfGzccHMN7WClhSLi95opWAWF5qAzZwU27I0MhtaPGZetIxGadMapLd2+Y9srG2fj J5muNfZrRbp+zsG2n4SLGU1J15RNm4rXqgP9oSsh1eG4mOH3k812Ecxrxy+2z3NCEwZX aQng== X-Gm-Message-State: AJcUukduEG9bZL/+KcthfIElCZ4ua+y2PjLHUzJplVvMvhw4UNZOlgvX LDQ/K75Ttkl6Zbzn411WwA== X-Received: by 2002:a24:ba0b:: with SMTP id p11mr10809557itf.113.1548698124649; Mon, 28 Jan 2019 09:55:24 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id 193sm42060itl.19.2019.01.28.09.55.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 09:55:22 -0800 (PST) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:c8f8:7971:e432:a838]) by serve.minyard.net (Postfix) with ESMTPA id EFDFCBD2; Mon, 28 Jan 2019 11:55:17 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 95CEE301156; Mon, 28 Jan 2019 11:55:11 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" Date: Mon, 28 Jan 2019 11:54:57 -0600 Message-Id: <20190128175458.27255-19-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190128175458.27255-1-minyard@acm.org> References: <20190128175458.27255-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::142 Subject: [Qemu-devel] [PATCH v4 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 , Paolo Bonzini , Corey Minyard , Corey Minyard , "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 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;