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>
This commit is contained in:
parent
bd4976838d
commit
ab9746570a
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user