Skip to contentSkip to conversation

vfio/mlx5: Switch to use module_pci_driver() macro

PATCH Applied Shang XiaoJing 4 participants 6 messages Sep 22, 2022 – Nov 10, 2022

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

PATCH 1/1 vfio/mlx5: Switch to use module_pci_driver() macro

Since pci provides the helper macro module_pci_driver(), we may replace the module_init/exit with it.

---
 drivers/vfio/pci/mlx5/main.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/vfio/pci/mlx5/main.c +1 -12
index 759a5f5f7b3f..42bfa2678b81 100644
@@ -654,18 +654,7 @@ static struct pci_driver mlx5vf_pci_driver = {
 	.driver_managed_dma = true,
 };
 
-static void __exit mlx5vf_pci_cleanup(void)
-{
-	pci_unregister_driver(&mlx5vf_pci_driver);
-}
-
-static int __init mlx5vf_pci_init(void)
-{
-	return pci_register_driver(&mlx5vf_pci_driver);
-}
-
-module_init(mlx5vf_pci_init);
-module_exit(mlx5vf_pci_cleanup);
+module_pci_driver(mlx5vf_pci_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Max Gurtovoy <[email protected]>");
Signature · 1 line
2.17.1
#2 lore raw
In reply to Shang XiaoJing
Quoted 7 lines · On Thu, 22 Sep 2022 20:35:07 +0800 Shang XiaoJing <[email protected]>…

Since pci provides the helper macro module_pci_driver(), we may replace the module_init/exit with it.

---
 drivers/vfio/pci/mlx5/main.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

Nice cleanup. Yishai? Thanks,

Alex

Quoted 25 lines
drivers/vfio/pci/mlx5/main.c +1 -12
index 759a5f5f7b3f..42bfa2678b81 100644
@@ -654,18 +654,7 @@ static struct pci_driver mlx5vf_pci_driver = {
 	.driver_managed_dma = true,
 };
 
-static void __exit mlx5vf_pci_cleanup(void)
-{
-	pci_unregister_driver(&mlx5vf_pci_driver);
-}
-
-static int __init mlx5vf_pci_init(void)
-{
-	return pci_register_driver(&mlx5vf_pci_driver);
-}
-
-module_init(mlx5vf_pci_init);
-module_exit(mlx5vf_pci_cleanup);
+module_pci_driver(mlx5vf_pci_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Max Gurtovoy <[email protected]>");
Reviewed-by
#3 lore raw
Quoted 6 lines · Alex Williamson
Quoted 3 lines · On Thu, 22 Sep 2022 20:35:07 +0800 Shang XiaoJing <[email protected]>…

Since pci provides the helper macro module_pci_driver(), we may replace the module_init/exit with it.

Quoted 6 lines
Quoted 4 lines
---
 drivers/vfio/pci/mlx5/main.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

Nice cleanup. Yishai? Thanks,

Jason

maintainer Reviewed-by
#4 lore raw
In reply to Alex Williamson
Quoted 11 lines · Alex Williamson
Quoted 7 lines · On Thu, 22 Sep 2022 20:35:07 +0800 Shang XiaoJing <[email protected]>…

Since pci provides the helper macro module_pci_driver(), we may replace the module_init/exit with it.

---
  drivers/vfio/pci/mlx5/main.c | 13 +------------
  1 file changed, 1 insertion(+), 12 deletions(-)

Nice cleanup. Yishai? Thanks,

Quoted 27 lines

Alex

Quoted 24 lines
drivers/vfio/pci/mlx5/main.c +1 -12
index 759a5f5f7b3f..42bfa2678b81 100644
@@ -654,18 +654,7 @@ static struct pci_driver mlx5vf_pci_driver = {
  	.driver_managed_dma = true,
  };
 
-static void __exit mlx5vf_pci_cleanup(void)
-{
-	pci_unregister_driver(&mlx5vf_pci_driver);
-}
-
-static int __init mlx5vf_pci_init(void)
-{
-	return pci_register_driver(&mlx5vf_pci_driver);
-}
-
-module_init(mlx5vf_pci_init);
-module_exit(mlx5vf_pci_cleanup);
+module_pci_driver(mlx5vf_pci_driver);
 
  MODULE_LICENSE("GPL");
  MODULE_AUTHOR("Max Gurtovoy <[email protected]>");
#5 lore raw
In reply to Shang XiaoJing
Quoted 22 lines · On Thu, 22 Sep 2022 20:35:07 +0800 Shang XiaoJing <[email protected]>…

Since pci provides the helper macro module_pci_driver(), we may replace the module_init/exit with it.

---
 drivers/vfio/pci/mlx5/main.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/vfio/pci/mlx5/main.c +0 -6
index 759a5f5f7b3f..42bfa2678b81 100644
@@ -654,18 +654,7 @@ static struct pci_driver mlx5vf_pci_driver = {
 	.driver_managed_dma = true,
 };
 
-static void __exit mlx5vf_pci_cleanup(void)
-{
-	pci_unregister_driver(&mlx5vf_pci_driver);
-}
-
-static int __init mlx5vf_pci_init(void)

drivers/vfio/pci/mlx5/main.c static struct pci_driver mlx5vf_pci_driver = { · line 660

Quoted 10 lines
drivers/vfio/pci/mlx5/main.c +1 -6
-{
-	return pci_register_driver(&mlx5vf_pci_driver);
-}
-
-module_init(mlx5vf_pci_init);
-module_exit(mlx5vf_pci_cleanup);
+module_pci_driver(mlx5vf_pci_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Max Gurtovoy <[email protected]>");

Applied to vfio next branch for v6.2. Thanks,

Alex