Skip to contentSkip to conversation

media: remove unnecessary module_init/exit functions

PATCH In review Ethan Nelson-Moore 2 participants 3 messages Jan 31 – Feb 1

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: remove unnecessary module_init/exit functions

Three media drivers have unnecessary module_init and module_exit functions that are empty or just print a message. Remove them. Note that if a module_init function exists, a module_exit function must also exist; otherwise, the module cannot be unloaded.

---
 drivers/media/common/b2c2/flexcop.c         | 14 --------------
 drivers/media/common/saa7146/saa7146_fops.c | 13 -------------
 drivers/media/usb/gspca/gspca.c             | 13 -------------
 3 files changed, 40 deletions(-)
drivers/media/common/b2c2/flexcop.c +0 -14
index 8506de48ba45..1572831be5b8 100644
@@ -292,20 +292,6 @@ void flexcop_device_exit(struct flexcop_device *fc)
 }
 EXPORT_SYMBOL(flexcop_device_exit);
 
-static int flexcop_module_init(void)
-{
-	info(DRIVER_NAME " loaded successfully");
-	return 0;
-}
-
-static void flexcop_module_cleanup(void)
-{
-	info(DRIVER_NAME " unloaded successfully");
-}
-
-module_init(flexcop_module_init);
-module_exit(flexcop_module_cleanup);
-
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_NAME);
 MODULE_LICENSE("GPL");
drivers/media/common/saa7146/saa7146_fops.c +0 -13
index a9e3bad76d54..c0166684eff8 100644
@@ -417,19 +417,6 @@ int saa7146_unregister_device(struct video_device *vfd, struct saa7146_dev *dev)
 }
 EXPORT_SYMBOL_GPL(saa7146_unregister_device);
 
-static int __init saa7146_vv_init_module(void)
-{
-	return 0;
-}
-
-
-static void __exit saa7146_vv_cleanup_module(void)
-{
-}
-
-module_init(saa7146_vv_init_module);
-module_exit(saa7146_vv_cleanup_module);
-
 MODULE_AUTHOR("Michael Hunold <[email protected]>");
 MODULE_DESCRIPTION("video4linux driver for saa7146-based hardware");
 MODULE_LICENSE("GPL");
drivers/media/usb/gspca/gspca.c +0 -13
index 3fc15d16df8e..f3d3f441c851 100644
@@ -1701,19 +1701,6 @@ int gspca_resume(struct usb_interface *intf)
 EXPORT_SYMBOL(gspca_resume);
 #endif
 
-/* -- module insert / remove -- */
-static int __init gspca_init(void)
-{
-	pr_info("v" GSPCA_VERSION " registered\n");
-	return 0;
-}
-static void __exit gspca_exit(void)
-{
-}
-
-module_init(gspca_init);
-module_exit(gspca_exit);
-
 module_param_named(debug, gspca_debug, int, 0644);
 MODULE_PARM_DESC(debug,
 		"1:probe 2:config 3:stream 4:frame 5:packet 6:usbi 7:usbo");
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Ethan,

Thank you for the patch.

Quoted 4 lines · Ethan Nelson-Moore

Three media drivers have unnecessary module_init and module_exit functions that are empty or just print a message. Remove them. Note that if a module_init function exists, a module_exit function must also exist; otherwise, the module cannot be unloaded.

How did you identify those, was it scripted or manual ?

Quoted 1 line

The patch looks good,

I would also be nice to replace the module init/exit functions that register/unregister PCI or USB drivers with the corresponding helper macros (module_pci_driver, module_usb_driver, module_platform_driver, ...), as we have quite a few drivers that still open-code that. In a separate patch of course.

Quoted 79 lines
---
 drivers/media/common/b2c2/flexcop.c         | 14 --------------
 drivers/media/common/saa7146/saa7146_fops.c | 13 -------------
 drivers/media/usb/gspca/gspca.c             | 13 -------------
 3 files changed, 40 deletions(-)
drivers/media/common/b2c2/flexcop.c +0 -14
index 8506de48ba45..1572831be5b8 100644
@@ -292,20 +292,6 @@ void flexcop_device_exit(struct flexcop_device *fc)
 }
 EXPORT_SYMBOL(flexcop_device_exit);
 
-static int flexcop_module_init(void)
-{
-	info(DRIVER_NAME " loaded successfully");
-	return 0;
-}
-
-static void flexcop_module_cleanup(void)
-{
-	info(DRIVER_NAME " unloaded successfully");
-}
-
-module_init(flexcop_module_init);
-module_exit(flexcop_module_cleanup);
-
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_NAME);
 MODULE_LICENSE("GPL");
drivers/media/common/saa7146/saa7146_fops.c +0 -13
index a9e3bad76d54..c0166684eff8 100644
@@ -417,19 +417,6 @@ int saa7146_unregister_device(struct video_device *vfd, struct saa7146_dev *dev)
 }
 EXPORT_SYMBOL_GPL(saa7146_unregister_device);
 
-static int __init saa7146_vv_init_module(void)
-{
-	return 0;
-}
-
-
-static void __exit saa7146_vv_cleanup_module(void)
-{
-}
-
-module_init(saa7146_vv_init_module);
-module_exit(saa7146_vv_cleanup_module);
-
 MODULE_AUTHOR("Michael Hunold <[email protected]>");
 MODULE_DESCRIPTION("video4linux driver for saa7146-based hardware");
 MODULE_LICENSE("GPL");
drivers/media/usb/gspca/gspca.c +0 -13
index 3fc15d16df8e..f3d3f441c851 100644
@@ -1701,19 +1701,6 @@ int gspca_resume(struct usb_interface *intf)
 EXPORT_SYMBOL(gspca_resume);
 #endif
 
-/* -- module insert / remove -- */
-static int __init gspca_init(void)
-{
-	pr_info("v" GSPCA_VERSION " registered\n");
-	return 0;
-}
-static void __exit gspca_exit(void)
-{
-}
-
-module_init(gspca_init);
-module_exit(gspca_exit);
-
 module_param_named(debug, gspca_debug, int, 0644);
 MODULE_PARM_DESC(debug,
 		"1:probe 2:config 3:stream 4:frame 5:packet 6:usbi 7:usbo");
Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw

Hi, Laurent,

Quoted 1 line · Laurent Pinchart

Thank you for the patch.

You're welcome.

Quoted 1 line

How did you identify those, was it scripted or manual ?

Scripted - I don't remember exactly how, but I think I looked for files that had a return statement or } at the start of the line within a few lines of the beginning of their module_init/exit functions.

Quoted 5 lines

I would also be nice to replace the module init/exit functions that register/unregister PCI or USB drivers with the corresponding helper macros (module_pci_driver, module_usb_driver, module_platform_driver, ...), as we have quite a few drivers that still open-code that. In a separate patch of course.

I will do this at some point soon.

Ethan