[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 28/61] pci: factor out while(bus) bus->next loop log
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH 28/61] pci: factor out while(bus) bus->next loop logic into pci_find_bus_from(). |
Date: |
Wed, 30 Sep 2009 19:18:04 +0900 |
factor out while(bus) bus->next loop logic into pci_find_bus_from()
which will be used later.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/pci.c | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 6a28fa5..5d6b3ea 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -577,6 +577,16 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr,
uint32_t val, int l)
pci_update_mappings(d);
}
+static PCIBus *pci_find_bus_from(PCIBus *from, int bus_num)
+{
+ PCIBus *s = from;
+
+ while (s && s->bus_num != bus_num)
+ s = s->next;
+
+ return s;
+}
+
void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len)
{
PCIBus *s = opaque;
@@ -588,8 +598,7 @@ void pci_data_write(void *opaque, uint32_t addr, uint32_t
val, int len)
addr, val, len);
#endif
bus_num = (addr >> 16) & 0xff;
- while (s && s->bus_num != bus_num)
- s = s->next;
+ s = pci_find_bus_from(s, bus_num);
if (!s)
return;
pci_dev = s->devices[(addr >> 8) & 0xff];
@@ -610,8 +619,7 @@ uint32_t pci_data_read(void *opaque, uint32_t addr, int len)
uint32_t val;
bus_num = (addr >> 16) & 0xff;
- while (s && s->bus_num != bus_num)
- s= s->next;
+ s = pci_find_bus_from(s, bus_num);
if (!s)
goto fail;
pci_dev = s->devices[(addr >> 8) & 0xff];
@@ -795,8 +803,7 @@ void pci_for_each_device(int bus_num, void (*fn)(PCIDevice
*d))
PCIDevice *d;
int devfn;
- while (bus && bus->bus_num != bus_num)
- bus = bus->next;
+ bus = pci_find_bus_from(bus, bus_num);
if (bus) {
for(devfn = 0; devfn < 256; devfn++) {
d = bus->devices[devfn];
@@ -896,12 +903,7 @@ static void pci_bridge_write_config(PCIDevice *d,
PCIBus *pci_find_bus(int bus_num)
{
- PCIBus *bus = first_bus;
-
- while (bus && bus->bus_num != bus_num)
- bus = bus->next;
-
- return bus;
+ return pci_find_bus_from(first_bus, bus_num);
}
PCIDevice *pci_find_device(int bus_num, int slot, int function)
--
1.6.0.2
- [Qemu-devel] Re: [PATCH 32/61] pci: helper functions to access PCIDevice::config, (continued)
- [Qemu-devel] [PATCH 50/61] pci hotadd, acpi_piix4: remove global variables., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 27/61] pci: clean up of pci_update_mappings(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 06/61] pc: fix file stream leak in multiboot loader., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 20/61] pci: fix PCI_DPRINTF() wrt variadic macro., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 19/61] pc_piix: initialize ioapic before use., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 31/61] pci: pcie host and mmcfg support., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 02/61] acpi: split out apm register emulation from acpi.c, Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 26/61] pci: 64bit bar support., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 04/61] acpi: split acpi.c into the common part and the piix4 part., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 28/61] pci: factor out while(bus) bus->next loop logic into pci_find_bus_from().,
Isaku Yamahata <=
- [Qemu-devel] [PATCH 21/61] pci: introduce constant PCI_NUM_PINS for the number of interrupt pins, 4., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 17/61] pc: split out pci device init from pc_init1() into pc_pci_device_init(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 15/61] pc: split out vga initialization from pc_init1() into pc_vga_init()., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 09/61] pc: remove a global variable, floppy_controller., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 59/61] ioapic: make irr accept more than 32 pins., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 16/61] pc: split out basic device init from pc_init1() into pc_basic_device_init(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 14/61] pc: split out memory allocation from pc_init1() into pc_memory_init(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 56/61] ioapic: clean up of #ifdef DEBUG_IOAPIC., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 03/61] acpi: add acpi constants from linux header files and use them., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 49/61] pci hot add: pass opaque argument to callback., Isaku Yamahata, 2009/09/30