Skip to contentSkip to conversation

Staging: rts5208: Use module_pci_driver

PATCH Superseded Vaishali Thakkar 2 participants 4 messages Mar 9, 2015 Staging

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rts5208: Use module_pci_driver

Macro module_pci_driver is used for drivers whose init and exit paths does only register and unregister to pci API. So, here remove some boilerplate code by using module_pci_driver.

---
 drivers/staging/rts5208/rtsx.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/staging/rts5208/rtsx.c +1 -18
index c74f1b8..7f3f16a 100644
@@ -1048,21 +1048,4 @@ static struct pci_driver driver = {
 	.shutdown = rtsx_shutdown,
 };
 
-static int __init rtsx_init(void)
-{
-	pr_info("Initializing Realtek PCIE storage driver...\n");
-
-	return pci_register_driver(&driver);
-}
-
-static void __exit rtsx_exit(void)
-{
-	pr_info("rtsx_exit() called\n");
-
-	pci_unregister_driver(&driver);
-
-	pr_info("%s module exit\n", CR_DRIVER_NAME);
-}
-
-module_init(rtsx_init)
-module_exit(rtsx_exit)
+module_pci_driver(driver);
Signature · 1 line
1.9.1
#1 lore raw
Quoted 28 lines · Vaishali Thakkar

Macro module_pci_driver is used for drivers whose init and exit paths does only register and unregister to pci API. So, here remove some boilerplate code by using module_pci_driver.

---
 drivers/staging/rts5208/rtsx.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/staging/rts5208/rtsx.c +0 -10
index c74f1b8..7f3f16a 100644
@@ -1048,21 +1048,4 @@ static struct pci_driver driver = {
        .shutdown = rtsx_shutdown,
 };
 
-static int __init rtsx_init(void)
-{
-       pr_info("Initializing Realtek PCIE storage driver...\n");
-
-       return pci_register_driver(&driver);
-}
-
-static void __exit rtsx_exit(void)
-{
-       pr_info("rtsx_exit() called\n");

drivers/staging/rts5208/rtsx.c static struct pci_driver driver = {

Quoted 10 lines
drivers/staging/rts5208/rtsx.c +1 -9
-
-       pci_unregister_driver(&driver);
-
-       pr_info("%s module exit\n", CR_DRIVER_NAME);
-}
-
-module_init(rtsx_init)
-module_exit(rtsx_exit)
+module_pci_driver(driver);
--

I am sorry for this patch. It has some issues.

So, please ignore this patch for sometime.

Quoted 2 lines

1.9.1

Signature · 1 line
Vaishali
maintainer
#2 lore raw
Quoted 34 lines · Vaishali Thakkar
Quoted 32 lines · Vaishali Thakkar

Macro module_pci_driver is used for drivers whose init and exit paths does only register and unregister to pci API. So, here remove some boilerplate code by using module_pci_driver.

---
 drivers/staging/rts5208/rtsx.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/staging/rts5208/rtsx.c +0 -14
index c74f1b8..7f3f16a 100644
@@ -1048,21 +1048,4 @@ static struct pci_driver driver = {
        .shutdown = rtsx_shutdown,
 };
 
-static int __init rtsx_init(void)
-{
-       pr_info("Initializing Realtek PCIE storage driver...\n");
-
-       return pci_register_driver(&driver);
-}
-
-static void __exit rtsx_exit(void)
-{
-       pr_info("rtsx_exit() called\n");
-
-       pci_unregister_driver(&driver);
-
-       pr_info("%s module exit\n", CR_DRIVER_NAME);
Quoted 8 lines

drivers/staging/rts5208/rtsx.c static struct pci_driver driver = {

Quoted 6 lines
drivers/staging/rts5208/rtsx.c +1 -5
-}
-
-module_init(rtsx_init)
-module_exit(rtsx_exit)
+module_pci_driver(driver);
--

I am sorry for this patch. It has some issues.

What "issues"? It looks correct to me.

Yes, you delete the unneeded messages to the kernel log, which is a good thing, and one reason why I want to see drivers move to these macros.

Am I missing something more obvious here?

thanks,

greg k-h

#3 lore raw
Quoted 44 lines · Greg KH
Quoted 34 lines · Vaishali Thakkar
Quoted 32 lines · Vaishali Thakkar

Macro module_pci_driver is used for drivers whose init and exit paths does only register and unregister to pci API. So, here remove some boilerplate code by using module_pci_driver.

---
 drivers/staging/rts5208/rtsx.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/staging/rts5208/rtsx.c +0 -14
index c74f1b8..7f3f16a 100644
@@ -1048,21 +1048,4 @@ static struct pci_driver driver = {
        .shutdown = rtsx_shutdown,
 };
 
-static int __init rtsx_init(void)
-{
-       pr_info("Initializing Realtek PCIE storage driver...\n");
-
-       return pci_register_driver(&driver);
-}
-
-static void __exit rtsx_exit(void)
-{
-       pr_info("rtsx_exit() called\n");
-
-       pci_unregister_driver(&driver);
-
-       pr_info("%s module exit\n", CR_DRIVER_NAME);
Quoted 8 lines

drivers/staging/rts5208/rtsx.c static struct pci_driver driver = {

Quoted 6 lines
drivers/staging/rts5208/rtsx.c +1 -5
-}
-
-module_init(rtsx_init)
-module_exit(rtsx_exit)
+module_pci_driver(driver);
--

I am sorry for this patch. It has some issues.

Quoted 2 lines

What "issues"? It looks correct to me.

It has some build issues. These:

drivers/staging/rts5208/rtsx.c:1051:19: error: conflicting types for ‘driver_init’

 module_pci_driver(driver);
                   ^
include/linux/device.h:1258:19: note: in definition of macro ‘module_driver’
 static int __init __driver##_init(void) \
                   ^

drivers/staging/rts5208/rtsx.c:1051:1: note: in expansion of macro ‘module_pci_driver’
module_pci_driver(driver);
^
include/linux/device.h:919:6: note: previous declaration of ‘driver_init’ was here

 void driver_init(void);
      ^

I already knew about them before sending this patch and I was trying to figure out
the solution. I was supposed to send this patch to my ownself but by mistake it was sent to mailing list. That's why I sent a message to ignore it.

I will be more careful next time before sending a patch.

Quoted 8 lines

Yes, you delete the unneeded messages to the kernel log, which is a good thing, and one reason why I want to see drivers move to these macros.

Am I missing something more obvious here?

thanks,

greg k-h

Signature · 1 line
Vaishali