2022-11-09 10:54:58

by Jinjie Ruan

[permalink] [raw]
Subject: [PATCH -next] vfio/mlx5: use module_pci_driver

mlx5vf_pci_init and mlx5vf_pci_cleanup with module_init and module_exit
calls can be replaced with the module_pci_driver call, as they are similar
to what module_pci_driver does

Signed-off-by: ruanjinjie <[email protected]>
---
drivers/vfio/pci/mlx5/main.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
index fd6ccb8454a2..457138b92f13 100644
--- a/drivers/vfio/pci/mlx5/main.c
+++ b/drivers/vfio/pci/mlx5/main.c
@@ -676,18 +676,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]>");
--
2.25.1



Subject: RE: [PATCH -next] vfio/mlx5: use module_pci_driver



> -----Original Message-----
> From: ruanjinjie
> Sent: 09 November 2022 09:37
> To: [email protected]; [email protected]; Shameerali Kolothum Thodi
> <[email protected]>; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]
> Cc: ruanjinjie <[email protected]>
> Subject: [PATCH -next] vfio/mlx5: use module_pci_driver
>
> mlx5vf_pci_init and mlx5vf_pci_cleanup with module_init and module_exit
> calls can be replaced with the module_pci_driver call, as they are similar
> to what module_pci_driver does

There is already a patch out there,
https://lore.kernel.org/kvm/[email protected]/

Thanks,
Shameer

> Signed-off-by: ruanjinjie <[email protected]>
> ---
> drivers/vfio/pci/mlx5/main.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
> index fd6ccb8454a2..457138b92f13 100644
> --- a/drivers/vfio/pci/mlx5/main.c
> +++ b/drivers/vfio/pci/mlx5/main.c
> @@ -676,18 +676,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]>");
> --
> 2.25.1