Skip to contentSkip to conversation

PCI: Move pci_dev_is/assign_added() to pci.h

PATCH Superseded Niklas Schnelle 1 participant 3 messages Jul 19, 2021 – Jul 20, 2021

Subsystems (6)
PowerPC ACPI PCI s390 +2 more subsystems

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Niklas Schnelle

author maintainer
#0 lore raw

PATCH 1/1 PCI: Move pci_dev_is/assign_added() to pci.h

The helper function pci_dev_is_added() from drivers/pci/pci.h is used in PCI arch code of both s390 and powerpc leading to awkward relative includes. Move it to the global include/linux/pci.h and get rid of these includes just for that one function.

---
 arch/powerpc/platforms/powernv/pci-sriov.c |  3 ---
 arch/powerpc/platforms/pseries/setup.c     |  1 -
 arch/s390/pci/pci_sysfs.c                  |  2 --
 drivers/pci/hotplug/acpiphp_glue.c         |  1 -
 drivers/pci/pci.h                          | 15 ---------------
 include/linux/pci.h                        | 13 +++++++++++++
 6 files changed, 13 insertions(+), 22 deletions(-)
arch/powerpc/platforms/powernv/pci-sriov.c +0 -3
index 28aac933a439..2e0ca5451e85 100644
@@ -9,9 +9,6 @@
 
 #include "pci.h"
 
-/* for pci_dev_is_added() */
-#include "../../../../drivers/pci/pci.h"
-
 /*
  * The majority of the complexity in supporting SR-IOV on PowerNV comes from
  * the need to put the MMIO space for each VF into a separate PE. Internally
arch/powerpc/platforms/pseries/setup.c +0 -1
index 631a0d57b6cd..17585ec9f955 100644
@@ -74,7 +74,6 @@
 #include <asm/hvconsole.h>
 
 #include "pseries.h"
-#include "../../../../drivers/pci/pci.h"
 
 DEFINE_STATIC_KEY_FALSE(shared_processor);
 EXPORT_SYMBOL_GPL(shared_processor);
arch/s390/pci/pci_sysfs.c +0 -2
index 6e2450c2b9c1..8dbe54ef8f8e 100644
@@ -13,8 +13,6 @@
 #include <linux/stat.h>
 #include <linux/pci.h>
 
-#include "../../../drivers/pci/pci.h"
-
 #include <asm/sclp.h>
 
 #define zpci_attr(name, fmt, member)					\
drivers/pci/hotplug/acpiphp_glue.c +0 -1
index f031302ad401..4cb963f88183 100644
@@ -38,7 +38,6 @@
 #include <linux/slab.h>
 #include <linux/acpi.h>
 
-#include "../pci.h"
 #include "acpiphp.h"
 
 static LIST_HEAD(bridge_list);
drivers/pci/pci.h +0 -15
index 93dcdd431072..a159cd0f6f05 100644
@@ -383,21 +383,6 @@ static inline bool pci_dev_is_disconnected(const struct pci_dev *dev)
 	return dev->error_state == pci_channel_io_perm_failure;
 }
 
-/* pci_dev priv_flags */
-#define PCI_DEV_ADDED 0
-#define PCI_DPC_RECOVERED 1
-#define PCI_DPC_RECOVERING 2
-
-static inline void pci_dev_assign_added(struct pci_dev *dev, bool added)
-{
-	assign_bit(PCI_DEV_ADDED, &dev->priv_flags, added);
-}
-
-static inline bool pci_dev_is_added(const struct pci_dev *dev)
-{
-	return test_bit(PCI_DEV_ADDED, &dev->priv_flags);
-}
-
 #ifdef CONFIG_PCIEAER
 #include <linux/aer.h>
 
include/linux/pci.h +13 -0
index 540b377ca8f6..b3b7bafa17e5 100644
@@ -507,6 +507,19 @@ struct pci_dev {
 	unsigned long	priv_flags;	/* Private flags for the PCI driver */
 };
 
+/* pci_dev priv_flags */
+#define PCI_DEV_ADDED 0
+
+static inline void pci_dev_assign_added(struct pci_dev *dev, bool added)
+{
+	assign_bit(PCI_DEV_ADDED, &dev->priv_flags, added);
+}
+
+static inline bool pci_dev_is_added(const struct pci_dev *dev)
+{
+	return test_bit(PCI_DEV_ADDED, &dev->priv_flags);
+}
+
 static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
 {
 #ifdef CONFIG_PCI_IOV
Signature · 1 line
2.25.1
author maintainer
#1 lore raw
Quoted 8 lines · Niklas Schnelle

The helper function pci_dev_is_added() from drivers/pci/pci.h is used in PCI arch code of both s390 and powerpc leading to awkward relative includes. Move it to the global include/linux/pci.h and get rid of these includes just for that one function.

---

... snip ...

Quoted 7 lines

static LIST_HEAD(bridge_list);

drivers/pci/pci.h +0 -0
index 93dcdd431072..a159cd0f6f05 100644

drivers/pci/pci.h static inline bool pci_dev_is_disconnected(const struct pci_dev *dev) · line 389

Quoted 7 lines
drivers/pci/pci.h +0 -4
@@ -383,21 +383,6 @@ static inline bool pci_dev_is_disconnected(const struct pci_dev *dev)
 	return dev->error_state == pci_channel_io_perm_failure;
 }
 
-/* pci_dev priv_flags */
-#define PCI_DEV_ADDED 0
-#define PCI_DPC_RECOVERED 1
-#define PCI_DPC_RECOVERING 2

Sorry, the above two PCI_DPC_* lines should remain in drivers/pci/pci.h I messed this up on rebasing to v5.14-rc1 and it didn't lead to problems on either s390x defconfig, nor pp64_defconfig but breaks ppc allyesconfig. Will resend a fixed version.

Quoted 1 line

.. snip ..

author maintainer
#2 lore raw
Quoted 20 lines · Niklas Schnelle
Quoted 8 lines · Niklas Schnelle

The helper function pci_dev_is_added() from drivers/pci/pci.h is used in PCI arch code of both s390 and powerpc leading to awkward relative includes. Move it to the global include/linux/pci.h and get rid of these includes just for that one function.

---

... snip ...

Quoted 10 lines

static LIST_HEAD(bridge_list);

drivers/pci/pci.h +0 -0
index 93dcdd431072..a159cd0f6f05 100644
@@ -383,21 +383,6 @@ static inline bool pci_dev_is_disconnected(const struct pci_dev *dev)
 	return dev->error_state == pci_channel_io_perm_failure;
 }
 
Quoted 9 lines

drivers/pci/pci.h static inline bool pci_dev_is_disconnected(const struct pci_dev *dev) · line 389

Quoted 4 lines
drivers/pci/pci.h +0 -4
-/* pci_dev priv_flags */
-#define PCI_DEV_ADDED 0
-#define PCI_DPC_RECOVERED 1
-#define PCI_DPC_RECOVERING 2

Sorry, the above two PCI_DPC_* lines should remain in drivers/pci/pci.h I messed this up on rebasing to v5.14-rc1 and it didn't lead to problems on either s390x defconfig, nor pp64_defconfig but breaks ppc allyesconfig. Will resend a fixed version.

Ok looking at this more closely, maybe it would also make sense to move the PCI_DPC_* flags also to include/linux/pci.h that would also put them in direct proximity of the priv_flags field decleration itself which I think also improves maintainability.

Quoted 4 lines

.. snip ..