[Linux-kernel-mentees] [RFC PATCH v5 20/23] PCI: Remove .root from struct pcie_link_state
Saheed O. Bolarinwa
refactormyself at gmail.com
Sat Aug 22 20:03:55 UTC 2020
- Remove initiations of pcie_link_state.root
- Replace all access to pcie_link_state.root with pci_pdev.root
- Remove pcie_link_state.root
- Do few cleanups
Signed-off-by: Saheed O. Bolarinwa <refactormyself at gmail.com>
---
drivers/pci/pcie/aspm.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 14b9da0a4efd..244b28534e7f 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -44,7 +44,6 @@
struct pcie_link_state {
struct pci_dev *pdev; /* Upstream component of the Link */
struct pci_dev *downstream; /* Downstream component, function 0 */
- struct pcie_link_state *root; /* pointer to the root port link */
};
static int aspm_disabled, aspm_force;
@@ -800,18 +799,13 @@ static int alloc_pcie_link_state(struct pci_dev *pdev)
if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT ||
pci_pcie_type(pdev) == PCI_EXP_TYPE_PCIE_BRIDGE ||
!pdev->bus->parent->self) {
- link->root = link;
pdev->root = pdev;
} else {
- struct pcie_link_state *parent;
-
- parent = pdev->bus->parent->self->link_state;
- if (!parent) {
+ if (!pdev->bus->parent->self) {
kfree(link);
return -1;
}
- link->root = link->pdev->parent->link_state->root;
pdev->parent = pdev->bus->parent->self;
pdev->root = pdev->parent->root;
}
@@ -944,7 +938,7 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
goto out;
link = parent->link_state;
- root = link->root;
+ root = link->pdev->root->link_state;
parent_link = link->pdev->parent->link_state;
/* All functions are removed, so just disable ASPM for the link */
@@ -966,9 +960,7 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
/* @pdev: the root port or switch downstream port */
void pcie_aspm_pm_state_change(struct pci_dev *pdev)
{
- struct pcie_link_state *link = pdev->link_state;
-
- if (aspm_disabled || !link)
+ if (aspm_disabled || !pdev)
return;
/*
* Devices changed PM state, we should recheck if latency
@@ -976,7 +968,7 @@ void pcie_aspm_pm_state_change(struct pci_dev *pdev)
*/
down_read(&pci_bus_sem);
mutex_lock(&aspm_lock);
- pcie_update_aspm_capable(link->root->pdev);
+ pcie_update_aspm_capable(pdev->root);
pcie_config_aspm_path(pdev);
mutex_unlock(&aspm_lock);
up_read(&pci_bus_sem);
--
2.18.4
More information about the Linux-kernel-mentees
mailing list