aboutsummaryrefslogtreecommitdiff
path: root/hw/s390x/s390-pci-bus.c
diff options
context:
space:
mode:
authorYi Min Zhao <zyimin@linux.vnet.ibm.com>2016-06-03 14:17:59 +0800
committerCornelia Huck <cornelia.huck@de.ibm.com>2016-07-11 09:48:05 +0200
commitab9746570ab375f3f2a3d5ec0c95d2621aca5493 (patch)
tree9a00b7880819ee9a56782c47a18a8e0d537f56a3 /hw/s390x/s390-pci-bus.c
parentbd4976838d1f2b79d4db68a70ddf8d46e0f8b054 (diff)
downloadqemu-ab9746570ab375f3f2a3d5ec0c95d2621aca5493.zip
qemu-ab9746570ab375f3f2a3d5ec0c95d2621aca5493.tar.gz
qemu-ab9746570ab375f3f2a3d5ec0c95d2621aca5493.tar.bz2
s390x/pci: refactor s390_pci_find_dev_by_idx
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 <zyimin@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'hw/s390x/s390-pci-bus.c')
-rw-r--r--hw/s390x/s390-pci-bus.c21
1 files changed, 1 insertions, 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)