aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shevchenko2022-02-10 15:49:43 +0200
committerGreg Kroah-Hartman2022-03-18 14:01:19 +0100
commite0de88dc7ba2cfd352f0e472044a9176c0a91cf1 (patch)
tree85406c86060e88c4012cc30f23d4fe4f2c67eca5
parent1456277644b3d33e76f553724127184b1cd27974 (diff)
pps: generators: pps_gen_parport: Switch to use module_parport_driver()
Switch to use module_parport_driver() to reduce boilerplate code. Note, it doesn't matter when we check the module parameter. If it was writable we even would have more flexibility of changing it at runtime (when built-in the kernel) after this patch. Acked-by: Rodolfo Giometti <giometti@enneenne.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220210134943.62026-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/pps/generators/pps_gen_parport.c42
1 files changed, 7 insertions, 35 deletions
diff --git a/drivers/pps/generators/pps_gen_parport.c b/drivers/pps/generators/pps_gen_parport.c
index 6a1af7664f3b..b3e084b75c23 100644
--- a/drivers/pps/generators/pps_gen_parport.c
+++ b/drivers/pps/generators/pps_gen_parport.c
@@ -20,8 +20,6 @@
#include <linux/hrtimer.h>
#include <linux/parport.h>
-#define DRVDESC "parallel port PPS signal generator"
-
#define SIGNAL 0
#define NO_SIGNAL PARPORT_CONTROL_STROBE
@@ -180,6 +178,11 @@ static void parport_attach(struct parport *port)
{
struct pardev_cb pps_cb;
+ if (send_delay > SEND_DELAY_MAX) {
+ pr_err("delay value should be not greater then %d\n", SEND_DELAY_MAX);
+ return;
+ }
+
if (attached) {
/* we already have a port */
return;
@@ -231,39 +234,8 @@ static struct parport_driver pps_gen_parport_driver = {
.detach = parport_detach,
.devmodel = true,
};
-
-/* module staff */
-
-static int __init pps_gen_parport_init(void)
-{
- int ret;
-
- pr_info(DRVDESC "\n");
-
- if (send_delay > SEND_DELAY_MAX) {
- pr_err("delay value should be not greater"
- " then %d\n", SEND_DELAY_MAX);
- return -EINVAL;
- }
-
- ret = parport_register_driver(&pps_gen_parport_driver);
- if (ret) {
- pr_err("unable to register with parport\n");
- return ret;
- }
-
- return 0;
-}
-
-static void __exit pps_gen_parport_exit(void)
-{
- parport_unregister_driver(&pps_gen_parport_driver);
- pr_info("hrtimer avg error is %ldns\n", hrtimer_error);
-}
-
-module_init(pps_gen_parport_init);
-module_exit(pps_gen_parport_exit);
+module_parport_driver(pps_gen_parport_driver);
MODULE_AUTHOR("Alexander Gordeev <lasaine@lvk.cs.msu.su>");
-MODULE_DESCRIPTION(DRVDESC);
+MODULE_DESCRIPTION("parallel port PPS signal generator");
MODULE_LICENSE("GPL");