parport: Introduce module_parport_driver() helper macro
Subsystems (2)
PATCH v2 1/3 parport: Introduce module_parport_driver() helper macro
Introduce module_parport_driver() helper macro to reduce boilerplate in the existing and new code.
---
v2: fixed typo in the macro
include/linux/parport.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
include/linux/parport.h +11 -1
@@ -301,9 +301,19 @@ int __must_check __parport_register_driver(struct parport_driver *,__parport_register_driver (driver,THIS_MODULE ,KBUILD_MODNAME ) /* Unregister a high-level driver. */ -extern void parport_unregister_driver (struct parport_driver *);void parport_unregister_driver (struct parport_driver *); +/** +* module_parport_driver() - Helper macro for registering a modular parport driver +* @__parport_driver: struct parport_driver to be used +* +* Helper macro for parport drivers which do not do anything special in module +* init and exit. This eliminates a lot of boilerplate. Each module may only +* use this macro once, and calling it replaces module_init() and module_exit(). +*/ +#define module_parport_driver (__parport_driver) \ + module_driver(__parport_driver, parport_register_driver, parport_unregister_driver) +/* If parport_register_driver doesn't fit your needs, perhaps * parport_find_xxx does. */ extern struct parport *parport_find_number (int );
Signature · 1 line
2.30.0
PATCH v2 2/3 spi: butterfly: Switch to use module_parport_driver()
Switch to use module_parport_driver() to reduce boilerplate code. Note, device_initcall() is a default for module_init().
---
v2: added Ack (Mark)
drivers/spi/spi-butterfly.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/spi/spi-butterfly.c +1 -12
@@ -317,18 +317,7 @@ static struct parport_driver butterfly_driver = { .detach = butterfly_detach, .devmodel = true, }; - -static int __init butterfly_init (void ) -{ -return parport_register_driver (&butterfly_driver); -} -device_initcall (butterfly_init); - -static void __exit butterfly_exit(void) -{ -parport_unregister_driver (&butterfly_driver); -} -module_exit (butterfly_exit); +module_parport_driver (butterfly_driver);MODULE_DESCRIPTION ("Parport Adapter driver for AVR Butterfly" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.30.0
PATCH v2 3/3 spi: lm70llp: Switch to use module_parport_driver()
In reply to Andy ShevchenkoSwitch to use module_parport_driver() to reduce boilerplate code.
---
v2: added Ack (Mark), drop unneeded note from the commit message
drivers/spi/spi-lm70llp.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/spi/spi-lm70llp.c +1 -12
@@ -320,18 +320,7 @@ static struct parport_driver spi_lm70llp_drv = { .detach = spi_lm70llp_detach, .devmodel = true, }; - -static int __init init_spi_lm70llp (void ) -{ -return parport_register_driver (&spi_lm70llp_drv); -} -module_init (init_spi_lm70llp); - -static void __exit cleanup_spi_lm70llp(void) -{ -parport_unregister_driver (&spi_lm70llp_drv); -} -module_exit (cleanup_spi_lm70llp); +module_parport_driver (spi_lm70llp_drv);MODULE_AUTHOR ("Kaiwan N Billimoria <[email protected]>" ); MODULE_DESCRIPTION(
Signature · 1 line
2.30.0
Quoted 2 lines · Andy Shevchenko
Introduce
module_parport_driver()helper macro to reduce boilerplate in the existing and new code.
Sudip, any comments on this?
Quoted 34 lines
Signed-off-by Andy Shevchenko <[email protected]>---
v2: fixed typo in the macroinclude/linux/parport.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)include/linux/parport.h +11
-1@@ -301,9 +301,19 @@ int __must_check __parport_register_driver(struct parport_driver *,__parport_register_driver (driver,THIS_MODULE ,KBUILD_MODNAME ) /* Unregister a high-level driver. */ -extern void parport_unregister_driver (struct parport_driver *);void parport_unregister_driver (struct parport_driver *); +/** +* module_parport_driver() - Helper macro for registering a modular parport driver +* @__parport_driver: struct parport_driver to be used +* +* Helper macro for parport drivers which do not do anything special in module +* init and exit. This eliminates a lot of boilerplate. Each module may only +* use this macro once, and calling it replaces module_init() and module_exit(). +*/ +#define module_parport_driver (__parport_driver) \ + module_driver(__parport_driver, parport_register_driver, parport_unregister_driver) +/* If parport_register_driver doesn't fit your needs, perhaps * parport_find_xxx does. */ extern struct parport *parport_find_number (int );Signature · 1 line
2.30.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi Andy,
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
Introduce
module_parport_driver()helper macro to reduce boilerplate in the existing and new code.Sudip, any comments on this?
Sorry for the delay in reply.
lgtm. I think there are few more drivers which can also use this new helper. Will you like to do them also?
--
Regards
Sudip
Quoted 10 lines · Sudip Mukherjee
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
Introduce
module_parport_driver()helper macro to reduce boilerplate in the existing and new code.Sudip, any comments on this?
Sorry for the delay in reply.
lgtm. I think there are few more drivers which can also use this new helper. Will you like to do them also?
Yes, that's the (slow going) plan.
Quoted 1 line
Acked-by Sudip Mukherjee <[email protected]>
Thanks! I considered that you take it thru parport tree. Do you have something else in mind?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Sudip Mukherjee
maintainerQuoted 13 lines · Andy Shevchenko
Quoted 10 lines · Sudip Mukherjee
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
Introduce
module_parport_driver()helper macro to reduce boilerplate in the existing and new code.Sudip, any comments on this?
Sorry for the delay in reply.
lgtm. I think there are few more drivers which can also use this new helper. Will you like to do them also?
Quoted 6 lines
Yes, that's the (slow going) plan.
Quoted 1 line
Acked-by Sudip Mukherjee <[email protected]>Thanks! I considered that you take it thru parport tree. Do you have something else in mind?
I dont have a separate parport tree (parport is not under active development to have a separate tree). I send everything parport related to Greg and then he adds it to his tree.
I guess in this case if Greg agrees it can go via Mark's tree as the series will also have SPI related patches.
--
Regards
Sudip
Quoted 17 lines · Sudip Mukherjee
Quoted 15 lines · Andy Shevchenko
Quoted 10 lines · Sudip Mukherjee
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
Introduce
module_parport_driver()helper macro to reduce boilerplate in the existing and new code.Sudip, any comments on this?
Sorry for the delay in reply.
lgtm. I think there are few more drivers which can also use this new helper. Will you like to do them also?Yes, that's the (slow going) plan.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Acked-by Sudip Mukherjee <[email protected]>Thanks! I considered that you take it thru parport tree. Do you have something else in mind?
I dont have a separate parport tree (parport is not under active development to have a separate tree). I send everything parport related to Greg and then he adds it to his tree.
MAINTAINERS doesn't show this. But good to know.
Quoted 2 lines
I guess in this case if Greg agrees it can go via Mark's tree as the series will also have SPI related patches.
Okay, if Greg wants to handle this himself, I think I have to resend (he wasn't in the Cc list). Otherwise Mark can also apply this if Greg is okay (but sounds like I have to resend anyway to let him understand what's going on here).
Signature · 2 lines
With Best Regards, Andy Shevchenko