[Skiboot] [PATCH 5/8] core/pci: No validation on pd and ecap in pcie_slot_create()
Gavin Shan
gwshan at linux.vnet.ibm.com
Wed Jan 11 11:31:15 AEDT 2017
The PCI device and its PCIe capability offset should be valid in
pcie_slot_create(). No need to validate them. This removes the
validation logic to make the function simpler. No functional changes
introduced.
Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
core/pcie-slot.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/core/pcie-slot.c b/core/pcie-slot.c
index de2d5a5..72068ba 100644
--- a/core/pcie-slot.c
+++ b/core/pcie-slot.c
@@ -449,15 +449,13 @@ struct pci_slot *pcie_slot_create(struct phb *phb, struct pci_device *pd)
return NULL;
/* Cache the link and slot capabilities */
- if (pd) {
- ecap = pci_cap(pd, PCI_CFG_CAP_ID_EXP, false);
- pci_cfg_read16(phb, pd->bdfn, ecap + PCICAP_EXP_CAPABILITY_REG,
- &slot->pcie_cap);
- pci_cfg_read32(phb, pd->bdfn, ecap + PCICAP_EXP_LCAP,
- &slot->link_cap);
- pci_cfg_read32(phb, pd->bdfn, ecap + PCICAP_EXP_SLOTCAP,
- &slot->slot_cap);
- }
+ ecap = pci_cap(pd, PCI_CFG_CAP_ID_EXP, false);
+ pci_cfg_read16(phb, pd->bdfn, ecap + PCICAP_EXP_CAPABILITY_REG,
+ &slot->pcie_cap);
+ pci_cfg_read32(phb, pd->bdfn, ecap + PCICAP_EXP_LCAP,
+ &slot->link_cap);
+ pci_cfg_read32(phb, pd->bdfn, ecap + PCICAP_EXP_SLOTCAP,
+ &slot->slot_cap);
if (slot->slot_cap & PCICAP_EXP_SLOTCAP_HPLUG_CAP)
slot->pluggable = 1;
@@ -467,12 +465,10 @@ struct pci_slot *pcie_slot_create(struct phb *phb, struct pci_device *pd)
/* The power is on by default */
slot->power_state = PCI_SLOT_POWER_ON;
- if (pd && ecap) {
- pci_cfg_read16(phb, pd->bdfn,
- ecap + PCICAP_EXP_SLOTCTL, &slot_ctl);
- if (((slot_ctl & PCICAP_EXP_SLOTCTL_PWRI) >> 8) == PCIE_INDIC_OFF)
- slot->power_state = PCI_SLOT_POWER_OFF;
- }
+ pci_cfg_read16(phb, pd->bdfn, ecap + PCICAP_EXP_SLOTCTL,
+ &slot_ctl);
+ if (((slot_ctl & PCICAP_EXP_SLOTCTL_PWRI) >> 8) == PCIE_INDIC_OFF)
+ slot->power_state = PCI_SLOT_POWER_OFF;
}
if (slot->slot_cap & PCICAP_EXP_SLOTCAP_PWRI)
--
2.7.4
More information about the Skiboot
mailing list