[PATCH v1 net-next 1/3] ptp_ocp: Switch to use module_pci_driver() macro

From: Andy Shevchenko
Date: Fri Aug 13 2021 - 08:27:51 EST


Eliminate some boilerplate code by using module_pci_driver() instead of
init/exit, and, if needed, moving the salient bits from init into probe.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
drivers/ptp/ptp_ocp.c | 20 +-------------------
1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 0d1034e3ed0f..874ea7930079 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -4,7 +4,6 @@
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/module.h>
-#include <linux/init.h>
#include <linux/pci.h>
#include <linux/ptp_clock_kernel.h>

@@ -377,24 +376,7 @@ static struct pci_driver ptp_ocp_driver = {
.probe = ptp_ocp_probe,
.remove = ptp_ocp_remove,
};
-
-static int __init
-ptp_ocp_init(void)
-{
- int err;
-
- err = pci_register_driver(&ptp_ocp_driver);
- return err;
-}
-
-static void __exit
-ptp_ocp_fini(void)
-{
- pci_unregister_driver(&ptp_ocp_driver);
-}
-
-module_init(ptp_ocp_init);
-module_exit(ptp_ocp_fini);
+module_pci_driver(ptp_ocp_driver);

MODULE_DESCRIPTION("OpenCompute TimeCard driver");
MODULE_LICENSE("GPL v2");
--
2.30.2