From: Bjorn Helgaas <bhelgaas@xxxxxxxxxx> 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@xxxxxxxxxx> --- 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