From: Ian Jackson Date: Mon, 23 Mar 2009 16:28:07 +0000 (+0000) Subject: Use test_pci_slot() to test if a php slot is valid, in use or free X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=86a2a2a59a8b76117b221c712ba0a156d21441c9;p=xenclient%2Fioemu.git Use test_pci_slot() to test if a php slot is valid, in use or free Signed-off-by: Simon Horman --- diff --git a/hw/pass-through.c b/hw/pass-through.c index ed69265d..351ccf66 100644 --- a/hw/pass-through.c +++ b/hw/pass-through.c @@ -836,7 +836,7 @@ static int __insert_to_pci_slot(int bus, int dev, int func, int slot, if ( slot >= PHP_SLOT_START && slot < PHP_SLOT_END ) { php_slot = PCI_TO_PHP_SLOT(slot); - if ( !dpci_infos.php_devs[php_slot].valid ) + if ( !test_pci_slot(slot) ) { goto found; } @@ -850,7 +850,7 @@ static int __insert_to_pci_slot(int bus, int dev, int func, int slot, /* slot == 0, pick up a free one */ for ( i = 0; i < PHP_SLOT_LEN; i++ ) { - if ( !dpci_infos.php_devs[i].valid ) + if ( !test_pci_slot(PHP_TO_PCI_SLOT(i)) ) { php_slot = i; goto found; @@ -3800,13 +3800,13 @@ int unregister_real_device(int php_slot) uint32_t bdf = 0; int rc = -1; - if ( php_slot < 0 || php_slot >= PHP_SLOT_LEN ) + if ( test_pci_slot(PHP_TO_PCI_SLOT(php_slot)) != 1 ) return -1; php_dev = &dpci_infos.php_devs[php_slot]; assigned_device = php_dev->pt_dev; - if ( !assigned_device || !php_dev->valid ) + if ( !assigned_device ) return -1; pci_dev = assigned_device->pci_dev; diff --git a/hw/piix4acpi.c b/hw/piix4acpi.c index 3f986bdb..287ba965 100644 --- a/hw/piix4acpi.c +++ b/hw/piix4acpi.c @@ -454,7 +454,7 @@ void acpi_php_del(int pci_slot) GPEState *s = &gpe_state; int php_slot = PCI_TO_PHP_SLOT(pci_slot); - if ( pci_slot < PHP_SLOT_START || pci_slot >= PHP_SLOT_END ) { + if ( test_pci_slot(pci_slot) < 0 ) { fprintf(logfile, "not find the pci slot %d when hot remove.\n", pci_slot); return;