Do not look for pci capabilites in devices that do not support them.
Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
{
u8 pos = PCI_CFG_CAP_PTR - 1;
+ if (!(pci_read_config(bdf, PCI_CFG_STATUS, 2) & PCI_STS_CAPS))
+ return -1;
+
while (1) {
pos = pci_read_config(bdf, pos + 1, 1);
if (pos == 0)
# define PCI_CMD_INTX_OFF (1 << 10)
#define PCI_CFG_STATUS 0x006
# define PCI_STS_INT (1 << 3)
+# define PCI_STS_CAPS (1 << 4)
#define PCI_CFG_BAR 0x010
# define PCI_BAR_64BIT 0x4
#define PCI_CFG_CAP_PTR 0x034