s390x/pci: refactor list_pci

Because of the refactor of s390_pci_find_dev_by_idx(), list_pci()
should be updated. We introduce a new function to get the next
available zpci device. It simplifies the code of looking up zpci
devices.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Acked-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
This commit is contained in:
Yi Min Zhao 2016-06-03 15:16:01 +08:00 committed by Cornelia Huck
parent ab9746570a
commit 4e3bfc167d
3 changed files with 44 additions and 25 deletions

View file

@ -91,6 +91,26 @@ int chsc_sei_nt2_have_event(void)
return !QTAILQ_EMPTY(&s->pending_sei);
}
S390PCIBusDevice *s390_pci_find_next_avail_dev(S390PCIBusDevice *pbdev)
{
int idx = 0;
S390PCIBusDevice *dev = NULL;
S390pciState *s = s390_get_phb();
if (pbdev) {
idx = (pbdev->fh & FH_MASK_INDEX) + 1;
}
for (; idx < PCI_SLOT_MAX; idx++) {
dev = s->pbdev[idx];
if (dev && dev->state != ZPCI_FS_RESERVED) {
return dev;
}
}
return NULL;
}
S390PCIBusDevice *s390_pci_find_dev_by_fid(uint32_t fid)
{
S390PCIBusDevice *pbdev;