public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/1] pps: generators: pps_gen_parport: Switch to use module_parport_driver()
@ 2022-02-07 14:19 Andy Shevchenko
  2022-02-07 14:33 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-02-07 14:19 UTC (permalink / raw)
  To: Rodolfo Giometti, Andy Shevchenko, linux-kernel; +Cc: Greg Kroah-Hartman

Switch to use module_parport_driver() to reduce boilerplate code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
---

v4: made sure the proper version is taken into consideration
v3: added Ack (Rodolfo), Cc'ed to Greg for picking it up

 drivers/pps/generators/pps_gen_parport.c | 42 ++++--------------------
 1 file 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");
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v4 1/1] pps: generators: pps_gen_parport: Switch to use module_parport_driver()
  2022-02-07 14:19 [PATCH v4 1/1] pps: generators: pps_gen_parport: Switch to use module_parport_driver() Andy Shevchenko
@ 2022-02-07 14:33 ` Greg Kroah-Hartman
  2022-02-07 14:54   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2022-02-07 14:33 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Rodolfo Giometti, linux-kernel

On Mon, Feb 07, 2022 at 04:19:44PM +0200, Andy Shevchenko wrote:
> Switch to use module_parport_driver() to reduce boilerplate code.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Acked-by: Rodolfo Giometti <giometti@enneenne.com>
> ---
> 
> v4: made sure the proper version is taken into consideration
> v3: added Ack (Rodolfo), Cc'ed to Greg for picking it up
> 
>  drivers/pps/generators/pps_gen_parport.c | 42 ++++--------------------
>  1 file 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");
> -- 
> 2.34.1
> 

You changed the functionality here :(

Currently if send_delay is too big, loading the module will fail.

Now it succeeds but binding to a device fails, that's a functional
change.  Are you _SURE_ that is ok to do?

And why did you not mention any of this in the changelog text?  You
passed this off as a mere code cleanup, no functional change :(

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4 1/1] pps: generators: pps_gen_parport: Switch to use module_parport_driver()
  2022-02-07 14:33 ` Greg Kroah-Hartman
@ 2022-02-07 14:54   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-02-07 14:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Rodolfo Giometti, linux-kernel

On Mon, Feb 07, 2022 at 03:33:10PM +0100, Greg Kroah-Hartman wrote:
> On Mon, Feb 07, 2022 at 04:19:44PM +0200, Andy Shevchenko wrote:
> > Switch to use module_parport_driver() to reduce boilerplate code.

> You changed the functionality here :(
> 
> Currently if send_delay is too big, loading the module will fail.
> 
> Now it succeeds but binding to a device fails, that's a functional
> change.  Are you _SURE_ that is ok to do?

We already discussed that during v1 IIRC. And I told that it might even gain
additional flexibility for built-in case of the module.

> And why did you not mention any of this in the changelog text?  You
> passed this off as a mere code cleanup, no functional change :(

This is fair point. Since we end up in the same Q above. I will update
changelog in v5.

Thank you for review!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-07 15:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-07 14:19 [PATCH v4 1/1] pps: generators: pps_gen_parport: Switch to use module_parport_driver() Andy Shevchenko
2022-02-07 14:33 ` Greg Kroah-Hartman
2022-02-07 14:54   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox