From patchwork Mon Jun 14 05:51:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 105870 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5E5pPZT030903 for ; Mon, 14 Jun 2010 05:51:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752527Ab0FNFvn (ORCPT ); Mon, 14 Jun 2010 01:51:43 -0400 Received: from qmta06.emeryville.ca.mail.comcast.net ([76.96.30.56]:42383 "EHLO qmta06.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752268Ab0FNFvm (ORCPT ); Mon, 14 Jun 2010 01:51:42 -0400 Received: from omta08.emeryville.ca.mail.comcast.net ([76.96.30.12]) by qmta06.emeryville.ca.mail.comcast.net with comcast id Vhou1e0030FhH24A6hriWw; Mon, 14 Jun 2010 05:51:42 +0000 Received: from localhost.localdomain ([75.71.122.219]) by omta08.emeryville.ca.mail.comcast.net with comcast id Vhrg1e0064k7Kz78UhrhUf; Mon, 14 Jun 2010 05:51:42 +0000 From: Alex Williamson Subject: [RFC PATCH 4/5] eepro100: Add a dev field to eeprom new/free functions To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, avi@redhat.com, anthony@codemonkey.ws, paul@codesourcery.com, kraxel@redhat.com, chrisw@redhat.com, alex.williamson@redhat.com Date: Sun, 13 Jun 2010 23:51:40 -0600 Message-ID: <20100614055140.879.10273.stgit@localhost.localdomain> In-Reply-To: <20100614054923.879.33717.stgit@localhost.localdomain> References: <20100614054923.879.33717.stgit@localhost.localdomain> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 14 Jun 2010 05:51:45 +0000 (UTC) diff --git a/hw/eepro100.c b/hw/eepro100.c index 92cfea7..c5731cc 100644 --- a/hw/eepro100.c +++ b/hw/eepro100.c @@ -1836,7 +1836,7 @@ static int pci_nic_uninit(PCIDevice *pci_dev) cpu_unregister_io_memory(s->mmio_index); vmstate_unregister(&pci_dev->qdev, s->vmstate, s); - eeprom93xx_free(s->eeprom); + eeprom93xx_free(&pci_dev->qdev, s->eeprom); qemu_del_vlan_client(&s->nic->nc); return 0; } @@ -1863,7 +1863,7 @@ static int e100_nic_init(PCIDevice *pci_dev) /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM, * i82559 and later support 64 or 256 word EEPROM. */ - s->eeprom = eeprom93xx_new(EEPROM_SIZE); + s->eeprom = eeprom93xx_new(&pci_dev->qdev, EEPROM_SIZE); /* Handler for memory-mapped I/O */ s->mmio_index = diff --git a/hw/eeprom93xx.c b/hw/eeprom93xx.c index 6ba546f..660b28f 100644 --- a/hw/eeprom93xx.c +++ b/hw/eeprom93xx.c @@ -289,7 +289,7 @@ void eeprom93xx_reset(eeprom_t *eeprom) } #endif -eeprom_t *eeprom93xx_new(uint16_t nwords) +eeprom_t *eeprom93xx_new(DeviceState *dev, uint16_t nwords) { /* Add a new EEPROM (with 16, 64 or 256 words). */ eeprom_t *eeprom; @@ -316,15 +316,15 @@ eeprom_t *eeprom93xx_new(uint16_t nwords) /* Output DO is tristate, read results in 1. */ eeprom->eedo = 1; logout("eeprom = 0x%p, nwords = %u\n", eeprom, nwords); - vmstate_register(NULL, 0, &vmstate_eeprom, eeprom); + vmstate_register(dev, 0, &vmstate_eeprom, eeprom); return eeprom; } -void eeprom93xx_free(eeprom_t *eeprom) +void eeprom93xx_free(DeviceState *dev, eeprom_t *eeprom) { /* Destroy EEPROM. */ logout("eeprom = 0x%p\n", eeprom); - vmstate_unregister(NULL, &vmstate_eeprom, eeprom); + vmstate_unregister(dev, &vmstate_eeprom, eeprom); qemu_free(eeprom); } diff --git a/hw/eeprom93xx.h b/hw/eeprom93xx.h index 47282d3..8ba0e28 100644 --- a/hw/eeprom93xx.h +++ b/hw/eeprom93xx.h @@ -23,10 +23,10 @@ typedef struct _eeprom_t eeprom_t; /* Create a new EEPROM with (nwords * 2) bytes. */ -eeprom_t *eeprom93xx_new(uint16_t nwords); +eeprom_t *eeprom93xx_new(DeviceState *dev, uint16_t nwords); /* Destroy an existing EEPROM. */ -void eeprom93xx_free(eeprom_t *eeprom); +void eeprom93xx_free(DeviceState *dev, eeprom_t *eeprom); /* Read from the EEPROM. */ uint16_t eeprom93xx_read(eeprom_t *eeprom);