qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 13/17] s390x/pci: refactor s390_pci_find_dev_by_idx


From: Cornelia Huck
Subject: [Qemu-devel] [PATCH 13/17] s390x/pci: refactor s390_pci_find_dev_by_idx
Date: Fri, 24 Jun 2016 15:29:02 +0200

From: Yi Min Zhao <address@hidden>

s390_find_dev_by_idx() only indexes usable zpci devices. It implies
that the index value of each zpci device is dynamic and may change if
a new zpci device is plugged. So we have to use a constant index to
look up the device.

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 | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 57d5d14..9e24268 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -223,28 +223,9 @@ static S390PCIBusDevice *s390_pci_find_dev_by_target(const 
char *target)
 
 S390PCIBusDevice *s390_pci_find_dev_by_idx(uint32_t idx)
 {
-    S390PCIBusDevice *pbdev;
-    int i;
-    int j = 0;
     S390pciState *s = s390_get_phb();
 
-    for (i = 0; i < PCI_SLOT_MAX; i++) {
-        pbdev = s->pbdev[i];
-        if (!pbdev) {
-            continue;
-        }
-
-        if (pbdev->state == ZPCI_FS_RESERVED) {
-            continue;
-        }
-
-        if (j == idx) {
-            return pbdev;
-        }
-        j++;
-    }
-
-    return NULL;
+    return s->pbdev[idx & FH_MASK_INDEX];
 }
 
 S390PCIBusDevice *s390_pci_find_dev_by_fh(uint32_t fh)
-- 
2.9.0




reply via email to

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