[v2,3/3] PCI/DPC: Encapsulate pci_acpi_add_edr_notifier()

Message ID 20240222221521.32159-4-helgaas@kernel.org
State New
Headers
Series PCI/DPC: Clean up DPC vs AER/EDR ownership and Kconfig |

Commit Message

Bjorn Helgaas Feb. 22, 2024, 10:15 p.m. UTC
  From: Bjorn Helgaas <bhelgaas@google.com>

pci_acpi_add_edr_notifier() and pci_acpi_remove_edr_notifier() are only
referenced inside drivers/pci/.  Move their declarations from
include/linux/pci-acpi.h to drivers/pci/pci.h so they're not visible
outside drivers/pci/.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.h        | 4 ++++
 include/linux/pci-acpi.h | 8 --------
 2 files changed, 4 insertions(+), 8 deletions(-)
  

Comments

Kuppuswamy Sathyanarayanan Feb. 25, 2024, 8:06 p.m. UTC | #1
On 2/22/24 2:15 PM, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
>
> pci_acpi_add_edr_notifier() and pci_acpi_remove_edr_notifier() are only
> referenced inside drivers/pci/.  Move their declarations from
> include/linux/pci-acpi.h to drivers/pci/pci.h so they're not visible
> outside drivers/pci/.
>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/pci.h        | 4 ++++
>  include/linux/pci-acpi.h | 8 --------
>  2 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 2336a8d1edab..03bf2776d73b 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -432,11 +432,15 @@ void pci_dpc_init(struct pci_dev *pdev);
>  void dpc_process_error(struct pci_dev *pdev);
>  pci_ers_result_t dpc_reset_link(struct pci_dev *pdev);
>  bool pci_dpc_recovered(struct pci_dev *pdev);
> +void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
> +void pci_acpi_remove_edr_notifier(struct pci_dev *pdev);

Protect them with CONFIG_ACPI?

>  #else
>  static inline void pci_save_dpc_state(struct pci_dev *dev) { }
>  static inline void pci_restore_dpc_state(struct pci_dev *dev) { }
>  static inline void pci_dpc_init(struct pci_dev *pdev) { }
>  static inline bool pci_dpc_recovered(struct pci_dev *pdev) { return false; }
> +static inline void pci_acpi_add_edr_notifier(struct pci_dev *pdev) { }
> +static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { }
>  #endif
>  
>  #ifdef CONFIG_PCIEPORTBUS
> diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
> index 92e196ba0249..f447ce215adf 100644
> --- a/include/linux/pci-acpi.h
> +++ b/include/linux/pci-acpi.h
> @@ -122,14 +122,6 @@ extern const guid_t pci_acpi_dsm_guid;
>  #define DSM_PCI_POWER_ON_RESET_DELAY		0x08
>  #define DSM_PCI_DEVICE_READINESS_DURATIONS	0x09
>  
> -#ifdef CONFIG_PCIE_DPC
> -void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
> -void pci_acpi_remove_edr_notifier(struct pci_dev *pdev);
> -#else
> -static inline void pci_acpi_add_edr_notifier(struct pci_dev *pdev) { }
> -static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { }
> -#endif /* CONFIG_PCIE_DPC */
> -
>  int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_dev *));
>  void pci_acpi_clear_companion_lookup_hook(void);
>
  
Bjorn Helgaas Feb. 26, 2024, 3:25 p.m. UTC | #2
On Sun, Feb 25, 2024 at 12:06:52PM -0800, Kuppuswamy Sathyanarayanan wrote:
> 
> On 2/22/24 2:15 PM, Bjorn Helgaas wrote:
> > From: Bjorn Helgaas <bhelgaas@google.com>
> >
> > pci_acpi_add_edr_notifier() and pci_acpi_remove_edr_notifier() are only
> > referenced inside drivers/pci/.  Move their declarations from
> > include/linux/pci-acpi.h to drivers/pci/pci.h so they're not visible
> > outside drivers/pci/.
> >
> > Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> > ---
> >  drivers/pci/pci.h        | 4 ++++
> >  include/linux/pci-acpi.h | 8 --------
> >  2 files changed, 4 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> > index 2336a8d1edab..03bf2776d73b 100644
> > --- a/drivers/pci/pci.h
> > +++ b/drivers/pci/pci.h
> > @@ -432,11 +432,15 @@ void pci_dpc_init(struct pci_dev *pdev);
> >  void dpc_process_error(struct pci_dev *pdev);
> >  pci_ers_result_t dpc_reset_link(struct pci_dev *pdev);
> >  bool pci_dpc_recovered(struct pci_dev *pdev);
> > +void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
> > +void pci_acpi_remove_edr_notifier(struct pci_dev *pdev);
> 
> Protect them with CONFIG_ACPI?

Good idea, thanks!  They're called only from pci-acpi.c, so I moved
them inside the #ifdef CONFIG_ACPI above:

  #ifdef CONFIG_ACPI
  int pci_acpi_program_hp_params(struct pci_dev *dev);
  ...
  #ifdef CONFIG_PCIE_DPC
  void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
  void pci_acpi_remove_edr_notifier(struct pci_dev *pdev);
  #endif
  #else
  static inline int pci_acpi_program_hp_params(struct pci_dev *dev)
  {
          return -ENODEV;
  }
  #ifdef CONFIG_PCIE_DPC
  static inline void pci_acpi_add_edr_notifier(struct pci_dev *pdev) { }
  static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { }
  #endif
  #endif

Bjorn
  

Patch

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 2336a8d1edab..03bf2776d73b 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -432,11 +432,15 @@  void pci_dpc_init(struct pci_dev *pdev);
 void dpc_process_error(struct pci_dev *pdev);
 pci_ers_result_t dpc_reset_link(struct pci_dev *pdev);
 bool pci_dpc_recovered(struct pci_dev *pdev);
+void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
+void pci_acpi_remove_edr_notifier(struct pci_dev *pdev);
 #else
 static inline void pci_save_dpc_state(struct pci_dev *dev) { }
 static inline void pci_restore_dpc_state(struct pci_dev *dev) { }
 static inline void pci_dpc_init(struct pci_dev *pdev) { }
 static inline bool pci_dpc_recovered(struct pci_dev *pdev) { return false; }
+static inline void pci_acpi_add_edr_notifier(struct pci_dev *pdev) { }
+static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { }
 #endif
 
 #ifdef CONFIG_PCIEPORTBUS
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index 92e196ba0249..f447ce215adf 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -122,14 +122,6 @@  extern const guid_t pci_acpi_dsm_guid;
 #define DSM_PCI_POWER_ON_RESET_DELAY		0x08
 #define DSM_PCI_DEVICE_READINESS_DURATIONS	0x09
 
-#ifdef CONFIG_PCIE_DPC
-void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
-void pci_acpi_remove_edr_notifier(struct pci_dev *pdev);
-#else
-static inline void pci_acpi_add_edr_notifier(struct pci_dev *pdev) { }
-static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { }
-#endif /* CONFIG_PCIE_DPC */
-
 int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_dev *));
 void pci_acpi_clear_companion_lookup_hook(void);