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>
This commit is contained in:

committed by
Bjorn Helgaas

parent
786e22885d
commit
62f87c0e31
@@ -288,7 +288,7 @@ static struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
|
||||
while (1) {
|
||||
if (!pci_is_pcie(dev))
|
||||
break;
|
||||
if (dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT)
|
||||
if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
|
||||
return dev;
|
||||
if (!dev->bus->self)
|
||||
break;
|
||||
|
@@ -81,10 +81,11 @@ bool pci_aer_available(void)
|
||||
static int set_device_error_reporting(struct pci_dev *dev, void *data)
|
||||
{
|
||||
bool enable = *((bool *)data);
|
||||
int type = pci_pcie_type(dev);
|
||||
|
||||
if ((dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) ||
|
||||
(dev->pcie_type == PCI_EXP_TYPE_UPSTREAM) ||
|
||||
(dev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)) {
|
||||
if ((type == PCI_EXP_TYPE_ROOT_PORT) ||
|
||||
(type == PCI_EXP_TYPE_UPSTREAM) ||
|
||||
(type == PCI_EXP_TYPE_DOWNSTREAM)) {
|
||||
if (enable)
|
||||
pci_enable_pcie_error_reporting(dev);
|
||||
else
|
||||
|
@@ -60,7 +60,7 @@ static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data)
|
||||
p = (struct acpi_hest_aer_common *)(hest_hdr + 1);
|
||||
if (p->flags & ACPI_HEST_GLOBAL) {
|
||||
if ((pci_is_pcie(info->pci_dev) &&
|
||||
info->pci_dev->pcie_type == pcie_type) || bridge)
|
||||
pci_pcie_type(info->pci_dev) == pcie_type) || bridge)
|
||||
ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
|
||||
} else
|
||||
if (hest_match_pci(p, info->pci_dev))
|
||||
|
@@ -465,7 +465,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev)
|
||||
|
||||
if (driver && driver->reset_link) {
|
||||
status = driver->reset_link(udev);
|
||||
} else if (udev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) {
|
||||
} else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM) {
|
||||
status = default_downstream_reset_link(udev);
|
||||
} else {
|
||||
dev_printk(KERN_DEBUG, &dev->dev,
|
||||
|
@@ -412,7 +412,7 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
|
||||
* do ASPM for now.
|
||||
*/
|
||||
list_for_each_entry(child, &linkbus->devices, bus_list) {
|
||||
if (child->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) {
|
||||
if (pci_pcie_type(child) == PCI_EXP_TYPE_PCI_BRIDGE) {
|
||||
link->aspm_disable = ASPM_STATE_ALL;
|
||||
break;
|
||||
}
|
||||
@@ -425,8 +425,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
|
||||
struct aspm_latency *acceptable =
|
||||
&link->acceptable[PCI_FUNC(child->devfn)];
|
||||
|
||||
if (child->pcie_type != PCI_EXP_TYPE_ENDPOINT &&
|
||||
child->pcie_type != PCI_EXP_TYPE_LEG_END)
|
||||
if (pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT &&
|
||||
pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END)
|
||||
continue;
|
||||
|
||||
pos = pci_pcie_cap(child);
|
||||
@@ -552,7 +552,7 @@ static struct pcie_link_state *alloc_pcie_link_state(struct pci_dev *pdev)
|
||||
INIT_LIST_HEAD(&link->children);
|
||||
INIT_LIST_HEAD(&link->link);
|
||||
link->pdev = pdev;
|
||||
if (pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) {
|
||||
if (pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM) {
|
||||
struct pcie_link_state *parent;
|
||||
parent = pdev->bus->parent->self->link_state;
|
||||
if (!parent) {
|
||||
@@ -585,12 +585,12 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)
|
||||
|
||||
if (!pci_is_pcie(pdev) || pdev->link_state)
|
||||
return;
|
||||
if (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT &&
|
||||
pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)
|
||||
if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
|
||||
pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM)
|
||||
return;
|
||||
|
||||
/* VIA has a strange chipset, root port is under a bridge */
|
||||
if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT &&
|
||||
if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT &&
|
||||
pdev->bus->self)
|
||||
return;
|
||||
|
||||
@@ -647,8 +647,8 @@ static void pcie_update_aspm_capable(struct pcie_link_state *root)
|
||||
if (link->root != root)
|
||||
continue;
|
||||
list_for_each_entry(child, &linkbus->devices, bus_list) {
|
||||
if ((child->pcie_type != PCI_EXP_TYPE_ENDPOINT) &&
|
||||
(child->pcie_type != PCI_EXP_TYPE_LEG_END))
|
||||
if ((pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT) &&
|
||||
(pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END))
|
||||
continue;
|
||||
pcie_aspm_check_latency(child);
|
||||
}
|
||||
@@ -663,8 +663,8 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
|
||||
|
||||
if (!pci_is_pcie(pdev) || !parent || !parent->link_state)
|
||||
return;
|
||||
if ((parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT) &&
|
||||
(parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))
|
||||
if ((pci_pcie_type(parent) != PCI_EXP_TYPE_ROOT_PORT) &&
|
||||
(pci_pcie_type(parent) != PCI_EXP_TYPE_DOWNSTREAM))
|
||||
return;
|
||||
|
||||
down_read(&pci_bus_sem);
|
||||
@@ -704,8 +704,8 @@ void pcie_aspm_pm_state_change(struct pci_dev *pdev)
|
||||
|
||||
if (aspm_disabled || !pci_is_pcie(pdev) || !link)
|
||||
return;
|
||||
if ((pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) &&
|
||||
(pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))
|
||||
if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
|
||||
(pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM))
|
||||
return;
|
||||
/*
|
||||
* Devices changed PM state, we should recheck if latency
|
||||
@@ -729,8 +729,8 @@ void pcie_aspm_powersave_config_link(struct pci_dev *pdev)
|
||||
if (aspm_policy != POLICY_POWERSAVE)
|
||||
return;
|
||||
|
||||
if ((pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) &&
|
||||
(pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))
|
||||
if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
|
||||
(pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM))
|
||||
return;
|
||||
|
||||
down_read(&pci_bus_sem);
|
||||
@@ -757,8 +757,8 @@ static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
|
||||
if (!pci_is_pcie(pdev))
|
||||
return;
|
||||
|
||||
if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT ||
|
||||
pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)
|
||||
if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT ||
|
||||
pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM)
|
||||
parent = pdev;
|
||||
if (!parent || !parent->link_state)
|
||||
return;
|
||||
@@ -933,8 +933,8 @@ void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev)
|
||||
struct pcie_link_state *link_state = pdev->link_state;
|
||||
|
||||
if (!pci_is_pcie(pdev) ||
|
||||
(pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT &&
|
||||
pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
|
||||
(pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
|
||||
pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
|
||||
return;
|
||||
|
||||
if (link_state->aspm_support)
|
||||
@@ -950,8 +950,8 @@ void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev)
|
||||
struct pcie_link_state *link_state = pdev->link_state;
|
||||
|
||||
if (!pci_is_pcie(pdev) ||
|
||||
(pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT &&
|
||||
pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
|
||||
(pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
|
||||
pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
|
||||
return;
|
||||
|
||||
if (link_state->aspm_support)
|
||||
|
@@ -120,7 +120,7 @@ static bool pcie_pme_from_pci_bridge(struct pci_bus *bus, u8 devfn)
|
||||
if (!dev)
|
||||
return false;
|
||||
|
||||
if (pci_is_pcie(dev) && dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) {
|
||||
if (pci_is_pcie(dev) && pci_pcie_type(dev) == PCI_EXP_TYPE_PCI_BRIDGE) {
|
||||
down_read(&pci_bus_sem);
|
||||
if (pcie_pme_walk_bus(bus))
|
||||
found = true;
|
||||
@@ -335,13 +335,13 @@ static void pcie_pme_mark_devices(struct pci_dev *port)
|
||||
struct pci_dev *dev;
|
||||
|
||||
/* Check if this is a root port event collector. */
|
||||
if (port->pcie_type != PCI_EXP_TYPE_RC_EC || !bus)
|
||||
if (pci_pcie_type(port) != PCI_EXP_TYPE_RC_EC || !bus)
|
||||
return;
|
||||
|
||||
down_read(&pci_bus_sem);
|
||||
list_for_each_entry(dev, &bus->devices, bus_list)
|
||||
if (pci_is_pcie(dev)
|
||||
&& dev->pcie_type == PCI_EXP_TYPE_RC_END)
|
||||
&& pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END)
|
||||
pcie_pme_set_native(dev, NULL);
|
||||
up_read(&pci_bus_sem);
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
|
||||
return 0;
|
||||
|
||||
if ((driver->port_type != PCIE_ANY_PORT) &&
|
||||
(driver->port_type != pciedev->port->pcie_type))
|
||||
(driver->port_type != pci_pcie_type(pciedev->port)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
@@ -298,7 +298,7 @@ static int get_port_device_capability(struct pci_dev *dev)
|
||||
services |= PCIE_PORT_SERVICE_VC;
|
||||
/* Root ports are capable of generating PME too */
|
||||
if ((cap_mask & PCIE_PORT_SERVICE_PME)
|
||||
&& dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) {
|
||||
&& pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) {
|
||||
services |= PCIE_PORT_SERVICE_PME;
|
||||
/*
|
||||
* 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)
|
||||
device->release = release_pcie_device; /* callback to free pcie dev */
|
||||
dev_set_name(device, "%s:pcie%02x",
|
||||
pci_name(pdev),
|
||||
get_descriptor_id(pdev->pcie_type, service));
|
||||
get_descriptor_id(pci_pcie_type(pdev), service));
|
||||
device->parent = &pdev->dev;
|
||||
device_enable_async_suspend(device);
|
||||
|
||||
|
@@ -95,7 +95,7 @@ static int pcie_port_resume_noirq(struct device *dev)
|
||||
* which breaks ACPI-based runtime wakeup on PCI Express, so clear those
|
||||
* bits now just in case (shouldn't hurt).
|
||||
*/
|
||||
if(pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT)
|
||||
if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT)
|
||||
pcie_clear_root_pme_status(pdev);
|
||||
return 0;
|
||||
}
|
||||
@@ -186,9 +186,9 @@ static int __devinit pcie_portdrv_probe(struct pci_dev *dev,
|
||||
int status;
|
||||
|
||||
if (!pci_is_pcie(dev) ||
|
||||
((dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) &&
|
||||
(dev->pcie_type != PCI_EXP_TYPE_UPSTREAM) &&
|
||||
(dev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)))
|
||||
((pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) &&
|
||||
(pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) &&
|
||||
(pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM)))
|
||||
return -ENODEV;
|
||||
|
||||
if (!dev->irq && dev->pin) {
|
||||
|
Reference in New Issue
Block a user