Commit 5256d8bf authored by Isaku Yamahata's avatar Isaku Yamahata Committed by Michael S. Tsirkin
Browse files

pci: use devfn for pci_find_device() instead of (slot, fn) pair

(slot, fn) pair is somewhat confusing because of ARI.
So use devfn for pci_find_device() instead of (slot, fn).

Signed-off-by: default avatarIsaku Yamahata <>
Signed-off-by: default avatarMichael S. Tsirkin <>
parent 90a20dbb
......@@ -127,7 +127,8 @@ void drive_hot_add(Monitor *mon, const QDict *qdict)
if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
goto err;
dev = pci_find_device(pci_find_root_bus(dom), pci_bus, slot, 0);
dev = pci_find_device(pci_find_root_bus(dom), pci_bus,
PCI_DEVFN(slot, 0));
if (!dev) {
monitor_printf(mon, "no pci device with address %s\n", pci_addr);
goto err;
......@@ -277,7 +278,7 @@ static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
return -1;
d = pci_find_device(pci_find_root_bus(dom), bus, slot, 0);
d = pci_find_device(pci_find_root_bus(dom), bus, PCI_DEVFN(slot, 0));
if (!d) {
monitor_printf(mon, "slot %d empty\n", slot);
return -1;
......@@ -1603,14 +1603,14 @@ PCIBus *pci_find_bus(PCIBus *bus, int bus_num)
return NULL;
PCIDevice *pci_find_device(PCIBus *bus, int bus_num, int slot, int function)
PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn)
bus = pci_find_bus(bus, bus_num);
if (!bus)
return NULL;
return bus->devices[PCI_DEVFN(slot, function)];
return bus->devices[devfn];
static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
......@@ -252,7 +252,7 @@ void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDe
PCIBus *pci_find_root_bus(int domain);
int pci_find_domain(const PCIBus *bus);
PCIBus *pci_find_bus(PCIBus *bus, int bus_num);
PCIDevice *pci_find_device(PCIBus *bus, int bus_num, int slot, int function);
PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
int pci_qdev_find_device(const char *id, PCIDevice **pdev);
PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
......@@ -44,7 +44,7 @@ static inline PCIDevice *pci_dev_find_by_addr(PCIBus *bus, uint32_t addr)
uint8_t bus_num = addr >> 16;
uint8_t devfn = addr >> 8;
return pci_find_device(bus, bus_num, PCI_SLOT(devfn), PCI_FUNC(devfn));
return pci_find_device(bus, bus_num, devfn);
void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len)
......@@ -49,8 +49,7 @@ static inline PCIDevice *pcie_dev_find_by_mmcfg_addr(PCIBus *s,
uint32_t mmcfg_addr)
return pci_find_device(s, PCIE_MMCFG_BUS(mmcfg_addr),
static void pcie_mmcfg_data_write(PCIBus *s,
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment