From: Marcelo Tosatti <mtosatti@redhat.com>
To: qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [patch 1/2] qemu: move pci devfn "first free" assignment to separate function
Date: Mon, 13 Apr 2009 00:53:12 -0300 [thread overview]
Message-ID: <20090413035340.221112109@amt.cnet> (raw)
In-Reply-To: 20090413035311.009617911@amt.cnet
[-- Attachment #1: pci-assign-dev-addr --]
[-- Type: text/plain, Size: 1550 bytes --]
Move pci device address assignment to a separate function.
Index: trunk/hw/pci.c
===================================================================
--- trunk.orig/hw/pci.c
+++ trunk/hw/pci.c
@@ -121,6 +121,16 @@ int pci_bus_num(PCIBus *s)
return s->bus_num;
}
+int pci_bus_assign_dev_addr(PCIBus *bus)
+{
+ int devfn;
+
+ for(devfn = bus->devfn_min ; devfn < 256; devfn += 8)
+ if (!bus->devices[devfn])
+ return devfn;
+ return -1;
+}
+
void pci_device_save(PCIDevice *s, QEMUFile *f)
{
int i;
@@ -246,14 +256,6 @@ PCIDevice *pci_register_device(PCIBus *b
if (pci_irq_index >= PCI_DEVICES_MAX)
return NULL;
- if (devfn < 0) {
- for(devfn = bus->devfn_min ; devfn < 256; devfn += 8) {
- if (!bus->devices[devfn])
- goto found;
- }
- return NULL;
- found: ;
- }
pci_dev = qemu_mallocz(instance_size);
pci_dev->bus = bus;
pci_dev->devfn = devfn;
Index: trunk/hw/pci.h
===================================================================
--- trunk.orig/hw/pci.h
+++ trunk/hw/pci.h
@@ -184,6 +184,7 @@ PCIDevice *pci_nic_init(PCIBus *bus, NIC
void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);
uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
int pci_bus_num(PCIBus *s);
+int pci_bus_assign_dev_addr(PCIBus *bus);
void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d));
PCIBus *pci_find_bus(int bus_num);
PCIDevice *pci_find_device(int bus_num, int slot, int function);
next prev parent reply other threads:[~2009-04-13 3:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-13 3:53 [Qemu-devel] [patch 0/2] RFC: move PCI device enumeration out of pci drivers Marcelo Tosatti
2009-04-13 3:53 ` Marcelo Tosatti [this message]
2009-04-13 8:08 ` [Qemu-devel] [patch 1/2] qemu: move pci devfn "first free" assignment to separate function Avi Kivity
2009-04-13 3:53 ` [Qemu-devel] [patch 2/2] qemu: switch pci device init functions to accept devfn Marcelo Tosatti
2009-04-13 12:27 ` Paul Brook
2009-04-13 13:30 ` Marcelo Tosatti
2009-04-13 13:47 ` Brian Wheeler
2009-04-13 14:34 ` Marcelo Tosatti
2009-04-14 3:29 ` Marcelo Tosatti
2009-04-14 8:17 ` Marcelo Tosatti
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=20090413035340.221112109@amt.cnet \
--to=mtosatti@redhat.com \
--cc=armbru@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).