[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220906222351.64760-10-helgaas@kernel.org>
Date: Tue, 6 Sep 2022 17:23:50 -0500
From: Bjorn Helgaas <helgaas@...nel.org>
To: Kai-Heng Feng <kai.heng.feng@...onical.com>,
Rajvi Jingar <rajvi.jingar@...ux.intel.com>,
"Rafael J . Wysocki" <rafael@...nel.org>
Cc: Koba Ko <koba.ko@...onical.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
"David E . Box" <david.e.box@...ux.intel.com>,
Sathyanarayanan Kuppuswamy
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
linux-pci@...r.kernel.org, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, Bjorn Helgaas <bhelgaas@...gle.com>
Subject: [PATCH v3 09/10] PCI/PTM: Reorder functions in logical order
From: Bjorn Helgaas <bhelgaas@...gle.com>
pci_enable_ptm() and pci_disable_ptm() were separated.
pci_save_ptm_state() and pci_restore_ptm_state() dangled at the top. Move
them to logical places.
Signed-off-by: Bjorn Helgaas <bhelgaas@...gle.com>
---
drivers/pci/pcie/ptm.c | 108 ++++++++++++++++++++---------------------
1 file changed, 54 insertions(+), 54 deletions(-)
diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c
index d65f5af9700d..6c09e00a7b51 100644
--- a/drivers/pci/pcie/ptm.c
+++ b/drivers/pci/pcie/ptm.c
@@ -9,60 +9,6 @@
#include <linux/pci.h>
#include "../pci.h"
-static void __pci_disable_ptm(struct pci_dev *dev)
-{
- int ptm = dev->ptm_cap;
- u16 ctrl;
-
- if (!ptm)
- return;
-
- pci_read_config_word(dev, ptm + PCI_PTM_CTRL, &ctrl);
- ctrl &= ~PCI_PTM_CTRL_ENABLE;
- pci_write_config_word(dev, ptm + PCI_PTM_CTRL, ctrl);
-}
-
-void pci_disable_ptm(struct pci_dev *dev)
-{
- __pci_disable_ptm(dev);
- dev->ptm_enabled = 0;
-}
-EXPORT_SYMBOL(pci_disable_ptm);
-
-void pci_save_ptm_state(struct pci_dev *dev)
-{
- int ptm = dev->ptm_cap;
- struct pci_cap_saved_state *save_state;
- u16 *cap;
-
- if (!ptm)
- return;
-
- save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_PTM);
- if (!save_state)
- return;
-
- cap = (u16 *)&save_state->cap.data[0];
- pci_read_config_word(dev, ptm + PCI_PTM_CTRL, cap);
-}
-
-void pci_restore_ptm_state(struct pci_dev *dev)
-{
- int ptm = dev->ptm_cap;
- struct pci_cap_saved_state *save_state;
- u16 *cap;
-
- if (!ptm)
- return;
-
- save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_PTM);
- if (!save_state)
- return;
-
- cap = (u16 *)&save_state->cap.data[0];
- pci_write_config_word(dev, ptm + PCI_PTM_CTRL, *cap);
-}
-
/*
* If the next upstream device supports PTM, return it; otherwise return
* NULL. PTM Messages are local, so both link partners must support it.
@@ -132,6 +78,40 @@ void pci_ptm_init(struct pci_dev *dev)
pci_enable_ptm(dev, NULL);
}
+void pci_save_ptm_state(struct pci_dev *dev)
+{
+ int ptm = dev->ptm_cap;
+ struct pci_cap_saved_state *save_state;
+ u16 *cap;
+
+ if (!ptm)
+ return;
+
+ save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_PTM);
+ if (!save_state)
+ return;
+
+ cap = (u16 *)&save_state->cap.data[0];
+ pci_read_config_word(dev, ptm + PCI_PTM_CTRL, cap);
+}
+
+void pci_restore_ptm_state(struct pci_dev *dev)
+{
+ int ptm = dev->ptm_cap;
+ struct pci_cap_saved_state *save_state;
+ u16 *cap;
+
+ if (!ptm)
+ return;
+
+ save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_PTM);
+ if (!save_state)
+ return;
+
+ cap = (u16 *)&save_state->cap.data[0];
+ pci_write_config_word(dev, ptm + PCI_PTM_CTRL, *cap);
+}
+
static int __pci_enable_ptm(struct pci_dev *dev)
{
int ptm = dev->ptm_cap;
@@ -193,6 +173,26 @@ int pci_enable_ptm(struct pci_dev *dev, u8 *granularity)
}
EXPORT_SYMBOL(pci_enable_ptm);
+static void __pci_disable_ptm(struct pci_dev *dev)
+{
+ int ptm = dev->ptm_cap;
+ u16 ctrl;
+
+ if (!ptm)
+ return;
+
+ pci_read_config_word(dev, ptm + PCI_PTM_CTRL, &ctrl);
+ ctrl &= ~PCI_PTM_CTRL_ENABLE;
+ pci_write_config_word(dev, ptm + PCI_PTM_CTRL, ctrl);
+}
+
+void pci_disable_ptm(struct pci_dev *dev)
+{
+ __pci_disable_ptm(dev);
+ dev->ptm_enabled = 0;
+}
+EXPORT_SYMBOL(pci_disable_ptm);
+
/*
* Disable PTM, but leave dev->ptm_enabled so we silently re-enable it on
* resume.
--
2.25.1
Powered by blists - more mailing lists