core/pci: No validation on pd and ecap in pcie_slot_create()
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.
@@ -449,7 +449,6 @@ 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);
@@ -457,7 +456,6 @@ struct pci_slot *pcie_slot_create(struct phb *phb, struct pci_device *pd)
&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,13 +465,11 @@ 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);
+ 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)
slot->power_led_ctl = PCI_SLOT_PWR_LED_CTL_KERNEL;
