From patchwork Mon Nov 26 20:04:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 152079 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp345197ljp; Mon, 26 Nov 2018 12:39:49 -0800 (PST) X-Google-Smtp-Source: AJdET5ea8IioXu7Pu77FRQJdErFuVv1Q+6j6Z9bl4x1zjgsMqHXDS2okOLtMWg+sp7tQGwAtZnqU X-Received: by 2002:a81:ad60:: with SMTP id l32mr29932553ywk.64.1543264789438; Mon, 26 Nov 2018 12:39:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543264789; cv=none; d=google.com; s=arc-20160816; b=S91a7Rj6AUhs9stb9O8qN72qhk8WFvCfi6HbWMkZSFjax7IQBLpTzCaWK0UBqYdvID TOdbdz+HLwwFnIgW9/LMOPOlfjmSYFwoR40n2EhawYVjYRdxuzgMCMe0okq/HkG8IV7S qDKvAlSCcwuMhX7898fbw83RgP2EQGEtS4I5VueTIJcEVHiVKFJQFpI8e1Kn19+p2noh f8qkFVxSjirewM281aj3VgWV5V6fvw2wpNSQ46nhurFbrgKxHBfVmVDSoG0FHSw7qD9e ics7zrftv23QxkSkmM8qoglSRVeHOWatLCIymi0NJAet2ra/q2Py7PMex23f8thLhX2t loJA== 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=Yw6EKNcC1y/dHBmPzkzOpSFON0gZns1Zjs8Jkp8E5Hk=; b=hQXTKdVT3CBXRDrMit7OldDpVovm2OOJ71kzbPnQYWPgSneOy8EP/RMf2qO3oc7PX4 6rEyu0YwAzS0vg1NPjL4VLV0zkR+4a7s7KJJ0/sKUQMPclOxqFIW3L7/9axe4Q3xFQim ysS+utvzPoNr2Vp4KBw/3ropZ2ACaQL5D4UXwvAMq8seCcx5whK8JutUGbSAVXRYzE8W XjRHcmeHLB7tiVuPCfTFpvJn7A095ozvuFQO3ucfxzRfAyibldPVr23vLQfQiLOKLPKA lbD2wVBb4ul4sjht87XJqzhsoryQ7v2f2xRPqwvViLeibN7e7FikZGkuGe7UDPigf9cv KbIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=gYYSGioN; 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 x185-v6si986350ywc.180.2018.11.26.12.39.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 26 Nov 2018 12:39:49 -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=gYYSGioN; 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]:38765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRNfY-0000c0-Uk for patch@linaro.org; Mon, 26 Nov 2018 15:39:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRNE4-0007Vs-LD for qemu-devel@nongnu.org; Mon, 26 Nov 2018 15:11:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRNE0-0002kA-Ne for qemu-devel@nongnu.org; Mon, 26 Nov 2018 15:11:24 -0500 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:43052) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRNE0-0002k2-DV for qemu-devel@nongnu.org; Mon, 26 Nov 2018 15:11:20 -0500 Received: by mail-ot1-x342.google.com with SMTP id a11so17858431otr.10 for ; Mon, 26 Nov 2018 12:11:20 -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=Yw6EKNcC1y/dHBmPzkzOpSFON0gZns1Zjs8Jkp8E5Hk=; b=gYYSGioNLAfV30Y2ftIBmNo2jbtqcvVW09U4RgXLikkqzR5nfMhgQgs9EguwBJXSKX ufAaB+JW1puRXHk2ABOLMpLQsnKRVcJEsSjvxcZPxoPGm25vS8wfBRzT/vg77J7qZF9p 1Gdn55QsWedSHjDET0OE9v/MpWhZjZeM1fCwBI++b1bOoa/gc0lmUPXn4TYvk1b91g7U lq0muRkeR20gTjbeZaXbyIBZuL+9SDE9ZZUJ+IPf4Tl8SBCneDbUHslS5DBLyxWpKdoM W0dbA3tY2K1knzGJKLi9mfQnz1IdyNhzwLbd6iGw0e/AXVz9320GZV9xY3FYIiS7r3R3 O+9Q== 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=Yw6EKNcC1y/dHBmPzkzOpSFON0gZns1Zjs8Jkp8E5Hk=; b=KXfXu9DxgyN8ZYOTUEtrhOscC1wQ4owBWHe69OxRv6M6lzesSH4Y4pbXW0m65YQJlt AssyuDup7NI782/8z/bagdoERfhaC9zmtcL97cek18wlX61LFbHgXVSb6WtRkbYCrFVp S8vRGeEdlV0xLYB+LDKyXkd67pHT4BlBUj/XKwkt6gmWJ1riEPER/bmkX9DfBd47oicU 44nHWhQ9vsg+/0XULNE0jXjDImuUR2MoNdSN2ZDyDR06v0gsujoKoRM+ktf+u3MbndNK cip4n01PoHeoeqaPPZqiwHwr8HdsUMqYYznXPkRMMA6WT9z7b+XTE2ODXjN8hD1/FGi0 DvNw== X-Gm-Message-State: AA+aEWaT42wvvcPsAW2bdbD8IrAxIp7lMdOoAH0OKsnbEUI7AaCBYoXN Ns+UVEZsPCHhNp1n3ZzIfA== X-Received: by 2002:a9d:4b17:: with SMTP id q23mr16833166otf.121.1543263078758; Mon, 26 Nov 2018 12:11:18 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id 21sm405168oie.24.2018.11.26.12.11.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 12:11:17 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 128381F90; Mon, 26 Nov 2018 14:04:50 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id F0F04301471; Mon, 26 Nov 2018 14:04:46 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Date: Mon, 26 Nov 2018 14:04:35 -0600 Message-Id: <20181126200435.23408-17-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181126200435.23408-1-minyard@acm.org> References: <20181126200435.23408-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 v3 16/16] 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: 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 --- hw/i2c/smbus_eeprom.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index a0dcadbd60..de3a492df4 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -107,7 +107,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); @@ -115,6 +115,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(), @@ -126,6 +131,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;