qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 05/17] s390x/pci: refactor s390_pci_find_dev_by_fh


From: Cornelia Huck
Subject: [Qemu-devel] [PATCH 05/17] s390x/pci: refactor s390_pci_find_dev_by_fh
Date: Fri, 24 Jun 2016 15:28:54 +0200

From: Yi Min Zhao <address@hidden>

Because this function is called very frequently, we should use a more
effective way to find the zpci device. So we use the FH's index to get
the device directly.

Signed-off-by: Yi Min Zhao <address@hidden>
Reviewed-by: Pierre Morel <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
 hw/s390x/s390-pci-bus.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 7111587..1b83772 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -198,19 +198,12 @@ S390PCIBusDevice *s390_pci_find_dev_by_idx(uint32_t idx)
 
 S390PCIBusDevice *s390_pci_find_dev_by_fh(uint32_t fh)
 {
-    S390PCIBusDevice *pbdev;
-    int i;
     S390pciState *s = s390_get_phb();
+    S390PCIBusDevice *pbdev;
 
-    if (!fh) {
-        return NULL;
-    }
-
-    for (i = 0; i < PCI_SLOT_MAX; i++) {
-        pbdev = &s->pbdev[i];
-        if (pbdev->fh == fh) {
-            return pbdev;
-        }
+    pbdev = &s->pbdev[fh & FH_MASK_INDEX];
+    if (pbdev->fh != 0 && pbdev->fh == fh) {
+        return pbdev;
     }
 
     return NULL;
-- 
2.9.0




reply via email to

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