diff options
author | Jiang Liu <jiang.liu@huawei.com> | 2012-07-24 05:20:08 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-08-23 12:11:11 -0400 |
commit | 2dcfaf85cd0ced6dcfd4bf0012354b3fd2ed1f38 (patch) | |
tree | 5a15e98507a8ff7452378f02f74f666f1d9b23ce | |
parent | 028fbad480edfc73157408f894a29385afc9689e (diff) |
PCI/portdrv: Use PCI Express Capability accessors
Use PCI Express Capability access functions to simplify portdrv.
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>
-rw-r--r-- | drivers/pci/pcie/portdrv_core.c | 15 | ||||
-rw-r--r-- | drivers/pci/pcie/portdrv_pci.c | 9 |
2 files changed, 6 insertions, 18 deletions
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index bf320a9419f4..aede99171e90 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c | |||
@@ -246,8 +246,7 @@ static void cleanup_service_irqs(struct pci_dev *dev) | |||
246 | */ | 246 | */ |
247 | static int get_port_device_capability(struct pci_dev *dev) | 247 | static int get_port_device_capability(struct pci_dev *dev) |
248 | { | 248 | { |
249 | int services = 0, pos; | 249 | int services = 0; |
250 | u16 reg16; | ||
251 | u32 reg32; | 250 | u32 reg32; |
252 | int cap_mask = 0; | 251 | int cap_mask = 0; |
253 | int err; | 252 | int err; |
@@ -265,11 +264,9 @@ static int get_port_device_capability(struct pci_dev *dev) | |||
265 | return 0; | 264 | return 0; |
266 | } | 265 | } |
267 | 266 | ||
268 | pos = pci_pcie_cap(dev); | ||
269 | pci_read_config_word(dev, pos + PCI_EXP_FLAGS, ®16); | ||
270 | /* Hot-Plug Capable */ | 267 | /* Hot-Plug Capable */ |
271 | if ((cap_mask & PCIE_PORT_SERVICE_HP) && (reg16 & PCI_EXP_FLAGS_SLOT)) { | 268 | if (cap_mask & PCIE_PORT_SERVICE_HP) { |
272 | pci_read_config_dword(dev, pos + PCI_EXP_SLTCAP, ®32); | 269 | pcie_capability_read_dword(dev, PCI_EXP_SLTCAP, ®32); |
273 | if (reg32 & PCI_EXP_SLTCAP_HPC) { | 270 | if (reg32 & PCI_EXP_SLTCAP_HPC) { |
274 | services |= PCIE_PORT_SERVICE_HP; | 271 | services |= PCIE_PORT_SERVICE_HP; |
275 | /* | 272 | /* |
@@ -277,10 +274,8 @@ static int get_port_device_capability(struct pci_dev *dev) | |||
277 | * enabled by the BIOS and the hot-plug service driver | 274 | * enabled by the BIOS and the hot-plug service driver |
278 | * is not loaded. | 275 | * is not loaded. |
279 | */ | 276 | */ |
280 | pos += PCI_EXP_SLTCTL; | 277 | pcie_capability_clear_word(dev, PCI_EXP_SLTCTL, |
281 | pci_read_config_word(dev, pos, ®16); | 278 | PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE); |
282 | reg16 &= ~(PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE); | ||
283 | pci_write_config_word(dev, pos, reg16); | ||
284 | } | 279 | } |
285 | } | 280 | } |
286 | /* AER capable */ | 281 | /* AER capable */ |
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 24d1463e688b..2360330e48f1 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c | |||
@@ -64,14 +64,7 @@ __setup("pcie_ports=", pcie_port_setup); | |||
64 | */ | 64 | */ |
65 | void pcie_clear_root_pme_status(struct pci_dev *dev) | 65 | void pcie_clear_root_pme_status(struct pci_dev *dev) |
66 | { | 66 | { |
67 | int rtsta_pos; | 67 | pcie_capability_set_dword(dev, PCI_EXP_RTSTA, PCI_EXP_RTSTA_PME); |
68 | u32 rtsta; | ||
69 | |||
70 | rtsta_pos = pci_pcie_cap(dev) + PCI_EXP_RTSTA; | ||
71 | |||
72 | pci_read_config_dword(dev, rtsta_pos, &rtsta); | ||
73 | rtsta |= PCI_EXP_RTSTA_PME; | ||
74 | pci_write_config_dword(dev, rtsta_pos, rtsta); | ||
75 | } | 68 | } |
76 | 69 | ||
77 | static int pcie_portdrv_restore_config(struct pci_dev *dev) | 70 | static int pcie_portdrv_restore_config(struct pci_dev *dev) |