aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pcie
diff options
context:
space:
mode:
authorYijing Wang <wangyijing@huawei.com>2012-07-24 05:20:03 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-08-23 11:40:57 -0400
commit62f87c0e31d646d5501edf4f7feb07d0ad689d80 (patch)
treef2aa208c10f6cf8b91634f91efda44efc6f4c25f /drivers/pci/pcie
parent786e22885d9959fda0473ace5a61cb11620fba9b (diff)
PCI: Introduce pci_pcie_type(dev) to replace pci_dev->pcie_type
Introduce an inline function pci_pcie_type(dev) to extract PCIe device type from pci_dev->pcie_flags_reg field, and prepare for removing pci_dev->pcie_type. Signed-off-by: Yijing Wang <wangyijing@huawei.com> Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pcie')
-rw-r--r--drivers/pci/pcie/aer/aer_inject.c2
-rw-r--r--drivers/pci/pcie/aer/aerdrv.c7
-rw-r--r--drivers/pci/pcie/aer/aerdrv_acpi.c2
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c2
-rw-r--r--drivers/pci/pcie/aspm.c42
-rw-r--r--drivers/pci/pcie/pme.c6
-rw-r--r--drivers/pci/pcie/portdrv_bus.c2
-rw-r--r--drivers/pci/pcie/portdrv_core.c4
-rw-r--r--drivers/pci/pcie/portdrv_pci.c8
9 files changed, 38 insertions, 37 deletions
diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c
index 52229863e9fe..4e24cb8a94ae 100644
--- a/drivers/pci/pcie/aer/aer_inject.c
+++ b/drivers/pci/pcie/aer/aer_inject.c
@@ -288,7 +288,7 @@ static struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
288 while (1) { 288 while (1) {
289 if (!pci_is_pcie(dev)) 289 if (!pci_is_pcie(dev))
290 break; 290 break;
291 if (dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) 291 if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
292 return dev; 292 return dev;
293 if (!dev->bus->self) 293 if (!dev->bus->self)
294 break; 294 break;
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
index 58ad7917553c..f7c62453ae00 100644
--- a/drivers/pci/pcie/aer/aerdrv.c
+++ b/drivers/pci/pcie/aer/aerdrv.c
@@ -81,10 +81,11 @@ bool pci_aer_available(void)
81static int set_device_error_reporting(struct pci_dev *dev, void *data) 81static int set_device_error_reporting(struct pci_dev *dev, void *data)
82{ 82{
83 bool enable = *((bool *)data); 83 bool enable = *((bool *)data);
84 int type = pci_pcie_type(dev);
84 85
85 if ((dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) || 86 if ((type == PCI_EXP_TYPE_ROOT_PORT) ||
86 (dev->pcie_type == PCI_EXP_TYPE_UPSTREAM) || 87 (type == PCI_EXP_TYPE_UPSTREAM) ||
87 (dev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)) { 88 (type == PCI_EXP_TYPE_DOWNSTREAM)) {
88 if (enable) 89 if (enable)
89 pci_enable_pcie_error_reporting(dev); 90 pci_enable_pcie_error_reporting(dev);
90 else 91 else
diff --git a/drivers/pci/pcie/aer/aerdrv_acpi.c b/drivers/pci/pcie/aer/aerdrv_acpi.c
index 124f20ff11b2..5194a7d41730 100644
--- a/drivers/pci/pcie/aer/aerdrv_acpi.c
+++ b/drivers/pci/pcie/aer/aerdrv_acpi.c
@@ -60,7 +60,7 @@ static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data)
60 p = (struct acpi_hest_aer_common *)(hest_hdr + 1); 60 p = (struct acpi_hest_aer_common *)(hest_hdr + 1);
61 if (p->flags & ACPI_HEST_GLOBAL) { 61 if (p->flags & ACPI_HEST_GLOBAL) {
62 if ((pci_is_pcie(info->pci_dev) && 62 if ((pci_is_pcie(info->pci_dev) &&
63 info->pci_dev->pcie_type == pcie_type) || bridge) 63 pci_pcie_type(info->pci_dev) == pcie_type) || bridge)
64 ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST); 64 ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
65 } else 65 } else
66 if (hest_match_pci(p, info->pci_dev)) 66 if (hest_match_pci(p, info->pci_dev))
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index 0ca053538146..f55153489854 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -465,7 +465,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev)
465 465
466 if (driver && driver->reset_link) { 466 if (driver && driver->reset_link) {
467 status = driver->reset_link(udev); 467 status = driver->reset_link(udev);
468 } else if (udev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) { 468 } else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM) {
469 status = default_downstream_reset_link(udev); 469 status = default_downstream_reset_link(udev);
470 } else { 470 } else {
471 dev_printk(KERN_DEBUG, &dev->dev, 471 dev_printk(KERN_DEBUG, &dev->dev,
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index b500840a143b..25916034c0ae 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -412,7 +412,7 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
412 * do ASPM for now. 412 * do ASPM for now.
413 */ 413 */
414 list_for_each_entry(child, &linkbus->devices, bus_list) { 414 list_for_each_entry(child, &linkbus->devices, bus_list) {
415 if (child->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) { 415 if (pci_pcie_type(child) == PCI_EXP_TYPE_PCI_BRIDGE) {
416 link->aspm_disable = ASPM_STATE_ALL; 416 link->aspm_disable = ASPM_STATE_ALL;
417 break; 417 break;
418 } 418 }
@@ -425,8 +425,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
425 struct aspm_latency *acceptable = 425 struct aspm_latency *acceptable =
426 &link->acceptable[PCI_FUNC(child->devfn)]; 426 &link->acceptable[PCI_FUNC(child->devfn)];
427 427
428 if (child->pcie_type != PCI_EXP_TYPE_ENDPOINT && 428 if (pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT &&
429 child->pcie_type != PCI_EXP_TYPE_LEG_END) 429 pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END)
430 continue; 430 continue;
431 431
432 pos = pci_pcie_cap(child); 432 pos = pci_pcie_cap(child);
@@ -552,7 +552,7 @@ static struct pcie_link_state *alloc_pcie_link_state(struct pci_dev *pdev)
552 INIT_LIST_HEAD(&link->children); 552 INIT_LIST_HEAD(&link->children);
553 INIT_LIST_HEAD(&link->link); 553 INIT_LIST_HEAD(&link->link);
554 link->pdev = pdev; 554 link->pdev = pdev;
555 if (pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) { 555 if (pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM) {
556 struct pcie_link_state *parent; 556 struct pcie_link_state *parent;
557 parent = pdev->bus->parent->self->link_state; 557 parent = pdev->bus->parent->self->link_state;
558 if (!parent) { 558 if (!parent) {
@@ -585,12 +585,12 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)
585 585
586 if (!pci_is_pcie(pdev) || pdev->link_state) 586 if (!pci_is_pcie(pdev) || pdev->link_state)
587 return; 587 return;
588 if (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && 588 if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
589 pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) 589 pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM)
590 return; 590 return;
591 591
592 /* VIA has a strange chipset, root port is under a bridge */ 592 /* VIA has a strange chipset, root port is under a bridge */
593 if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT && 593 if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT &&
594 pdev->bus->self) 594 pdev->bus->self)
595 return; 595 return;
596 596
@@ -647,8 +647,8 @@ static void pcie_update_aspm_capable(struct pcie_link_state *root)
647 if (link->root != root) 647 if (link->root != root)
648 continue; 648 continue;
649 list_for_each_entry(child, &linkbus->devices, bus_list) { 649 list_for_each_entry(child, &linkbus->devices, bus_list) {
650 if ((child->pcie_type != PCI_EXP_TYPE_ENDPOINT) && 650 if ((pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT) &&
651 (child->pcie_type != PCI_EXP_TYPE_LEG_END)) 651 (pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END))
652 continue; 652 continue;
653 pcie_aspm_check_latency(child); 653 pcie_aspm_check_latency(child);
654 } 654 }
@@ -663,8 +663,8 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
663 663
664 if (!pci_is_pcie(pdev) || !parent || !parent->link_state) 664 if (!pci_is_pcie(pdev) || !parent || !parent->link_state)
665 return; 665 return;
666 if ((parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && 666 if ((pci_pcie_type(parent) != PCI_EXP_TYPE_ROOT_PORT) &&
667 (parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)) 667 (pci_pcie_type(parent) != PCI_EXP_TYPE_DOWNSTREAM))
668 return; 668 return;
669 669
670 down_read(&pci_bus_sem); 670 down_read(&pci_bus_sem);
@@ -704,8 +704,8 @@ void pcie_aspm_pm_state_change(struct pci_dev *pdev)
704 704
705 if (aspm_disabled || !pci_is_pcie(pdev) || !link) 705 if (aspm_disabled || !pci_is_pcie(pdev) || !link)
706 return; 706 return;
707 if ((pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && 707 if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
708 (pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)) 708 (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM))
709 return; 709 return;
710 /* 710 /*
711 * Devices changed PM state, we should recheck if latency 711 * Devices changed PM state, we should recheck if latency
@@ -729,8 +729,8 @@ void pcie_aspm_powersave_config_link(struct pci_dev *pdev)
729 if (aspm_policy != POLICY_POWERSAVE) 729 if (aspm_policy != POLICY_POWERSAVE)
730 return; 730 return;
731 731
732 if ((pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && 732 if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
733 (pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)) 733 (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM))
734 return; 734 return;
735 735
736 down_read(&pci_bus_sem); 736 down_read(&pci_bus_sem);
@@ -757,8 +757,8 @@ static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
757 if (!pci_is_pcie(pdev)) 757 if (!pci_is_pcie(pdev))
758 return; 758 return;
759 759
760 if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT || 760 if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT ||
761 pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) 761 pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM)
762 parent = pdev; 762 parent = pdev;
763 if (!parent || !parent->link_state) 763 if (!parent || !parent->link_state)
764 return; 764 return;
@@ -933,8 +933,8 @@ void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev)
933 struct pcie_link_state *link_state = pdev->link_state; 933 struct pcie_link_state *link_state = pdev->link_state;
934 934
935 if (!pci_is_pcie(pdev) || 935 if (!pci_is_pcie(pdev) ||
936 (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && 936 (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
937 pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) || !link_state) 937 pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
938 return; 938 return;
939 939
940 if (link_state->aspm_support) 940 if (link_state->aspm_support)
@@ -950,8 +950,8 @@ void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev)
950 struct pcie_link_state *link_state = pdev->link_state; 950 struct pcie_link_state *link_state = pdev->link_state;
951 951
952 if (!pci_is_pcie(pdev) || 952 if (!pci_is_pcie(pdev) ||
953 (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && 953 (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
954 pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) || !link_state) 954 pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
955 return; 955 return;
956 956
957 if (link_state->aspm_support) 957 if (link_state->aspm_support)
diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c
index 001f1b78f39c..30897bf05b58 100644
--- a/drivers/pci/pcie/pme.c
+++ b/drivers/pci/pcie/pme.c
@@ -120,7 +120,7 @@ static bool pcie_pme_from_pci_bridge(struct pci_bus *bus, u8 devfn)
120 if (!dev) 120 if (!dev)
121 return false; 121 return false;
122 122
123 if (pci_is_pcie(dev) && dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) { 123 if (pci_is_pcie(dev) && pci_pcie_type(dev) == PCI_EXP_TYPE_PCI_BRIDGE) {
124 down_read(&pci_bus_sem); 124 down_read(&pci_bus_sem);
125 if (pcie_pme_walk_bus(bus)) 125 if (pcie_pme_walk_bus(bus))
126 found = true; 126 found = true;
@@ -335,13 +335,13 @@ static void pcie_pme_mark_devices(struct pci_dev *port)
335 struct pci_dev *dev; 335 struct pci_dev *dev;
336 336
337 /* Check if this is a root port event collector. */ 337 /* Check if this is a root port event collector. */
338 if (port->pcie_type != PCI_EXP_TYPE_RC_EC || !bus) 338 if (pci_pcie_type(port) != PCI_EXP_TYPE_RC_EC || !bus)
339 return; 339 return;
340 340
341 down_read(&pci_bus_sem); 341 down_read(&pci_bus_sem);
342 list_for_each_entry(dev, &bus->devices, bus_list) 342 list_for_each_entry(dev, &bus->devices, bus_list)
343 if (pci_is_pcie(dev) 343 if (pci_is_pcie(dev)
344 && dev->pcie_type == PCI_EXP_TYPE_RC_END) 344 && pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END)
345 pcie_pme_set_native(dev, NULL); 345 pcie_pme_set_native(dev, NULL);
346 up_read(&pci_bus_sem); 346 up_read(&pci_bus_sem);
347 } 347 }
diff --git a/drivers/pci/pcie/portdrv_bus.c b/drivers/pci/pcie/portdrv_bus.c
index 18bf90f748f6..67be55a7f260 100644
--- a/drivers/pci/pcie/portdrv_bus.c
+++ b/drivers/pci/pcie/portdrv_bus.c
@@ -38,7 +38,7 @@ static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
38 return 0; 38 return 0;
39 39
40 if ((driver->port_type != PCIE_ANY_PORT) && 40 if ((driver->port_type != PCIE_ANY_PORT) &&
41 (driver->port_type != pciedev->port->pcie_type)) 41 (driver->port_type != pci_pcie_type(pciedev->port)))
42 return 0; 42 return 0;
43 43
44 return 1; 44 return 1;
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 75915b30ad19..bf320a9419f4 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -298,7 +298,7 @@ static int get_port_device_capability(struct pci_dev *dev)
298 services |= PCIE_PORT_SERVICE_VC; 298 services |= PCIE_PORT_SERVICE_VC;
299 /* Root ports are capable of generating PME too */ 299 /* Root ports are capable of generating PME too */
300 if ((cap_mask & PCIE_PORT_SERVICE_PME) 300 if ((cap_mask & PCIE_PORT_SERVICE_PME)
301 && dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) { 301 && pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) {
302 services |= PCIE_PORT_SERVICE_PME; 302 services |= PCIE_PORT_SERVICE_PME;
303 /* 303 /*
304 * Disable PME interrupt on this port in case it's been enabled 304 * Disable PME interrupt on this port in case it's been enabled
@@ -336,7 +336,7 @@ static int pcie_device_init(struct pci_dev *pdev, int service, int irq)
336 device->release = release_pcie_device; /* callback to free pcie dev */ 336 device->release = release_pcie_device; /* callback to free pcie dev */
337 dev_set_name(device, "%s:pcie%02x", 337 dev_set_name(device, "%s:pcie%02x",
338 pci_name(pdev), 338 pci_name(pdev),
339 get_descriptor_id(pdev->pcie_type, service)); 339 get_descriptor_id(pci_pcie_type(pdev), service));
340 device->parent = &pdev->dev; 340 device->parent = &pdev->dev;
341 device_enable_async_suspend(device); 341 device_enable_async_suspend(device);
342 342
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 3a7eefcb270a..24d1463e688b 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -95,7 +95,7 @@ static int pcie_port_resume_noirq(struct device *dev)
95 * which breaks ACPI-based runtime wakeup on PCI Express, so clear those 95 * which breaks ACPI-based runtime wakeup on PCI Express, so clear those
96 * bits now just in case (shouldn't hurt). 96 * bits now just in case (shouldn't hurt).
97 */ 97 */
98 if(pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) 98 if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT)
99 pcie_clear_root_pme_status(pdev); 99 pcie_clear_root_pme_status(pdev);
100 return 0; 100 return 0;
101} 101}
@@ -186,9 +186,9 @@ static int __devinit pcie_portdrv_probe(struct pci_dev *dev,
186 int status; 186 int status;
187 187
188 if (!pci_is_pcie(dev) || 188 if (!pci_is_pcie(dev) ||
189 ((dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && 189 ((pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) &&
190 (dev->pcie_type != PCI_EXP_TYPE_UPSTREAM) && 190 (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) &&
191 (dev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))) 191 (pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM)))
192 return -ENODEV; 192 return -ENODEV;
193 193
194 if (!dev->irq && dev->pin) { 194 if (!dev->irq && dev->pin) {