Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI/hotplug: Use PCI Express Capability accessors

Use PCI Express Capability access functions to simplify pcihp_slot.c.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>

authored by

Jiang Liu and committed by
Bjorn Helgaas
028fbad4 76b57c67

+5 -15
+5 -15
drivers/pci/hotplug/pcihp_slot.c
··· 96 96 static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) 97 97 { 98 98 int pos; 99 - u16 reg16; 100 99 u32 reg32; 101 100 102 101 if (!hpp) 103 - return; 104 - 105 - /* Find PCI Express capability */ 106 - pos = pci_pcie_cap(dev); 107 - if (!pos) 108 102 return; 109 103 110 104 if (hpp->revision > 1) { ··· 108 114 } 109 115 110 116 /* Initialize Device Control Register */ 111 - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &reg16); 112 - reg16 = (reg16 & hpp->pci_exp_devctl_and) | hpp->pci_exp_devctl_or; 113 - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, reg16); 117 + pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, 118 + ~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or); 114 119 115 120 /* Initialize Link Control Register */ 116 - if (dev->subordinate) { 117 - pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &reg16); 118 - reg16 = (reg16 & hpp->pci_exp_lnkctl_and) 119 - | hpp->pci_exp_lnkctl_or; 120 - pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, reg16); 121 - } 121 + if (dev->subordinate) 122 + pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL, 123 + ~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or); 122 124 123 125 /* Find Advanced Error Reporting Enhanced Capability */ 124 126 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);