Skip to contentSkip to conversation

ds2781_battery: convert to module_platform_driver

PATCH In review Devendra Naga 2 participants 2 messages Jul 30, 2012 – Aug 23, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ds2781_battery: convert to module_platform_driver

module_platform_driver can be used to replace the platform_driver register and unregister functions, with the calls to module_init and module_exit,

i.e. all the code that is doing like the below

static int __init mymod_init(void)

{
	return platform_driver_register(&drv_operations);
}

static void __exit mymod_exit(void)

{
	platform_driver_unregister(&drv_operations);
}

module_init(mymod_init);
module_exit(mymod_exit);

can be replaced with
module_platform_driver(drv_operations)...

---
 drivers/power/ds2781_battery.c |   14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/power/ds2781_battery.c +1 -13
index 7a1ff4e..8f84ab7 100644
@@ -835,19 +835,7 @@ static struct platform_driver ds2781_battery_driver = {
 	.remove   = __devexit_p(ds2781_battery_remove),
 };
 
-static int __init ds2781_battery_init(void)
-{
-	return platform_driver_register(&ds2781_battery_driver);
-}
-
-static void __exit ds2781_battery_exit(void)
-{
-	platform_driver_unregister(&ds2781_battery_driver);
-}
-
-module_init(ds2781_battery_init);
-module_exit(ds2781_battery_exit);
-
+module_platform_driver(ds2781_battery_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Renata Sayakhova <[email protected]>");
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 16 lines · Devendra Naga

module_platform_driver can be used to replace the platform_driver register and unregister functions, with the calls to module_init and module_exit,

i.e. all the code that is doing like the below

static int __init mymod_init(void)

{
	return platform_driver_register(&drv_operations);
}

static void __exit mymod_exit(void)

{
	platform_driver_unregister(&drv_operations);
}
Quoted 7 lines

module_init(mymod_init);
module_exit(mymod_exit);

can be replaced with
module_platform_driver(drv_operations)...

Nice! Both patches applied, thank you!