]> xenbits.xen.org Git - xenclient/ioemu.git/commitdiff
Use test_pci_slot() to test if a php slot is valid, in use or free
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 23 Mar 2009 16:28:07 +0000 (16:28 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 23 Mar 2009 16:28:07 +0000 (16:28 +0000)
Signed-off-by: Simon Horman <horms@verge.net.au>
hw/pass-through.c
hw/piix4acpi.c

index ed69265d44f029355c9ff8ce2f64e86f4cde38e9..351ccf6611fcf8ec74b35817ed9d641444ab1b35 100644 (file)
@@ -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;
index 3f986bdb688060c248ac442cb269047bec01d2c9..287ba965eaba6d396358cf82f6b67e2a416e7a00 100644 (file)
@@ -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;