qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 03/26] eepro100: Remove unused indirection of PCIDevice
Date: Mon, 24 Aug 2009 18:42:37 +0200	[thread overview]
Message-ID: <06aa59ddf55102747ecd892cba83847b4adfcc69.1251131364.git.quintela@redhat.com> (raw)
In-Reply-To: <cover.1251131364.git.quintela@redhat.com>
In-Reply-To: <cover.1251131364.git.quintela@redhat.com>

Once there, there is no way that we don't have a PCI Device at save/load time. Remove the check

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/eepro100.c |   57 +++++++++++++++++++++++----------------------------------
 1 files changed, 23 insertions(+), 34 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 1776975..bdc8353 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -181,6 +181,7 @@ typedef enum {
 } ru_state_t;

 typedef struct {
+    PCIDevice dev;
 #if 1
     uint8_t cmd;
     uint32_t start;
@@ -200,7 +201,6 @@ typedef struct {
     uint8_t curpag;
     uint8_t mult[8];            /* multicast mask array */
     int mmio_index;
-    PCIDevice *pci_dev;
     VLANClientState *vc;
 #endif
     uint8_t scb_stat;           /* SCB stat/ack byte */
@@ -304,7 +304,7 @@ static void disable_interrupt(EEPRO100State * s)
 {
     if (s->int_stat) {
         logout("interrupt disabled\n");
-        qemu_irq_lower(s->pci_dev->irq[0]);
+        qemu_irq_lower(s->dev.irq[0]);
         s->int_stat = 0;
     }
 }
@@ -313,7 +313,7 @@ static void enable_interrupt(EEPRO100State * s)
 {
     if (!s->int_stat) {
         logout("interrupt enabled\n");
-        qemu_irq_raise(s->pci_dev->irq[0]);
+        qemu_irq_raise(s->dev.irq[0]);
         s->int_stat = 1;
     }
 }
@@ -392,7 +392,7 @@ static void eepro100_fcp_interrupt(EEPRO100State * s)
 static void pci_reset(EEPRO100State * s)
 {
     uint32_t device = s->device;
-    uint8_t *pci_conf = s->pci_dev->config;
+    uint8_t *pci_conf = s->dev.config;

     logout("%p\n", s);

@@ -1338,16 +1338,10 @@ static void ioport_write4(void *opaque, uint32_t addr, uint32_t val)
 /***********************************************************/
 /* PCI EEPRO100 definitions */

-typedef struct PCIEEPRO100State {
-    PCIDevice dev;
-    EEPRO100State eepro100;
-} PCIEEPRO100State;
-
 static void pci_map(PCIDevice * pci_dev, int region_num,
                     uint32_t addr, uint32_t size, int type)
 {
-    PCIEEPRO100State *d = DO_UPCAST(PCIEEPRO100State, dev, pci_dev);
-    EEPRO100State *s = &d->eepro100;
+    EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);

     logout("region %d, addr=0x%08x, size=0x%08x, type=%d\n",
            region_num, addr, size, type);
@@ -1420,15 +1414,15 @@ static CPUReadMemoryFunc *pci_mmio_read[] = {
 static void pci_mmio_map(PCIDevice * pci_dev, int region_num,
                          uint32_t addr, uint32_t size, int type)
 {
-    PCIEEPRO100State *d = DO_UPCAST(PCIEEPRO100State, dev, pci_dev);
+    EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);

     logout("region %d, addr=0x%08x, size=0x%08x, type=%d\n",
            region_num, addr, size, type);

     if (region_num == 0) {
         /* Map control / status registers. */
-        cpu_register_physical_memory(addr, size, d->eepro100.mmio_index);
-        d->eepro100.region[region_num] = addr;
+        cpu_register_physical_memory(addr, size, s->mmio_index);
+        s->region[region_num] = addr;
     }
 }

@@ -1551,8 +1545,8 @@ static int nic_load(QEMUFile * f, void *opaque, int version_id)
     if (version_id > 3)
         return -EINVAL;

-    if (s->pci_dev && version_id >= 3) {
-        ret = pci_device_load(s->pci_dev, f);
+    if (version_id >= 3) {
+        ret = pci_device_load(&s->dev, f);
         if (ret < 0)
             return ret;
     }
@@ -1637,8 +1631,7 @@ static void nic_save(QEMUFile * f, void *opaque)
     EEPRO100State *s = opaque;
     int i;

-    if (s->pci_dev)
-        pci_device_save(s->pci_dev, f);
+    pci_device_save(&s->dev, f);

     qemu_put_8s(f, &s->rxcr);

@@ -1720,8 +1713,7 @@ static void nic_cleanup(VLANClientState *vc)

 static int pci_nic_uninit(PCIDevice *dev)
 {
-    PCIEEPRO100State *d = DO_UPCAST(PCIEEPRO100State, dev, dev);
-    EEPRO100State *s = &d->eepro100;
+    EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, dev);

     cpu_unregister_io_memory(s->mmio_index);

@@ -1730,16 +1722,13 @@ static int pci_nic_uninit(PCIDevice *dev)

 static void nic_init(PCIDevice *pci_dev, uint32_t device)
 {
-    PCIEEPRO100State *d = DO_UPCAST(PCIEEPRO100State, dev, pci_dev);
-    EEPRO100State *s;
+    EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);

     logout("\n");

-    d->dev.unregister = pci_nic_uninit;
+    s->dev.unregister = pci_nic_uninit;

-    s = &d->eepro100;
     s->device = device;
-    s->pci_dev = &d->dev;

     pci_reset(s);

@@ -1748,24 +1737,24 @@ static void nic_init(PCIDevice *pci_dev, uint32_t device)
     s->eeprom = eeprom93xx_new(EEPROM_SIZE);

     /* Handler for memory-mapped I/O */
-    d->eepro100.mmio_index =
+    s->mmio_index =
         cpu_register_io_memory(pci_mmio_read, pci_mmio_write, s);

-    pci_register_bar(&d->dev, 0, PCI_MEM_SIZE,
+    pci_register_bar(&s->dev, 0, PCI_MEM_SIZE,
                            PCI_ADDRESS_SPACE_MEM |
                            PCI_ADDRESS_SPACE_MEM_PREFETCH, pci_mmio_map);
-    pci_register_bar(&d->dev, 1, PCI_IO_SIZE, PCI_ADDRESS_SPACE_IO,
+    pci_register_bar(&s->dev, 1, PCI_IO_SIZE, PCI_ADDRESS_SPACE_IO,
                            pci_map);
-    pci_register_bar(&d->dev, 2, PCI_FLASH_SIZE, PCI_ADDRESS_SPACE_MEM,
+    pci_register_bar(&s->dev, 2, PCI_FLASH_SIZE, PCI_ADDRESS_SPACE_MEM,
                            pci_mmio_map);

-    qdev_get_macaddr(&d->dev.qdev, s->macaddr);
+    qdev_get_macaddr(&s->dev.qdev, s->macaddr);
     logout("macaddr: %s\n", nic_dump(&s->macaddr[0], 6));
     assert(s->region[1] == 0);

     nic_reset(s);

-    s->vc = qdev_get_vlan_client(&d->dev.qdev,
+    s->vc = qdev_get_vlan_client(&s->dev.qdev,
                                  nic_can_receive, nic_receive, NULL,
                                  nic_cleanup, s);

@@ -1794,15 +1783,15 @@ static void pci_i82559er_init(PCIDevice *dev)
 static PCIDeviceInfo eepro100_info[] = {
     {
         .qdev.name = "i82551",
-        .qdev.size = sizeof(PCIEEPRO100State),
+        .qdev.size = sizeof(EEPRO100State),
         .init      = pci_i82551_init,
     },{
         .qdev.name = "i82557b",
-        .qdev.size = sizeof(PCIEEPRO100State),
+        .qdev.size = sizeof(EEPRO100State),
         .init      = pci_i82557b_init,
     },{
         .qdev.name = "i82559er",
-        .qdev.size = sizeof(PCIEEPRO100State),
+        .qdev.size = sizeof(EEPRO100State),
         .init      = pci_i82559er_init,
     },{
         /* end of list */
-- 
1.6.2.5

  parent reply	other threads:[~2009-08-24 16:45 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-24 16:42 [Qemu-devel] [PATCH 00/26] Indirection Cleanup Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 01/26] eepro100: convert casts to DO_UPCAST() Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 02/26] eepro100: cast a void * makes no sense Juan Quintela
2009-08-24 16:42 ` Juan Quintela [this message]
2009-08-24 16:42 ` [Qemu-devel] [PATCH 04/26] pci: remove casts from void * Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 05/26] rtl8139: Remove unneeded double indirection of PCIRTL8139State Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 06/26] rtl8139: remove pointless cast from void * Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 07/26] lsi53c895a: " Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 08/26] lsi53c895a: use DO_UPCAST to cast from PCIDevice Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 09/26] lsi53c895a: rename PCIDevice field from pci_dev to dev (consistence) Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 10/26] lsi53c895a: LSIState is a DeviceHost Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 11/26] Introduce vga_common_reset() to be able to typcheck vga_reset() Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 12/26] vga: Rename vga_state -> vga Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 13/26] Everything outside of vga.c should use VGACommonState Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 14/26] usb-ohci: Change casts to DO_UPCAST() for OHCIPCIState Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 15/26] ne2000: remove casts from void * Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 16/26] ne2000: pci_dev has this very value with the right type Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 17/26] ne2000: Change casts to DO_UPCAST() for PCINE2000State Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 18/26] We need PCINE2000State for save/load functions Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 19/26] Add pci_ne2000_{save/load} functions, then remove pci_dev NE2000State field Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 20/26] cirrus_vga: remove pointless cast from void * Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 21/26] cirrus_vga: Change casts to DO_UPCAST() for PCICirrusVGAState Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 22/26] Add pci_cirrus_vga_{save/load} functions, then remove vga.pci_dev use Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 23/26] pcnet: Change casts to DO_UPCAST() for PCIPCNetState Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 24/26] pcnet: remove useless casts This are casts to the very type of the function Juan Quintela
2009-08-24 16:42 ` [Qemu-devel] [PATCH 25/26] pcnet: Add pci_pcnet_{save/load} functions, then remove PCNetState pci_dev field Juan Quintela
2009-08-24 16:43 ` [Qemu-devel] [PATCH 26/26] e1000 cleanup Juan Quintela
2009-08-25  8:22 ` [Qemu-devel] [PATCH 00/26] Indirection Cleanup Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=06aa59ddf55102747ecd892cba83847b4adfcc69.1251131364.git.quintela@redhat.com \
    --to=quintela@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).