PCI: dwc: Fix dw_pcie_ep_find_capability() to return correct capability offset
authorKishon Vijay Abraham I <kishon@ti.com>
Mon, 25 Mar 2019 09:39:41 +0000 (15:09 +0530)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tue, 16 Apr 2019 14:10:36 +0000 (15:10 +0100)
commit421db1ab287eebe80fd203eb009ae92836c586ad
tree82bf0706c37243585ca6cbac3bd61d2f89277c4c
parent626961dd6d32edcdbea1ebc488305533960b5d08
PCI: dwc: Fix dw_pcie_ep_find_capability() to return correct capability offset

commit beb4641a787d ("PCI: dwc: Add MSI-X callbacks handler") while
adding MSI-X callback handler, introduced dw_pcie_ep_find_capability()
and __dw_pcie_ep_find_next_cap() for finding the MSI and MSIX capability.

However if MSI or MSIX capability is the last capability (i.e there are
no additional items in the capabilities list and the Next Capability
Pointer is set to '0'), __dw_pcie_ep_find_next_cap will return '0'
even though MSI or MSIX capability may be present because of
incorrect ordering of the "next_cap_ptr" check. Fix it.

Fixes: beb4641a787d ("PCI: dwc: Add MSI-X callbacks handler")
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
drivers/pci/controller/dwc/pcie-designware-ep.c