Skip to contentSkip to conversation

parport: Introduce module_parport_driver() and use it

PATCH In review Andy Shevchenko 3 participants 8 messages Mar 3, 2021 – Mar 4, 2021

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH v3 1/3 parport: Introduce module_parport_driver() helper macro

In reply to Andy Shevchenko

Introduce module_parport_driver() helper macro to reduce boilerplate in the existing and new code.

---
 include/linux/parport.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
include/linux/parport.h +11 -1
index f981f794c850..1c16ffb8b908 100644
@@ -332,9 +332,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.1
#4 lore raw

PATCH v3 3/3 spi: lm70llp: Switch to use module_parport_driver()

In reply to Andy Shevchenko

Switch to use module_parport_driver() to reduce boilerplate code.

---
 drivers/spi/spi-lm70llp.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/spi/spi-lm70llp.c +1 -12
index 174dba29b1dd..f914b8d2043e 100644
@@ -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.1
#0 lore raw

v3 cover parport: Introduce module_parport_driver() and use it

Introduce module_parport_driver() and use it.
Greg or Mark, since we have this series tagged, can somebody of you pick it up?

Changelog v3:
- added tag on patch 1 (Sudip)
- Cc'ed to Greg

Andy Shevchenko (3):
parport: Introduce module_parport_driver() helper macro
spi: butterfly: Switch to use module_parport_driver()
spi: lm70llp: Switch to use module_parport_driver()

 drivers/spi/spi-butterfly.c | 13 +------------
 drivers/spi/spi-lm70llp.c   | 13 +------------
 include/linux/parport.h     | 12 +++++++++++-
 3 files changed, 13 insertions(+), 25 deletions(-)
Signature · 1 line
2.30.1
#3 lore raw

PATCH v3 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().

---
 drivers/spi/spi-butterfly.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/spi/spi-butterfly.c +1 -12
index 7e71a351f3b7..cceae816cebc 100644
@@ -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.1
maintainer
#5 lore raw
In reply to Andy Shevchenko
Quoted 2 lines · Andy Shevchenko

Introduce module_parport_driver() and use it.
Greg or Mark, since we have this series tagged, can somebody of you pick it up?

Greg, are you OK with me applying this?

Reviewed-by on v3 1/3
#2 lore raw

Re: [PATCH v3 1/3] parport: Introduce module_parport_driver() helper macro

In reply to Andy Shevchenko
Quoted 8 lines · Andy Shevchenko

Introduce module_parport_driver() helper macro to reduce boilerplate in the existing and new code.

---
 include/linux/parport.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
#6 lore raw
In reply to Mark Brown
Quoted 5 lines · Mark Brown
Quoted 2 lines · Andy Shevchenko

Introduce module_parport_driver() and use it.
Greg or Mark, since we have this series tagged, can somebody of you pick it up?

Greg, are you OK with me applying this?

Yup, just sent a reviewed-by for it, thanks.

greg k-h

maintainer
#7 lore raw
In reply to Andy Shevchenko
Quoted 8 lines · Andy Shevchenko

Introduce module_parport_driver() and use it.
Greg or Mark, since we have this series tagged, can somebody of you pick it up?

Changelog v3:
- added tag on patch 1 (Sudip)
- Cc'ed to Greg

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/3] parport: Introduce module_parport_driver() helper macro

      commit: 9c9b536e1ee94558f1ae5ed8d13b76295b2dfef4
[2/3] spi: butterfly: Switch to use module_parport_driver()
      commit: ef3a5316f41fa027cb00b158324a5ef7e3d1a277
[3/3] spi: lm70llp: Switch to use module_parport_driver()
      commit: 7ea6fd9ba47853fb9e88b18d34fc60c71a3fd070

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark