[Linux-kernel-mentees] [RFC PATCH v5 17/23] PCI: Remove .clkpm_* from struct pcie_link_state

Saheed O. Bolarinwa refactormyself at gmail.com
Sat Aug 22 20:03:52 UTC 2020


 - Remove initiations of pcie_link_state.clkpm_*
 - Replace all access to pcie_link_state.clkpm_* with pci_pdev.clkpm_*
 - Remove pcie_link_state.clkpm_*

Signed-off-by: Saheed O. Bolarinwa <refactormyself at gmail.com>
---
 drivers/pci/pcie/aspm.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 56fdf2e7c98a..27a590fe6b23 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -53,12 +53,6 @@ struct pcie_link_state {
 	u32 aspm_capable:7;		/* Capable ASPM state with latency */
 	u32 aspm_default:7;		/* Default ASPM state by BIOS */
 	u32 aspm_disable:7;		/* Disabled ASPM state */
-
-	/* Clock PM state */
-	u32 clkpm_capable:1;		/* Clock PM capable? */
-	u32 clkpm_enabled:1;		/* Current Clock PM state */
-	u32 clkpm_default:1;		/* Default Clock PM state by BIOS */
-	u32 clkpm_disable:1;		/* Clock PM disabled */
 };
 
 static int aspm_disabled, aspm_force;
@@ -119,7 +113,7 @@ static int policy_to_clkpm_state(struct pci_dev *pdev)
 		/* Enable Clock PM */
 		return 1;
 	case POLICY_DEFAULT:
-		return pdev->link_state->clkpm_default;
+		return pdev->clkpm_default;
 	}
 	return 0;
 }
@@ -135,7 +129,6 @@ static void pcie_set_clkpm_nocheck(struct pci_dev *pdev, int enable)
 		pcie_capability_clear_and_set_word(child, PCI_EXP_LNKCTL,
 						   PCI_EXP_LNKCTL_CLKREQ_EN,
 						   val);
-	link->clkpm_enabled = !!enable;
 	link->pdev->clkpm_enabled = !!enable;
 }
 
@@ -146,10 +139,10 @@ static void pcie_set_clkpm(struct pci_dev *pdev, int enable)
 	 * Don't enable Clock PM if the link is not Clock PM capable
 	 * or Clock PM is disabled
 	 */
-	if (!link->clkpm_capable || link->clkpm_disable)
+	if (!pdev->clkpm_capable || pdev->clkpm_disable)
 		enable = 0;
 	/* Need nothing if the specified equals to current state */
-	if (link->clkpm_enabled == enable)
+	if (pdev->clkpm_enabled == enable)
 		return;
 	pcie_set_clkpm_nocheck(link->pdev, enable);
 }
@@ -173,10 +166,6 @@ static void pcie_clkpm_cap_init(struct pci_dev *pdev, int blacklist)
 		if (!(reg16 & PCI_EXP_LNKCTL_CLKREQ_EN))
 			enabled = 0;
 	}
-	link->clkpm_enabled = enabled;
-	link->clkpm_default = enabled;
-	link->clkpm_capable = capable;
-	link->clkpm_disable = blacklist ? 1 : 0;
 	link->pdev->clkpm_enabled = enabled;
 	link->pdev->clkpm_default = enabled;
 	link->pdev->clkpm_capable = capable;
@@ -1124,7 +1113,6 @@ static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
 	pcie_config_aspm_link(link->pdev, policy_to_aspm_state(link->pdev));
 
 	if (state & PCIE_LINK_STATE_CLKPM) {
-		link->clkpm_disable = 1;
 		bridge->clkpm_disable = 1;
 	}
 	pcie_set_clkpm(link->pdev, policy_to_clkpm_state(link->pdev));
@@ -1284,7 +1272,7 @@ static ssize_t clkpm_show(struct device *dev,
 {
 	struct pci_dev *pdev = pcie_aspm_get_link(to_pci_dev(dev));
 
-	return sprintf(buf, "%d\n", pdev->link_state->clkpm_enabled);
+	return sprintf(buf, "%d\n", pdev->clkpm_enabled);
 }
 
 static ssize_t clkpm_store(struct device *dev,
@@ -1301,7 +1289,6 @@ static ssize_t clkpm_store(struct device *dev,
 	down_read(&pci_bus_sem);
 	mutex_lock(&aspm_lock);
 
-	link->clkpm_disable = !state_enable;
 	link->pdev->clkpm_disable = !state_enable;
 	pcie_set_clkpm(link->pdev, policy_to_clkpm_state(link->pdev));
 
@@ -1349,7 +1336,7 @@ static umode_t aspm_ctrl_attrs_are_visible(struct kobject *kobj,
 		return 0;
 
 	if (n == 0)
-		return link->clkpm_capable ? a->mode : 0;
+		return pdev->clkpm_capable ? a->mode : 0;
 
 	return link->aspm_capable & aspm_state_map[n - 1] ? a->mode : 0;
 }
-- 
2.18.4



More information about the Linux-kernel-mentees mailing list