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: 10699149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C91D914E2 for ; Mon, 26 Nov 2018 20:40:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B84942A478 for ; Mon, 26 Nov 2018 20:40:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A90362A491; Mon, 26 Nov 2018 20:40:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 410BE2A478 for ; Mon, 26 Nov 2018 20:40:26 +0000 (UTC) Received: from localhost ([::1]:38774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRNg9-0001DZ-4N for patchwork-qemu-devel@patchwork.kernel.org; Mon, 26 Nov 2018 15:40:25 -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-Google-Smtp-Source: AFSGD/Xt/nd07Pofy8N/8vvmdaBZYDKuuOmIY5ya7gemJ59Sqe+n9PAosiUBor/cVJ52ziHX7MrmOg== 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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;