Skip to contentSkip to conversation

Driver: Adding helper macro for platform_driver boilerplate.

PATCH In review Harshal Chaudhari 2 participants 2 messages May 9, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Driver: Adding helper macro for platform_driver boilerplate.

From: Harshal <[email protected]>

For simple module that contain a single platform_driver without any additional setup code then ends up being a block of duplicated boilerplate.

This patch add a new micro, module_platform_driver(), which replace the module_init()/module_exit() registrations with template functions.

---
 drivers/misc/xilinx_sdfec.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)
drivers/misc/xilinx_sdfec.c +1 -19
index 71bbaa56bdb5..db16a42c66f4 100644
@@ -1484,25 +1484,7 @@ static struct platform_driver xsdfec_driver = {
 	.remove =  xsdfec_remove,
 };
 
-static int __init xsdfec_init(void)
-{
-	int err;
-
-	err = platform_driver_register(&xsdfec_driver);
-	if (err < 0) {
-		pr_err("%s Unabled to register SDFEC driver", __func__);
-		return err;
-	}
-	return 0;
-}
-
-static void __exit xsdfec_exit(void)
-{
-	platform_driver_unregister(&xsdfec_driver);
-}
-
-module_init(xsdfec_init);
-module_exit(xsdfec_exit);
+module_platform_driver(xsdfec_driver);
 
 MODULE_AUTHOR("Xilinx, Inc");
 MODULE_DESCRIPTION("Xilinx SD-FEC16 Driver");
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 7 lines · Harshal Chaudhari

From: Harshal <[email protected]>

For simple module that contain a single platform_driver without any additional setup code then ends up being a block of duplicated boilerplate.

This patch add a new micro, module_platform_driver(), which replace the module_init()/module_exit() registrations with template functions.

Please properly wrap your changelog text.

And fixup the Subject line to match other patches for this driver.

And the text needs to be revised a bit to say what this really is doing, as what you describe is not correct.

Quoted 2 lines

Finally, this does not match your "From:" line for the patch, which means I couldn't take it even if all of the above was correct :(

Please fix up and resend.

thanks,

greg k-h