Skip to contentSkip to conversation

Input: gpio-keys - use module_platform_driver macro

PATCH In review Slawomir Stepien 2 participants 3 messages Oct 27, 2016

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

PATCH 1/1 Input: gpio-keys - use module_platform_driver macro

The gpio_keys_init() and gpio_keys_exit() are not doing anything more then just register and unregister. Replace these functions with module_platform_driver.

---
 drivers/input/keyboard/gpio_keys.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/input/keyboard/gpio_keys.c +1 -12
index 2909365..e54b586 100644
@@ -877,18 +877,7 @@ static struct platform_driver gpio_keys_device_driver = {
 	}
 };
 
-static int __init gpio_keys_init(void)
-{
-	return platform_driver_register(&gpio_keys_device_driver);
-}
-
-static void __exit gpio_keys_exit(void)
-{
-	platform_driver_unregister(&gpio_keys_device_driver);
-}
-
-late_initcall(gpio_keys_init);
-module_exit(gpio_keys_exit);
+module_platform_driver(gpio_keys_device_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Phil Blundell <[email protected]>");
Signature · 1 line
2.10.0
maintainer
#1 lore raw

Hi Slawomir,

Quoted 18 lines · Slawomir Stepien

The gpio_keys_init() and gpio_keys_exit() are not doing anything more then just register and unregister. Replace these functions with module_platform_driver.

---
 drivers/input/keyboard/gpio_keys.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/input/keyboard/gpio_keys.c +0 -1
index 2909365..e54b586 100644
@@ -877,18 +877,7 @@ static struct platform_driver gpio_keys_device_driver = {
 	}
 };
 
-static int __init gpio_keys_init(void)

drivers/input/keyboard/gpio_keys.c static struct platform_driver gpio_keys_device_driver = { · line 890

Quoted 10 lines
drivers/input/keyboard/gpio_keys.c +0 -10
-{
-	return platform_driver_register(&gpio_keys_device_driver);
-}
-
-static void __exit gpio_keys_exit(void)
-{
-	platform_driver_unregister(&gpio_keys_device_driver);
-}
-
-late_initcall(gpio_keys_init);

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Because of this we can't switch to module_platform_driver(). The late_initcall was requirement of one of platforms because of the probe ordering issues. It may be resolved now with deferred probing, but you'd need to confirm with all the users.

Quoted 7 lines
drivers/input/keyboard/gpio_keys.c +1 -1
-module_exit(gpio_keys_exit);
+module_platform_driver(gpio_keys_device_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Phil Blundell <[email protected]>");
Signature · 1 line
2.10.0

Thanks.

Signature · 1 line
Dmitry
#2 lore raw
Quoted 1 line · Dmitry Torokhov

Hi Slawomir,

Hi Dmitry,

Quoted 7 lines
Quoted 1 line

-late_initcall(gpio_keys_init);

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Because of this we can't switch to module_platform_driver(). The late_initcall was requirement of one of platforms because of the probe ordering issues. It may be resolved now with deferred probing, but you'd need to confirm with all the users.

I was unaware of that. Let me look in to that more deeply. At the moment I do not have the knowledge what will be to correct solution for that.

Quoted 7 lines

drivers/input/keyboard/gpio_keys.c static struct platform_driver gpio_keys_device_driver = { · line 883

Quoted 5 lines
drivers/input/keyboard/gpio_keys.c +1 -1
-module_exit(gpio_keys_exit);
+module_platform_driver(gpio_keys_device_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Phil Blundell <[email protected]>");

Thanks.

Thank you.

Signature · 1 line
Slawomir Stepien