Skip to contentSkip to conversation

PCI: spear: Use builtin_platform_driver to simplify the code

PATCH In review Wei Yongjun 2 participants 2 messages Sep 10, 2016 – Sep 14, 2016 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: spear: Use builtin_platform_driver to simplify the code

From: Wei Yongjun <[email protected]>

Use the builtin_platform_driver() macro to make the code simpler.

---
 drivers/pci/host/pcie-spear13xx.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/pci/host/pcie-spear13xx.c +1 -5
index 09aed85..1c957eb 100644
@@ -364,8 +364,4 @@ static struct platform_driver spear13xx_pcie_driver = {
 	},
 };
 
-static int __init spear13xx_pcie_init(void)
-{
-	return platform_driver_register(&spear13xx_pcie_driver);
-}
-device_initcall(spear13xx_pcie_init);
+builtin_platform_driver(spear13xx_pcie_driver);
#1 lore raw

[+cc Paul]

Quoted 14 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

Use the builtin_platform_driver() macro to make the code simpler.

---
 drivers/pci/host/pcie-spear13xx.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/pci/host/pcie-spear13xx.c +0 -0
index 09aed85..1c957eb 100644

drivers/pci/host/pcie-spear13xx.c static struct platform_driver spear13xx_pcie_driver = { · line 367

Quoted 9 lines
drivers/pci/host/pcie-spear13xx.c +1 -5
@@ -364,8 +364,4 @@ static struct platform_driver spear13xx_pcie_driver = {
 	},
 };
 
-static int __init spear13xx_pcie_init(void)
-{
-	return platform_driver_register(&spear13xx_pcie_driver);
-}
-device_initcall(spear13xx_pcie_init);
+builtin_platform_driver(spear13xx_pcie_driver);

Hmm. It looks like maybe we could use builtin_platform_driver_probe()? In most or all of the drivers/pci/host drivers?

If you want to do that, please base your patches on my pci/demodularize branch, since that's where I would apply them.

I have to say that the plethora of helper macros is getting a little confusing:

module_driver
module_platform_driver
module_platform_driver_probe
module_pci_driver
...
builtin_driver
builtin_platform_driver
builtin_platform_driver_probe
builtin_pci_driver
...

Actually, seeing the list organized like this makes me feel better, like there really is some underlying structure here. It's just hard to discover in the middle of all the comments and CPP magic.

It is kind of amusing that each one has a big comment header like:

/* module_platform_driver_probe() - Helper macro for drivers that don't do
* anything special in module init/exit. This eliminates a lot of
* boilerplate. Each module may only use this macro once, and
* calling it replaces module_init() and module_exit()
*/

It amuses me that the comments about eliminating boilerplate are *themselves* boilerplate. I guess I'm easily amused.

Bjorn