diff options
author | Yi Min Zhao <zyimin@linux.vnet.ibm.com> | 2016-05-12 14:27:25 +0800 |
---|---|---|
committer | Cornelia Huck <cornelia.huck@de.ibm.com> | 2016-07-11 09:48:05 +0200 |
commit | 06a96dae11a70f3c519a706639e200a635a2cc55 (patch) | |
tree | 5520790bcb58454902c3907d07f0dc4291e58402 /hw | |
parent | c188e30315dc44cf428f2008df4ea2a9788ac8df (diff) | |
download | qemu-06a96dae11a70f3c519a706639e200a635a2cc55.tar.gz qemu-06a96dae11a70f3c519a706639e200a635a2cc55.tar.bz2 qemu-06a96dae11a70f3c519a706639e200a635a2cc55.zip |
s390x/pci: refactor s390_pci_find_dev_by_fh
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 <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')
-rw-r--r-- | hw/s390x/s390-pci-bus.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 7111587a77..1b8377241a 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; |