[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 05/14] pci: Fold pci_get_bus_devfn() into its sole
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 05/14] pci: Fold pci_get_bus_devfn() into its sole caller |
Date: |
Mon, 3 Jun 2019 14:08:42 -0400 |
From: David Gibson <address@hidden>
The only remaining caller of pci_get_bus_devfn() is pci_nic_init_nofail(),
itself an old compatibility function. Fold the two together to avoid
re-using the stale interface.
While we're there replace the explicit fprintf()s with error_report().
Signed-off-by: David Gibson <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Greg Kurz <address@hidden>
---
hw/pci/pci.c | 60 ++++++++++++++++++++++++----------------------------
1 file changed, 28 insertions(+), 32 deletions(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 7e5f8d001b..d3893bdfe1 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -723,37 +723,6 @@ static int pci_parse_devaddr(const char *addr, int *domp,
int *busp,
return 0;
}
-static PCIBus *pci_get_bus_devfn(int *devfnp, PCIBus *root,
- const char *devaddr)
-{
- int dom, bus;
- unsigned slot;
-
- if (!root) {
- fprintf(stderr, "No primary PCI bus\n");
- return NULL;
- }
-
- assert(!root->parent_dev);
-
- if (!devaddr) {
- *devfnp = -1;
- return pci_find_bus_nr(root, 0);
- }
-
- if (pci_parse_devaddr(devaddr, &dom, &bus, &slot, NULL) < 0) {
- return NULL;
- }
-
- if (dom != 0) {
- fprintf(stderr, "No support for non-zero PCI domains\n");
- return NULL;
- }
-
- *devfnp = PCI_DEVFN(slot, 0);
- return pci_find_bus_nr(root, bus);
-}
-
static void pci_init_cmask(PCIDevice *dev)
{
pci_set_word(dev->cmask + PCI_VENDOR_ID, 0xffff);
@@ -1895,6 +1864,8 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus
*rootbus,
DeviceState *dev;
int devfn;
int i;
+ int dom, busnr;
+ unsigned slot;
if (nd->model && !strcmp(nd->model, "virtio")) {
g_free(nd->model);
@@ -1928,7 +1899,32 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus
*rootbus,
exit(1);
}
- bus = pci_get_bus_devfn(&devfn, rootbus, devaddr);
+ if (!rootbus) {
+ error_report("No primary PCI bus");
+ exit(1);
+ }
+
+ assert(!rootbus->parent_dev);
+
+ if (!devaddr) {
+ devfn = -1;
+ busnr = 0;
+ } else {
+ if (pci_parse_devaddr(devaddr, &dom, &busnr, &slot, NULL) < 0) {
+ error_report("Invalid PCI device address %s for device %s",
+ devaddr, nd->model);
+ exit(1);
+ }
+
+ if (dom != 0) {
+ error_report("No support for non-zero PCI domains");
+ exit(1);
+ }
+
+ devfn = PCI_DEVFN(slot, 0);
+ }
+
+ bus = pci_find_bus_nr(rootbus, busnr);
if (!bus) {
error_report("Invalid PCI device address %s for device %s",
devaddr, nd->model);
--
MST
- [Qemu-devel] [PULL v2 00/14] virtio, pci, pc: cleanups, features, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 01/14] hw/acpi: Consolidate build_mcfg to pci.c, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 02/14] acpi: pci: use build_append_foo() API to construct MCFG, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 03/14] pcie: Simplify pci_adjust_config_limit(), Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 04/14] pci: Make is_bridge a bool, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 05/14] pci: Fold pci_get_bus_devfn() into its sole caller,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 08/14] vhost: fix incorrect print type, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 09/14] vhost: fix memory leak in vhost_user_scsi_realize, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 07/14] vhost: remove the dead code, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 06/14] docs: smbios: remove family=x from type2 entry description, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 10/14] bios-tables-test: add diff allowed list, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 11/14] vhost-scsi: The vhost backend should be stopped when the VM is not running, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 12/14] vhost-scsi: Add VMState descriptor, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 13/14] vhost-scsi: Allow user to enable migration, Michael S. Tsirkin, 2019/06/03
- [Qemu-devel] [PULL v2 14/14] bios-tables-test: list all tables that differ, Michael S. Tsirkin, 2019/06/03