Fix pci_dev scope

If pci_dev is defined inside the if clause it can not be used elsewhere
what is causing script to crash.