PCI/pciehp: Use PCI Express Capability accessors
Use PCI Express Capability access functions to simplify pciehp. Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Yijing Wang <wangyijing@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
This commit is contained in:
@@ -81,16 +81,12 @@ static struct list_head __initdata dummy_slots = LIST_HEAD_INIT(dummy_slots);
|
|||||||
/* Dummy driver for dumplicate name detection */
|
/* Dummy driver for dumplicate name detection */
|
||||||
static int __init dummy_probe(struct pcie_device *dev)
|
static int __init dummy_probe(struct pcie_device *dev)
|
||||||
{
|
{
|
||||||
int pos;
|
|
||||||
u32 slot_cap;
|
u32 slot_cap;
|
||||||
acpi_handle handle;
|
acpi_handle handle;
|
||||||
struct dummy_slot *slot, *tmp;
|
struct dummy_slot *slot, *tmp;
|
||||||
struct pci_dev *pdev = dev->port;
|
struct pci_dev *pdev = dev->port;
|
||||||
|
|
||||||
pos = pci_pcie_cap(pdev);
|
pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, &slot_cap);
|
||||||
if (!pos)
|
|
||||||
return -ENODEV;
|
|
||||||
pci_read_config_dword(pdev, pos + PCI_EXP_SLTCAP, &slot_cap);
|
|
||||||
slot = kzalloc(sizeof(*slot), GFP_KERNEL);
|
slot = kzalloc(sizeof(*slot), GFP_KERNEL);
|
||||||
if (!slot)
|
if (!slot)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@@ -44,25 +44,25 @@
|
|||||||
static inline int pciehp_readw(struct controller *ctrl, int reg, u16 *value)
|
static inline int pciehp_readw(struct controller *ctrl, int reg, u16 *value)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev = ctrl->pcie->port;
|
struct pci_dev *dev = ctrl->pcie->port;
|
||||||
return pci_read_config_word(dev, pci_pcie_cap(dev) + reg, value);
|
return pcie_capability_read_word(dev, reg, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pciehp_readl(struct controller *ctrl, int reg, u32 *value)
|
static inline int pciehp_readl(struct controller *ctrl, int reg, u32 *value)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev = ctrl->pcie->port;
|
struct pci_dev *dev = ctrl->pcie->port;
|
||||||
return pci_read_config_dword(dev, pci_pcie_cap(dev) + reg, value);
|
return pcie_capability_read_dword(dev, reg, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pciehp_writew(struct controller *ctrl, int reg, u16 value)
|
static inline int pciehp_writew(struct controller *ctrl, int reg, u16 value)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev = ctrl->pcie->port;
|
struct pci_dev *dev = ctrl->pcie->port;
|
||||||
return pci_write_config_word(dev, pci_pcie_cap(dev) + reg, value);
|
return pcie_capability_write_word(dev, reg, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pciehp_writel(struct controller *ctrl, int reg, u32 value)
|
static inline int pciehp_writel(struct controller *ctrl, int reg, u32 value)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev = ctrl->pcie->port;
|
struct pci_dev *dev = ctrl->pcie->port;
|
||||||
return pci_write_config_dword(dev, pci_pcie_cap(dev) + reg, value);
|
return pcie_capability_write_dword(dev, reg, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Power Control Command */
|
/* Power Control Command */
|
||||||
@@ -855,10 +855,6 @@ struct controller *pcie_init(struct pcie_device *dev)
|
|||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
ctrl->pcie = dev;
|
ctrl->pcie = dev;
|
||||||
if (!pci_pcie_cap(pdev)) {
|
|
||||||
ctrl_err(ctrl, "Cannot find PCI Express capability\n");
|
|
||||||
goto abort_ctrl;
|
|
||||||
}
|
|
||||||
if (pciehp_readl(ctrl, PCI_EXP_SLTCAP, &slot_cap)) {
|
if (pciehp_readl(ctrl, PCI_EXP_SLTCAP, &slot_cap)) {
|
||||||
ctrl_err(ctrl, "Cannot read SLOTCAP register\n");
|
ctrl_err(ctrl, "Cannot read SLOTCAP register\n");
|
||||||
goto abort_ctrl;
|
goto abort_ctrl;
|
||||||
|
Reference in New Issue
Block a user