[PATCH] ARM: PCI: expand single-line pci_common_init() wrapper function

Ethan Nelson-Moore posted 1 patch 1 week ago
arch/arm/include/asm/mach/pci.h                | 9 ---------
arch/arm/mach-dove/pcie.c                      | 2 +-
arch/arm/mach-footbridge/ebsa285-pci.c         | 2 +-
arch/arm/mach-footbridge/netwinder-pci.c       | 2 +-
arch/arm/mach-mv78xx0/pcie.c                   | 2 +-
arch/arm/mach-orion5x/board-mss2.c             | 2 +-
arch/arm/mach-orion5x/board-rd88f5182.c        | 2 +-
arch/arm/mach-orion5x/dns323-setup.c           | 2 +-
arch/arm/mach-orion5x/kurobox_pro-setup.c      | 2 +-
arch/arm/mach-orion5x/terastation_pro2-setup.c | 2 +-
arch/arm/mach-orion5x/ts209-setup.c            | 2 +-
arch/arm/mach-orion5x/ts409-setup.c            | 2 +-
12 files changed, 11 insertions(+), 20 deletions(-)
[PATCH] ARM: PCI: expand single-line pci_common_init() wrapper function
Posted by Ethan Nelson-Moore 1 week ago
pci_common_init() is a compatibility wrapper that simply calls
pci_common_init_dev() with an additional NULL argument. The comment
above it implies that it should be replaced by pci_common_init_dev(),
but that has never happened - there are no callers of
pci_common_init_dev() in the kernel. Make the PCI code more
straightforward by updating all uses of pci_common_init() to instead
call pci_common_init_dev() with a NULL first argument and removing
pci_common_init().

Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
---
 arch/arm/include/asm/mach/pci.h                | 9 ---------
 arch/arm/mach-dove/pcie.c                      | 2 +-
 arch/arm/mach-footbridge/ebsa285-pci.c         | 2 +-
 arch/arm/mach-footbridge/netwinder-pci.c       | 2 +-
 arch/arm/mach-mv78xx0/pcie.c                   | 2 +-
 arch/arm/mach-orion5x/board-mss2.c             | 2 +-
 arch/arm/mach-orion5x/board-rd88f5182.c        | 2 +-
 arch/arm/mach-orion5x/dns323-setup.c           | 2 +-
 arch/arm/mach-orion5x/kurobox_pro-setup.c      | 2 +-
 arch/arm/mach-orion5x/terastation_pro2-setup.c | 2 +-
 arch/arm/mach-orion5x/ts209-setup.c            | 2 +-
 arch/arm/mach-orion5x/ts409-setup.c            | 2 +-
 12 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/arch/arm/include/asm/mach/pci.h b/arch/arm/include/asm/mach/pci.h
index ea9bd08895b7..caad50f64a9c 100644
--- a/arch/arm/include/asm/mach/pci.h
+++ b/arch/arm/include/asm/mach/pci.h
@@ -52,15 +52,6 @@ struct pci_sys_data {
  */
 void pci_common_init_dev(struct device *, struct hw_pci *);
 
-/*
- * Compatibility wrapper for older platforms that do not care about
- * passing the parent device.
- */
-static inline void pci_common_init(struct hw_pci *hw)
-{
-	pci_common_init_dev(NULL, hw);
-}
-
 /*
  * Setup early fixed I/O mapping.
  */
diff --git a/arch/arm/mach-dove/pcie.c b/arch/arm/mach-dove/pcie.c
index 3044b7e03890..f990836409f4 100644
--- a/arch/arm/mach-dove/pcie.c
+++ b/arch/arm/mach-dove/pcie.c
@@ -222,5 +222,5 @@ void __init dove_pcie_init(int init_port0, int init_port1)
 	if (init_port1)
 		add_pcie_port(1, DOVE_PCIE1_VIRT_BASE);
 
-	pci_common_init(&dove_pci);
+	pci_common_init_dev(NULL, &dove_pci);
 }
diff --git a/arch/arm/mach-footbridge/ebsa285-pci.c b/arch/arm/mach-footbridge/ebsa285-pci.c
index c3f280d08fa7..93078a031383 100644
--- a/arch/arm/mach-footbridge/ebsa285-pci.c
+++ b/arch/arm/mach-footbridge/ebsa285-pci.c
@@ -41,7 +41,7 @@ static struct hw_pci ebsa285_pci __initdata = {
 static int __init ebsa285_init_pci(void)
 {
 	if (machine_is_ebsa285())
-		pci_common_init(&ebsa285_pci);
+		pci_common_init_dev(NULL, &ebsa285_pci);
 	return 0;
 }
 
diff --git a/arch/arm/mach-footbridge/netwinder-pci.c b/arch/arm/mach-footbridge/netwinder-pci.c
index e8304392074b..5fc0023f988f 100644
--- a/arch/arm/mach-footbridge/netwinder-pci.c
+++ b/arch/arm/mach-footbridge/netwinder-pci.c
@@ -55,7 +55,7 @@ static struct hw_pci netwinder_pci __initdata = {
 static int __init netwinder_pci_init(void)
 {
 	if (machine_is_netwinder())
-		pci_common_init(&netwinder_pci);
+		pci_common_init_dev(NULL, &netwinder_pci);
 	return 0;
 }
 
diff --git a/arch/arm/mach-mv78xx0/pcie.c b/arch/arm/mach-mv78xx0/pcie.c
index 533cb7856943..9cca6841644e 100644
--- a/arch/arm/mach-mv78xx0/pcie.c
+++ b/arch/arm/mach-mv78xx0/pcie.c
@@ -276,5 +276,5 @@ void __init mv78xx0_pcie_init(int init_port0, int init_port1)
 		}
 	}
 
-	pci_common_init(&mv78xx0_pci);
+	pci_common_init_dev(NULL, &mv78xx0_pci);
 }
diff --git a/arch/arm/mach-orion5x/board-mss2.c b/arch/arm/mach-orion5x/board-mss2.c
index 9e3d69891d2f..aad8d088f839 100644
--- a/arch/arm/mach-orion5x/board-mss2.c
+++ b/arch/arm/mach-orion5x/board-mss2.c
@@ -48,7 +48,7 @@ static struct hw_pci mss2_pci __initdata = {
 static int __init mss2_pci_init(void)
 {
 	if (machine_is_mss2())
-		pci_common_init(&mss2_pci);
+		pci_common_init_dev(NULL, &mss2_pci);
 
 	return 0;
 }
diff --git a/arch/arm/mach-orion5x/board-rd88f5182.c b/arch/arm/mach-orion5x/board-rd88f5182.c
index 1c14e49a90a6..cee3902a95ae 100644
--- a/arch/arm/mach-orion5x/board-rd88f5182.c
+++ b/arch/arm/mach-orion5x/board-rd88f5182.c
@@ -106,7 +106,7 @@ static struct hw_pci rd88f5182_pci __initdata = {
 static int __init rd88f5182_pci_init(void)
 {
 	if (of_machine_is_compatible("marvell,rd-88f5182-nas"))
-		pci_common_init(&rd88f5182_pci);
+		pci_common_init_dev(NULL, &rd88f5182_pci);
 
 	return 0;
 }
diff --git a/arch/arm/mach-orion5x/dns323-setup.c b/arch/arm/mach-orion5x/dns323-setup.c
index fcd38ff7ca45..cdc12b4ce4c5 100644
--- a/arch/arm/mach-orion5x/dns323-setup.c
+++ b/arch/arm/mach-orion5x/dns323-setup.c
@@ -99,7 +99,7 @@ static int __init dns323_pci_init(void)
 	 * gets in the way of initialising the SATA controller.
 	 */
 	if (machine_is_dns323() && system_rev == DNS323_REV_A1)
-		pci_common_init(&dns323_pci);
+		pci_common_init_dev(NULL, &dns323_pci);
 
 	return 0;
 }
diff --git a/arch/arm/mach-orion5x/kurobox_pro-setup.c b/arch/arm/mach-orion5x/kurobox_pro-setup.c
index 339b10891808..c1791aeefeeb 100644
--- a/arch/arm/mach-orion5x/kurobox_pro-setup.c
+++ b/arch/arm/mach-orion5x/kurobox_pro-setup.c
@@ -144,7 +144,7 @@ static int __init kurobox_pro_pci_init(void)
 {
 	if (machine_is_kurobox_pro()) {
 		orion5x_pci_disable();
-		pci_common_init(&kurobox_pro_pci);
+		pci_common_init_dev(NULL, &kurobox_pro_pci);
 	}
 
 	return 0;
diff --git a/arch/arm/mach-orion5x/terastation_pro2-setup.c b/arch/arm/mach-orion5x/terastation_pro2-setup.c
index a9f01859d101..c7af30134fab 100644
--- a/arch/arm/mach-orion5x/terastation_pro2-setup.c
+++ b/arch/arm/mach-orion5x/terastation_pro2-setup.c
@@ -126,7 +126,7 @@ static struct hw_pci tsp2_pci __initdata = {
 static int __init tsp2_pci_init(void)
 {
 	if (machine_is_terastation_pro2())
-		pci_common_init(&tsp2_pci);
+		pci_common_init_dev(NULL, &tsp2_pci);
 
 	return 0;
 }
diff --git a/arch/arm/mach-orion5x/ts209-setup.c b/arch/arm/mach-orion5x/ts209-setup.c
index de9092e992c5..a2c05f039d72 100644
--- a/arch/arm/mach-orion5x/ts209-setup.c
+++ b/arch/arm/mach-orion5x/ts209-setup.c
@@ -174,7 +174,7 @@ static struct hw_pci qnap_ts209_pci __initdata = {
 static int __init qnap_ts209_pci_init(void)
 {
 	if (machine_is_ts209())
-		pci_common_init(&qnap_ts209_pci);
+		pci_common_init_dev(NULL, &qnap_ts209_pci);
 
 	return 0;
 }
diff --git a/arch/arm/mach-orion5x/ts409-setup.c b/arch/arm/mach-orion5x/ts409-setup.c
index 725688aa5cba..94e0100dee36 100644
--- a/arch/arm/mach-orion5x/ts409-setup.c
+++ b/arch/arm/mach-orion5x/ts409-setup.c
@@ -145,7 +145,7 @@ static struct hw_pci qnap_ts409_pci __initdata = {
 static int __init qnap_ts409_pci_init(void)
 {
 	if (machine_is_ts409())
-		pci_common_init(&qnap_ts409_pci);
+		pci_common_init_dev(NULL, &qnap_ts409_pci);
 
 	return 0;
 }
-- 
2.43.0
Re: [PATCH] ARM: PCI: expand single-line pci_common_init() wrapper function
Posted by Andrew Lunn 1 week ago
On Sun, May 17, 2026 at 04:59:11PM -0700, Ethan Nelson-Moore wrote:
> pci_common_init() is a compatibility wrapper that simply calls
> pci_common_init_dev() with an additional NULL argument. The comment
> above it implies that it should be replaced by pci_common_init_dev(),
> but that has never happened - there are no callers of
> pci_common_init_dev() in the kernel. Make the PCI code more
> straightforward by updating all uses of pci_common_init() to instead
> call pci_common_init_dev() with a NULL first argument and removing
> pci_common_init().

Nobody seems to call pci_common_init_dev() without passing NULL. So i
think it makes more sense to rename pci_common_init_dev() to
pci_common_init() and drop struct device *parent parameter. You then
only need to change pci.h and bios32.c.

     Andrew
Re: [PATCH] ARM: PCI: expand single-line pci_common_init() wrapper function
Posted by Ethan Nelson-Moore 1 week ago
Hi, Andrew,

On Sun, May 17, 2026 at 8:42 PM Andrew Lunn <andrew@lunn.ch> wrote:
> Nobody seems to call pci_common_init_dev() without passing NULL. So i
> think it makes more sense to rename pci_common_init_dev() to
> pci_common_init() and drop struct device *parent parameter. You then
> only need to change pci.h and bios32.c.

I considered that, but decided against it because it would prevent the
code from easily being updated to pass a parent parameter in the
future. However, given the age of the affected platforms, that is
unlikely to happen, so your approach might make more sense. What do
you think?

Ethan
Re: [PATCH] ARM: PCI: expand single-line pci_common_init() wrapper function
Posted by Andrew Lunn 6 days, 17 hours ago
On Sun, May 17, 2026 at 09:20:46PM -0700, Ethan Nelson-Moore wrote:
> Hi, Andrew,
> 
> On Sun, May 17, 2026 at 8:42 PM Andrew Lunn <andrew@lunn.ch> wrote:
> > Nobody seems to call pci_common_init_dev() without passing NULL. So i
> > think it makes more sense to rename pci_common_init_dev() to
> > pci_common_init() and drop struct device *parent parameter. You then
> > only need to change pci.h and bios32.c.
> 
> I considered that, but decided against it because it would prevent the
> code from easily being updated to pass a parent parameter in the
> future. However, given the age of the affected platforms, that is
> unlikely to happen, so your approach might make more sense. What do
> you think?

These are all old platforms, they are likely to be slowly removed over
the next few years, and then pci_common_init* can be removed. I don't
expect any code to need to set the parent. And some new board does
come along which needs it, it is an easy revert.

You could also include a tiny patch which removes parent from
pcibios_init_hw().

     Andrew