qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 08/13] pci: Export pci_parse_devaddr instead of pci_


From: Jan Kiszka
Subject: [Qemu-devel] [PATCH 08/13] pci: Export pci_parse_devaddr instead of pci_read_devaddr
Date: Mon, 4 Jun 2012 10:52:16 +0200

The latter is an internal helper for PCI hotplug. So move it where it
belongs - before someone misuses it - and export the more versatile
pci_parse_devaddr instead.

Signed-off-by: Jan Kiszka <address@hidden>
---
 hw/pci-hotplug.c |   18 ++++++++++++++++--
 hw/pci.c         |   19 ++-----------------
 hw/pci.h         |    4 ++--
 3 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index e0ea8bb..e1654dc 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -34,6 +34,20 @@
 #include "blockdev.h"
 #include "error.h"
 
+static int read_pci_devaddr(Monitor *mon, const char *addr, unsigned int *domp,
+                            unsigned int *busp, unsigned *slotp)
+{
+    /* strip legacy tag */
+    if (!strncmp(addr, "pci_addr=", 9)) {
+        addr += 9;
+    }
+    if (pci_parse_devaddr(addr, domp, busp, slotp, NULL)) {
+        monitor_printf(mon, "Invalid pci address\n");
+        return -1;
+    }
+    return 0;
+}
+
 #if defined(TARGET_I386)
 static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
                                        const char *devaddr,
@@ -115,7 +129,7 @@ int pci_drive_hot_add(Monitor *mon, const QDict *qdict,
 
     switch (type) {
     case IF_SCSI:
-        if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
+        if (read_pci_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
             goto err;
         }
         dev = pci_find_device(pci_find_root_bus(dom), pci_bus,
@@ -261,7 +275,7 @@ static int pci_device_hot_remove(Monitor *mon, const char 
*pci_addr)
     unsigned slot;
     Error *local_err = NULL;
 
-    if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
+    if (read_pci_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
         return -1;
     }
 
diff --git a/hw/pci.c b/hw/pci.c
index d4c8b71..6471a68 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -512,9 +512,8 @@ static void pci_set_default_subsystem_id(PCIDevice *pci_dev)
  * Parse [[<domain>:]<bus>:]<slot>, return -1 on error if funcp == NULL
  *       [[<domain>:]<bus>:]<slot>.<func>, return -1 on error
  */
-static int pci_parse_devaddr(const char *addr, unsigned int *domp,
-                             unsigned int *busp, unsigned int *slotp,
-                             unsigned int *funcp)
+int pci_parse_devaddr(const char *addr, unsigned int *domp, unsigned int *busp,
+                      unsigned int *slotp, unsigned int *funcp)
 {
     const char *p;
     char *e;
@@ -572,20 +571,6 @@ static int pci_parse_devaddr(const char *addr, unsigned 
int *domp,
     return 0;
 }
 
-int pci_read_devaddr(Monitor *mon, const char *addr, unsigned int *domp,
-                     unsigned int *busp, unsigned *slotp)
-{
-    /* strip legacy tag */
-    if (!strncmp(addr, "pci_addr=", 9)) {
-        addr += 9;
-    }
-    if (pci_parse_devaddr(addr, domp, busp, slotp, NULL)) {
-        monitor_printf(mon, "Invalid pci address\n");
-        return -1;
-    }
-    return 0;
-}
-
 PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
 {
     unsigned int dom, bus;
diff --git a/hw/pci.h b/hw/pci.h
index 0c38c36..552a586 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -340,8 +340,8 @@ 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);
 
-int pci_read_devaddr(Monitor *mon, const char *addr, unsigned int *domp,
-                     unsigned int *busp, unsigned *slotp);
+int pci_parse_devaddr(const char *addr, unsigned int *domp, unsigned int *busp,
+                      unsigned int *slotp, unsigned int *funcp);
 
 void pci_device_deassert_intx(PCIDevice *dev);
 
-- 
1.7.3.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]