/* Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express devices have 4096 bytes. Even if the device is capable, that doesn't mean we can access it. Maybe we don't have a way to generate extended config space accesses, or the device is behind a reverse Express bridge. So we try reading the dword at 0x100 which must either be 0 or a valid extended capability header.  */
int pci_cfg_space_size_ext(struct pci_dev *dev)
/* Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express devices have 4096 bytes. Even if the device is capable, that doesn't mean we can access it. Maybe we don't have a way to generate extended config space accesses, or the device is behind a reverse Express bridge. So we try reading the dword at 0x100 which must either be 0 or a valid extended capability header.  */
int pci_cfg_space_size_ext(struct pci_dev *dev)
{
	u32 status;
	int pos = PCI_CFG_SPACE_SIZE;
	if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL)
		goto fail;
	if (status == 0xffffffff)
		goto fail;
	return PCI_CFG_SPACE_EXP_SIZE;
 fail:
	return PCI_CFG_SPACE_SIZE;
}