pps: clients: parport: Switch to use module_parport_driver()
PATCH 1/1 pps: clients: parport: Switch to use module_parport_driver()
Switch to use module_parport_driver() to reduce boilerplate code.
--- drivers/pps/clients/pps_parport.c | 42 ++++++------------------------- 1 file changed, 8 insertions(+), 34 deletions(-)
drivers/pps/clients/pps_parport.c +8 -34
@@ -22,8 +22,6 @@#include <linux/parport.h> #include <linux/pps_kernel.h> -#define DRVDESC "parallel port PPS client" -/* module parameters */ #define CLEAR_WAIT_MAX 100
@@ -138,6 +136,12 @@ static void parport_attach(struct parport *port) .dev = NULL }; +if (clear_wait >CLEAR_WAIT_MAX ) { +pr_err ("clear_wait value should be not greater then %d\n" , +CLEAR_WAIT_MAX ); +return ; + } + device =kzalloc (sizeof (struct pps_client_pp ),GFP_KERNEL );if (!device) {pr_err ("memory allocation failed, not attaching\n" );
@@ -214,38 +218,8 @@ static struct parport_driver pps_parport_driver = { .detach = parport_detach, .devmodel = true, }; - -/* module staff */ - -static int __init pps_parport_init (void ) -{ -int ret; - -pr_info (DRVDESC "\n" ); - -if (clear_wait >CLEAR_WAIT_MAX ) { -pr_err ("clear_wait value should be not greater" -" then %d\n" ,CLEAR_WAIT_MAX ); -return -EINVAL ; - } - - ret =parport_register_driver (&pps_parport_driver); -if (ret) { -pr_err ("unable to register with parport\n" ); -return ret; - } - -return 0 ; -} - -static void __exit pps_parport_exit(void) -{ -parport_unregister_driver (&pps_parport_driver); -} - -module_init (pps_parport_init); -module_exit (pps_parport_exit); +module_parport_driver (pps_parport_driver);MODULE_AUTHOR ("Alexander Gordeev <[email protected]>" ); -MODULE_DESCRIPTION (DRVDESC ); +MODULE_DESCRIPTION ("parallel port PPS client" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.30.2
Rodolfo Giometti
maintainerQuoted 21 lines · Andy Shevchenko
Switch to use
module_parport_driver()to reduce boilerplate code.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/pps/clients/pps_parport.c | 42 ++++++------------------------- 1 file changed, 8 insertions(+), 34 deletions(-)drivers/pps/clients/pps_parport.c +0
-2@@ -22,8 +22,6 @@#include <linux/parport.h> #include <linux/pps_kernel.h> -#define DRVDESC "parallel port PPS client" -/* module parameters */ #define CLEAR_WAIT_MAX 100
drivers/pps/clients/pps_parport.c static void parport_attach(struct parport *port) · line 144
Quoted 9 lines
drivers/pps/clients/pps_parport.c +6
-0@@ -138,6 +136,12 @@ static void parport_attach(struct parport *port) .dev = NULL }; +if (clear_wait >CLEAR_WAIT_MAX ) { +pr_err ("clear_wait value should be not greater then %d\n" , +CLEAR_WAIT_MAX ); +return ; + } +
Why do you need to do so? Maybe a comment would be welcomed.
Quoted 35 lines
drivers/pps/clients/pps_parport.c +0
-27device =kzalloc (sizeof (struct pps_client_pp ),GFP_KERNEL );if (!device) {pr_err ("memory allocation failed, not attaching\n" );@@ -214,38 +218,8 @@ static struct parport_driver pps_parport_driver = { .detach = parport_detach, .devmodel = true, }; - -/* module staff */ - -static int __init pps_parport_init (void ) -{ -int ret; - -pr_info (DRVDESC "\n" ); - -if (clear_wait >CLEAR_WAIT_MAX ) { -pr_err ("clear_wait value should be not greater" -" then %d\n" ,CLEAR_WAIT_MAX ); -return -EINVAL ; - } - - ret =parport_register_driver (&pps_parport_driver); -if (ret) { -pr_err ("unable to register with parport\n" ); -return ret; - } - -return 0 ; -} - -static void __exit pps_parport_exit(void) -{ -parport_unregister_driver (&pps_parport_driver);
drivers/pps/clients/pps_parport.c static struct parport_driver pps_parport_driver = { · line 225
Quoted 10 lines
drivers/pps/clients/pps_parport.c +2
-5-} - -module_init (pps_parport_init); -module_exit (pps_parport_exit); +module_parport_driver (pps_parport_driver);MODULE_AUTHOR ("Alexander Gordeev <[email protected]>" ); -MODULE_DESCRIPTION (DRVDESC ); +MODULE_DESCRIPTION ("parallel port PPS client" );MODULE_LICENSE ("GPL" );
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
Quoted 25 lines · Rodolfo Giometti
Quoted 24 lines · Andy Shevchenko
Switch to use
module_parport_driver()to reduce boilerplate code.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/pps/clients/pps_parport.c | 42 ++++++------------------------- 1 file changed, 8 insertions(+), 34 deletions(-)drivers/pps/clients/pps_parport.c +0
-2@@ -22,8 +22,6 @@#include <linux/parport.h> #include <linux/pps_kernel.h> -#define DRVDESC "parallel port PPS client" -/* module parameters */ #define CLEAR_WAIT_MAX 100@@ -138,6 +136,12 @@ static void parport_attach(struct parport *port) .dev = NULL };
Quoted 8 lines
drivers/pps/clients/pps_parport.c static void parport_attach(struct parport *port) · line 144
Quoted 6 lines
drivers/pps/clients/pps_parport.c +6
-0+if (clear_wait >CLEAR_WAIT_MAX ) { +pr_err ("clear_wait value should be not greater then %d\n" , +CLEAR_WAIT_MAX ); +return ; + } +Why do you need to do so? Maybe a comment would be welcomed.
It's in original code, I just moved it to ->probe().
What comment do you want to have here, because original code has no comment (I think in any case it's out of scope of this change, but may be prepended or appended to the series)?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Rodolfo Giometti
maintainerQuoted 35 lines · Andy Shevchenko
Quoted 25 lines · Rodolfo Giometti
Quoted 24 lines · Andy Shevchenko
Switch to use
module_parport_driver()to reduce boilerplate code.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/pps/clients/pps_parport.c | 42 ++++++------------------------- 1 file changed, 8 insertions(+), 34 deletions(-)drivers/pps/clients/pps_parport.c +0
-2@@ -22,8 +22,6 @@#include <linux/parport.h> #include <linux/pps_kernel.h> -#define DRVDESC "parallel port PPS client" -/* module parameters */ #define CLEAR_WAIT_MAX 100@@ -138,6 +136,12 @@ static void parport_attach(struct parport *port) .dev = NULL };Quoted 8 lines
drivers/pps/clients/pps_parport.c static void parport_attach(struct parport *port) · line 144
Quoted 6 lines
drivers/pps/clients/pps_parport.c +6
-0+if (clear_wait >CLEAR_WAIT_MAX ) { +pr_err ("clear_wait value should be not greater then %d\n" , +CLEAR_WAIT_MAX ); +return ; + } +Why do you need to do so? Maybe a comment would be welcomed.
Quoted 5 lines
It's in original code, I just moved it to ->probe().
What comment do you want to have here, because original code has no comment (I think in any case it's out of scope of this change, but may be prepended or appended to the series)?
Mmm... these functions can be called at different times, so I don't know if we can just move the code safely.
Maybe Alexander (in CC) can help us? :)
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
Quoted 36 lines · Rodolfo Giometti
Quoted 35 lines · Andy Shevchenko
Quoted 33 lines · Rodolfo Giometti
Quoted 21 lines · Andy Shevchenko
Switch to use
module_parport_driver()to reduce boilerplate code.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/pps/clients/pps_parport.c | 42 ++++++------------------------- 1 file changed, 8 insertions(+), 34 deletions(-)drivers/pps/clients/pps_parport.c +0
-2@@ -22,8 +22,6 @@#include <linux/parport.h> #include <linux/pps_kernel.h> -#define DRVDESC "parallel port PPS client" -/* module parameters */ #define CLEAR_WAIT_MAX 100drivers/pps/clients/pps_parport.c static void parport_attach(struct parport *port) · line 144
Quoted 9 lines
drivers/pps/clients/pps_parport.c +6
-0@@ -138,6 +136,12 @@ static void parport_attach(struct parport *port) .dev = NULL }; +if (clear_wait >CLEAR_WAIT_MAX ) { +pr_err ("clear_wait value should be not greater then %d\n" , +CLEAR_WAIT_MAX ); +return ; + } +Why do you need to do so? Maybe a comment would be welcomed.
Quoted 8 lines
Quoted 5 lines
It's in original code, I just moved it to ->probe().
What comment do you want to have here, because original code has no comment (I think in any case it's out of scope of this change, but may be prepended or appended to the series)?
Mmm... these functions can be called at different times, so I don't know if we can just move the code safely.
I do not see any issue here. TL;DR: it won't be worse, but might even give an improvement.
Before it prevented to module to be initialized,
now one may amend this at run time. the downside is that now it will require module removal and inserting versus just two attempts of inserting in a row.
For the built-in case it shouldn't change much (but if /sys/module/.../parameters/... is writable for this, then it will allow to do the similar trick as above, so extending functionality with the flexibility, means direct improvement).
Okay, permissions are 0 there, I don't remember what it means, maybe the parameter won't be available under /sysfs at all, but again, it won't change the functional behaviour, the downside is the memory consumed by the 'built-in' code at run time.
Quoted 1 line
Maybe Alexander (in CC) can help us? :)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 58 lines · Andy Shevchenko
Quoted 36 lines · Rodolfo Giometti
Quoted 35 lines · Andy Shevchenko
Quoted 33 lines · Rodolfo Giometti
Quoted 21 lines · Andy Shevchenko
Switch to use
module_parport_driver()to reduce boilerplate code.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/pps/clients/pps_parport.c | 42 ++++++------------------------- 1 file changed, 8 insertions(+), 34 deletions(-)drivers/pps/clients/pps_parport.c +0
-2@@ -22,8 +22,6 @@#include <linux/parport.h> #include <linux/pps_kernel.h> -#define DRVDESC "parallel port PPS client" -/* module parameters */ #define CLEAR_WAIT_MAX 100drivers/pps/clients/pps_parport.c static void parport_attach(struct parport *port) · line 144
Quoted 9 lines
drivers/pps/clients/pps_parport.c +6
-0@@ -138,6 +136,12 @@ static void parport_attach(struct parport *port) .dev = NULL }; +if (clear_wait >CLEAR_WAIT_MAX ) { +pr_err ("clear_wait value should be not greater then %d\n" , +CLEAR_WAIT_MAX ); +return ; + } +Why do you need to do so? Maybe a comment would be welcomed.
Quoted 8 lines
Quoted 5 lines
It's in original code, I just moved it to ->probe().
What comment do you want to have here, because original code has no comment (I think in any case it's out of scope of this change, but may be prepended or appended to the series)?
Mmm... these functions can be called at different times, so I don't know if we can just move the code safely.
I do not see any issue here. TL;DR: it won't be worse, but might even give an improvement.
Before it prevented to module to be initialized,
now one may amend this at run time. the downside is that now it will require module removal and inserting versus just two attempts of inserting in a row.For the built-in case it shouldn't change much (but if
/sys/module/.../parameters/... is writable for this, then it will allow to do the similar trick as above, so extending functionality with the flexibility, means direct improvement).
Quoted 4 lines
Okay, permissions are 0 there, I don't remember what it means, maybe the parameter won't be available under /sysfs at all, but again, it won't change the functional behaviour, the downside is the memory consumed by the 'built-in' code at run time.
OK, I see. If so it's OK for me:
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
Quoted 5 lines · Rodolfo Giometti
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Rodolfo Giometti
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Rodolfo Giometti
On 10/05/21 16:13, Andy Shevchenko wrote:
...
Quoted 30 lines
Quoted 30 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/pps/clients/pps_parport.c static void parport_attach(struct parport *port) · line 144
Quoted 6 lines
drivers/pps/clients/pps_parport.c +6
-0+if (clear_wait >CLEAR_WAIT_MAX ) { +pr_err ("clear_wait value should be not greater then %d\n" , +CLEAR_WAIT_MAX ); +return ; + } +Why do you need to do so? Maybe a comment would be welcomed.
Quoted 8 lines
Quoted 5 lines
It's in original code, I just moved it to ->probe().
What comment do you want to have here, because original code has no comment (I think in any case it's out of scope of this change, but may be prepended or appended to the series)?
Mmm... these functions can be called at different times, so I don't know if we can just move the code safely.
I do not see any issue here. TL;DR: it won't be worse, but might even give an improvement.
Before it prevented to module to be initialized,
now one may amend this at run time. the downside is that now it will require module removal and inserting versus just two attempts of inserting in a row.For the built-in case it shouldn't change much (but if
/sys/module/.../parameters/... is writable for this, then it will allow to do the similar trick as above, so extending functionality with the flexibility, means direct improvement).
Quoted 6 lines
Quoted 4 lines
Okay, permissions are 0 there, I don't remember what it means, maybe the parameter won't be available under /sysfs at all, but again, it won't change the functional behaviour, the downside is the memory consumed by the 'built-in' code at run time.
OK, I see. If so
At least this is my understanding how it works before and after the change. If anybody has something to clarify here, I would be glad to learn!
Quoted 3 lines
it's OK for me:
Acked-by Rodolfo Giometti <[email protected]>
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko